Policies

Deterministic detection reference

Complete repository-backed reference for DefenseClaw ActionFacts, CEL, regex, semantic proofs, YARA, bounded chains, profiles, and protection packs.

DefenseClaw separates detection evidence from blocking authority. A regex, CEL expression, YARA signature, or correlated sequence can create a finding, but an authenticated tool call can be denied only when a complete, same-rule deterministic proof reaches an enforcement-capable connector surface and the active profile maps its severity to block.

This page inventories the detectors currently shipped in the repository and explains which layer owns each decision. Benchmark scores for these layers are published in Deterministic Detection Benchmarks.

Repository snapshot

The balanced/default enabled rule catalog contains 184 local rules across seven families. The repository also contains 18 fixed bounded chains, five MCP-description YARA signatures, two post-event correlator patterns, five selectable high-assurance packs, and one staged SSH integrity policy contract. The YAML and Go files linked below remain authoritative if these counts change.

Decision architecture

when sequence context is required
atomic proof
complete lineage
SystemAuthenticated tool call or scanned content
PolicyNormalize trusted fields into ActionFacts
PolicyCEL and bounded RE2 candidate selectors
PolicyCode-owned semantic validator
PolicyOptional bounded same-session chain proof
DecisionSame-rule enforcement proof gate
PolicyPermissive / balanced / strict posture
Systemallow / alert / confirm / block
Lexical and semantic signals can detect broadly. Only complete code-owned proof on an eligible synchronous surface can authorize a block.

YARA description scanning and the legacy session correlator are parallel detection lanes. They create findings for audit and operator workflows; they do not bypass the same-rule proof gate or retroactively stop an action.

Current rule inventory

The bundled profiles share a common schema but intentionally differ in enabled rules and lexical fallback posture:

ProfileDeclared rulesEnabled rulesCEL declarationsTool-call-onlyNever-match a^ fallbacks
Balanced/default188184816121
Permissive188180816121
Strict18718781616

a^ is an intentionally impossible RE2 pattern. It is used when a broad raw text fallback would add noise or could not safely prove the same semantic effect. In balanced and permissive, nine CEL declarations are explicit false placeholders for rules that remain lexical-only in those profiles; strict enables tighter variants of those candidates.

The 184 enabled balanced/default rules are generated from policies/guardrail/default/rules/*.yaml:

FamilyRulesWhat it detects
command77Execution, reverse shells, destructive storage operations, persistence, privilege changes, credential access, security-control tampering, cloud, database, Kubernetes, and source-control effects
sensitive-path23Reads or writes involving SSH, cloud, Kubernetes, container, package-manager, Git, environment, browser-session, workload-identity, history, shell-profile, hook, and runtime-socket paths
secret22Provider credentials, API tokens, private keys, JWTs, authenticated connection strings, bearer tokens, and high-confidence secret assignments
trust-exploit22Instruction override, authority impersonation, jailbreak, prompt extraction, persona manipulation, delimiter abuse, and obfuscation signals
c218Known exfiltration endpoints, cloud metadata SSRF forms, DNS tunneling, and DNS exfiltration indicators
enterprise-data13Structured payment, banking, contact, medical, birth-date, CSV, and JSON PII shapes
cognitive-file9Agent instruction, memory, configuration, gateway, and detector-state modification

The generated Go catalog is checked against the YAML in CI. Edit the YAML sources, not internal/gateway/rules_catalog_generated.go.

ActionFacts

ActionFacts is the typed, bounded representation of one tool action. It parses POSIX shell, PowerShell, Windows CMD, argv-style calls, and closed structured tool schemas without trusting free-form descriptions. Unsupported, dynamic, conditional, truncated, ambiguous, or over-budget input records a parse status and cannot gain blocking authority.

Public CEL projection

FactImportant fieldsPurpose
f.commandsprogram, argv completeness, parent/pipeline IDs, operation enums, redirects, dialect, execution effectDistinguish a literal effect from a mention, preview, wrapper, or conditional branch
f.pathscommand ID, read/write/delete/execute access, path flavor, normalized/resolved pathBind an operation to an exact local resource
f.networkcommand ID, connect/listen/download/upload action, scheme, host, port, scope, target kindSeparate loopback/private use from public or unresolved egress
f.data_flowssource and destination command IDs, typed source/sink classesProve bounded source-to-sink relationships inside one action
f.parsestatus, dialect, bounded issue codesFail closed to detection-only when projection is not authoritative
f.tool, f.cwd, f.active_hometrusted connector identity and execution contextResolve tool-specific schemas and local paths without trusting payload claims

The parser caps one command input at 64 KiB and retains at most 128 command facts, 256 path facts, 128 network facts, 256 data-flow facts, and eight issue codes. Exceeding a bound downgrades the projection instead of silently dropping evidence and continuing as authoritative.

Private value-minimized proof facts

Some exact proofs need identities that must not be exposed to operator CEL or persisted as raw values. Code-owned ActionFacts therefore derives only closed operation classes and domain-separated SHA-256 identity digests for:

  • structured text replacement deltas and newly added literal IPv4 addresses;
  • sensitive-egress artifact writes;
  • SQL Server xp_cmdshell operations by connection;
  • PostgreSQL COPY ... PROGRAM connection identity;
  • command-capable SQL UDF create/invoke operations by engine, connection, and function;
  • privileged Kubernetes manifest, pod, and CronJob identities;
  • wireless capture/deauthentication BSSID identity;
  • cloud IAM user or role identity;
  • credential-extraction/remote-execution target and principal identity; and
  • staged payload write, mutation, and persistence-install path identity.

Raw SQL, commands, passwords, connection strings, manifests, principal names, packet filters, payload bytes, and persistence content are discarded before these facts reach durable chain state.

Detection and enforcement projections

The full ActionFacts projection is used for detection. A separate monotonic enforcement projection retains only effects statically proven to execute. Previewed commands, unresolved branches, incomplete argv, dynamic identities, and parser-limit failures can still produce a useful alert through a fallback, but cannot be upgraded into a deny.

See CEL authoring for the complete public field and enum reference.

CEL selectors

Each bundled profile declares 81 CEL expressions. CEL is deliberately limited to Boolean logic, field access, fixed enum constants, membership, bounded exists comprehensions, and literal RE2 matching. It cannot perform arbitrary history scans, dynamic regex construction, reflection, network access, file access, or unbounded iteration.

A successful CEL match is a candidate, not automatic block authority. The engine evaluates the expression against both full facts and the execute-only projection, then requires a code-owned proof pinned to the same rule ID. CEL errors, budget exhaustion, unsupported connector fields, and partial parsing fall back to that rule's regex lane and remain detection-only unless an exact fallback validator independently proves the same rule.

The admitted syntax, 50 ms dispatch budget, aggregate cost ceiling, and regex limits are documented in CEL engine boundaries.

Regex detection and fallback

All local patterns compile with Go's RE2-based regexp engine. The catalog uses regex in three distinct ways:

UseEnforcement meaning
Content detectorCreates findings for secrets, trust exploitation, C2, PII, and unstructured prompts/results
Tool-call candidate selectorNarrows calls before an exact ActionFacts/code-owned validator runs
Owner-local fallbackPreserves visibility when a semantic projection is unsupported or over budget

On an authenticated tool action, a raw or custom regex match is not trusted blocking proof. The finding remains detection-only unless a complete exact validator for that same rule accepts the action. Twenty-one balanced/default rules intentionally use a^ so there is no lexical fallback at all.

Pattern-writing guidance and counterexamples are in the Regex cookbook.

Exact atomic semantic rules

This benchmarked change added or materially completed 34 exact semantic rule IDs. Twenty-eight combine CEL and regex candidate selection, four use CEL with lexical fallback disabled, and two use a code-owned exact proof selected by a narrow regex. Neither selector alone can authorize a block.

Security effectExact rule IDs
Executionexec.remote_ip_download_execute_same_artifact, exec.postgresql_copy_program, exec.sql_command_udf_create
Persistencepersistence.global_ld_preload_install, persistence.windows_accessibility_feature_hijack
Privilegeprivilege.cloud_iam_administrator_attachment, privilege.kubernetes_cronjob_privileged_patch, privilege.sudoers_unrestricted_nopasswd, privilege.windows_uac_autoelevation_hijack
Credential accesscredential.macos_fake_update_prompt, credential.macos_login_keychain_dump, credential.pam_password_capture, credential.windows_lsass_memory_dump, credential.windows_registry_hive_dump
Impactimpact.linux_magic_sysrq_destruction, impact.posix_host_halt, impact.windows_delete_all_shadow_copies, impact.windows_recovery_disable_pair, impact.windows_recovery_store_destruction
Security-control tamperingtamper.cloud_audit_control_destruction, tamper.complete_firewall_relaxation, tamper.endpoint_security_product_disable, tamper.linux_security_control_disable, tamper.macos_unified_log_erase, tamper.posix_logging_hardening_disable, tamper.posix_system_log_destruction, tamper.windows_amsi_disable, tamper.windows_audit_policy_wipe, tamper.windows_credential_protection_weaken, tamper.windows_defender_component_disable, tamper.windows_defender_multi_control_disable, tamper.windows_registry_security_control_disable, tamper.windows_telemetry_disable, tamper.windows_usn_journal_delete

These rules accept closed literal grammars and reject near-miss executables, help/version invocations, dynamic operands, preview modes, conditional or augmented commands, unresolved paths, mismatched identities, and incomplete structured arguments.

Bounded tool-call chains

The fixed chain catalog contains 18 ordered behaviors. A chain examines only the current authenticated event plus at most eight predecessors from the same canonical connector/session, never more than 30 minutes. Required steps must be ordered, successful where specified, and joined by exact value-minimized identity. Failed, denied, cancelled, replayed, cross-session, mismatched, or mutated sequences cannot complete an enforcement proof.

ChainDeterministic joinRuntime posture
Guardrails disabled → external egressSame session, bounded orderEnforcement-capable proof
Permission denied → runtime bypassSame session, five-minute windowEnforcement-capable proof
Privilege discovery → elevationSame session, system/root semanticsEnforcement-capable proof
Secret-manager read → external egressSame session, bounded resultEnforcement-capable proof
Secret read → external egressExact artifact identity and mutation barrierEnforcement-capable proof
Workload identity read → lateral executionSame workload identity contextEnforcement-capable proof
Download → decode → executeExact derived artifact identity and mutation barrierEnforcement-capable proof
Download → executeExact artifact identity and mutation barrierAlert-only
Sensitive-egress artifact write → executeExact artifact identity and mutation barrierAlert-only
Firewall trust expansion → destination useExact canonical IP identityAlert-only until protected-firewall/approved-destination policy exists
SQL Server xp_cmdshell enable → invokeExact connection identity and successful terminal stepAlert-only until protected-database policy exists
Privileged host-root manifest write → apply → pod execExact manifest and pod identities, successful terminal stepAlert-only until protected-cluster policy exists
Wireless capture → deauthenticationExact BSSID and successful terminal stepAlert-only because authorization is deployment-specific
Credential extraction → remote executionExact target/principal and successful terminal stepAlert-only until protected-target policy exists
Cloud IAM principal create → AdministratorAccess attachExact principal and successful terminal stepAlert-only until protected-account policy exists
Privileged CronJob patch → job creationExact CronJob identity and successful terminal stepAlert-only until protected-cluster policy exists
Command-capable SQL UDF create → invokeExact engine, connection, and function; successful terminal stepAlert-only until protected-database policy exists
Reverse-shell payload write → persistence installExact path, closed payload grammar, success, and mutation barrierEnforcement-capable proof

“Enforcement-capable” means the chain can set the enforcement-safe result bit; the connector must still be synchronous and block-capable, the same-rule proof gate must accept it, and the active profile must map the severity to block.

Profile posture

Profiles change the disposition of accepted findings; they do not make an incomplete proof complete.

SeverityPermissiveBalanced/defaultStrict
CRITICALBlockBlockBlock
HIGHAlertAlert or confirm when HITL is enabledBlock
MEDIUMAllowAlertBlock
LOWAllowAllowAlert

Strict intentionally accepts more interruption risk. Balanced/default is the recommended general posture, while permissive is useful for observation-heavy deployments. Connector capability still controls whether block can become a native deny; unsupported surfaces retain the finding and audit action without claiming prevention. See Defaults for the complete operator configuration.

YARA MCP-description scanning

The MCP scanner adds five YARA signatures from policies/yara/mcp-tools/description_injection.yara:

SignatureRequires
Addressed sensitive-data transferA send/share verb, sensitive object, user-directed language, and an addressed email-like sink
Concrete financial actionAn account action, literal amount, and owned-account language
Exact destructive user-data actionA narrow delete/move/remove operation and an owned data object
Security-control downgradeA request to disable MFA/2FA on the user's account
Multi-attribute profile changeOne request changing email, location, and birthday together

These signatures are high-precision description-injection signals, not proof of authorization or tool execution. They remain alert-only. The scanner loads the pack in addition to its existing native rules and preserves the matching YARA rule name in the finding.

Protection packs and policy-provided context

Some actions are dual-use globally but deterministically forbidden inside a customer-declared boundary. High-assurance packs supply that missing policy fact and use closed CEL/ActionFacts proofs instead of resource-name guesses.

PackStatusDeterministic coverage
privacy-high-assuranceSelectable13 structured PII rules for SSNs, payment cards, IBANs, labeled email/phone, medical IDs, dates of birth, and structured CSV/JSON records
cloud-production-protectionSelectableBulk cloud-data deletion, cloud resource/service deletion, and audit-control destruction for production-scoped connectors
database-destruction-protectionSelectableLiteral SQL DELETE without WHERE and schema/table-wide destructive statements for a closed client set
infrastructure-destruction-protectionSelectableUnscoped Terraform, OpenTofu, and Pulumi destruction while allowing plans, previews, and targeted operations
kubernetes-production-protectionSelectableNamed namespace deletion and closed delete --all workload forms for protected clusters
ssh-authorized-keys-protectionStaged contract; not activatable yetExact active-home authorized_keys write, OpenSSH fingerprint derivation, and comparison with trusted approved fingerprints

The SSH contract intentionally abstains today because the public CEL activation does not expose file content or a trusted fingerprint allowlist parameter. It must not be selected as policy_dir until that binding exists. Dynamic paths, malformed keys, missing policy, failed writes, and unresolved homes already fail closed to abstention in its ActionFacts helper.

Other deterministic detection lanes

Post-event correlator

Two bundled patterns operate on persisted findings:

  • LETHAL-TRIFECTA: ordered untrusted ingress, sensitive access, then external egress;
  • TRIFECTA-WITH-FINGERPRINT-MATCH: the same content fingerprint appears in sensitive access and later external egress.

Both emit a synthetic CRITICAL CORR-* finding. They are post-event detection, not retroactive blocking and not a substitute for exact bounded tool-call chains.

Optional LLM judge

Injection, PII, and tool-injection judges handle ambiguous content. They are optional, non-deterministic secondary detectors and are deliberately outside the benchmarked deterministic block path. Data-exfiltration is a category of the tool-injection judge rather than a separate judge file.

OPA/Rego

OPA/Rego owns admission, firewall, sandbox, audit, skill-action, and final guardrail policy-domain decisions. It does not replace ActionFacts/CEL parsing; instead, it maps accepted findings and deployment context to policy outcomes.

Source of truth and validation

ConcernRepository source
Bundled local rules and CEL expressionspolicies/guardrail/{default,permissive,strict}/rules/*.yaml
ActionFacts types and parsersinternal/actionfacts/
CEL compiler/evaluator and limitsinternal/guardrail/semantic/
Exact semantic ownership and final proof dispatchinternal/gateway/semantic_owners*.go, internal/gateway/rule_match_validation.go
Fixed bounded chainsinternal/guardrail/tool_chain.go
YARA MCP-description signaturespolicies/yara/mcp-tools/description_injection.yara
Correlator patternsinternal/guardrail/defaults/correlation-patterns.yaml
High-assurance packspolicies/guardrail-use-cases/
Reproducible public scoresbenchmarks/

Run the repository checks after changing a detector:

make check-guardrail-catalog
go test ./internal/actionfacts ./internal/guardrail ./internal/gateway
go test ./benchmarks/...

The catalog check prevents generated Go rules from drifting from YAML. Focused tests exercise parser hard negatives, same-rule proof ownership, bounded chain identity, profile action posture, and connector enforcement eligibility.