Guardrail

Guardrail rule recipes

Search and copy the regex rules and suppressions in DefenseClaw's rule packs, plus RE2 patterns from the strict pack and what makes each one precise.

The recipe catalog is the library the Policy creator draws from. It holds every rule of the strict pack, the strict pack's pre-judge strips and finding suppressions (from policies/guardrail/strict/suppressions.yaml), and the default pack's tool suppressions (from policies/guardrail/default/suppressions.yaml; the strict pack has none). Each card names its source file. Copy an entry into your own pack (Packs and rules), or drop it into a draft in the creator.

Browse the recipes

Showing 24 of 304 recipes.
  • webhook.site (known exfil)rule:c2
    RECIPE-C2-WEBHOOK-SITE
    egress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity HIGH.

    YAML
    - id: C2-WEBHOOK-SITE
      pattern: (?i)(?:^|[^a-zA-Z0-9-])webhook\.site(?:[^a-zA-Z0-9.-]|$)
      title: webhook.site (known exfil)
      severity: HIGH
      confidence: 0.9
      tags:
        - exfiltration
        - c2
    
    policies/guardrail/strict/rules/c2.yaml
  • ngrok tunnel (exfil risk)rule:c2
    RECIPE-C2-NGROK
    egress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity HIGH.

    YAML
    - id: C2-NGROK
      pattern: (?i)(?:^|[^a-zA-Z0-9-])(?:ngrok\.io|ngrok-free\.app)(?:[^a-zA-Z0-9.-]|$)
      title: ngrok tunnel (exfil risk)
      severity: HIGH
      confidence: 0.85
      tags:
        - exfiltration
        - c2
    
    policies/guardrail/strict/rules/c2.yaml
  • Pipedream (known exfil)rule:c2
    RECIPE-C2-PIPEDREAM
    egress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity HIGH.

    YAML
    - id: C2-PIPEDREAM
      pattern: (?i)pipedream\.net
      title: Pipedream (known exfil)
      severity: HIGH
      confidence: 0.9
      tags:
        - exfiltration
        - c2
    
    policies/guardrail/strict/rules/c2.yaml
  • RequestBin (known exfil)rule:c2
    RECIPE-C2-REQUESTBIN
    egress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity HIGH.

    YAML
    - id: C2-REQUESTBIN
      pattern: (?i)requestbin\.com
      title: RequestBin (known exfil)
      severity: HIGH
      confidence: 0.9
      tags:
        - exfiltration
        - c2
    
    policies/guardrail/strict/rules/c2.yaml
  • HookBin (known exfil)rule:c2
    RECIPE-C2-HOOKBIN
    egress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity HIGH.

    YAML
    - id: C2-HOOKBIN
      pattern: (?i)hookbin\.com
      title: HookBin (known exfil)
      severity: HIGH
      confidence: 0.9
      tags:
        - exfiltration
        - c2
    
    policies/guardrail/strict/rules/c2.yaml
  • Burp Collaborator (pentest C2)rule:c2
    RECIPE-C2-BURP
    egress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity HIGH.

    YAML
    - id: C2-BURP
      pattern: (?i)burpcollaborator\.net
      title: Burp Collaborator (pentest C2)
      severity: HIGH
      confidence: 0.9
      tags:
        - exfiltration
        - c2
    
    policies/guardrail/strict/rules/c2.yaml
  • interact.sh (OOB exfil)rule:c2
    RECIPE-C2-INTERACTSH
    egress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity HIGH.

    YAML
    - id: C2-INTERACTSH
      pattern: (?i)interact\.sh
      title: interact.sh (OOB exfil)
      severity: HIGH
      confidence: 0.9
      tags:
        - exfiltration
        - c2
    
    policies/guardrail/strict/rules/c2.yaml
  • oast.fun (OOB testing)rule:c2
    RECIPE-C2-OAST
    egress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity HIGH.

    YAML
    - id: C2-OAST
      pattern: (?i)(?:^|[^a-zA-Z0-9-])oast\.fun(?:[^a-zA-Z0-9.-]|$)
      title: oast.fun (OOB testing)
      severity: HIGH
      confidence: 0.85
      tags:
        - exfiltration
        - c2
    
    policies/guardrail/strict/rules/c2.yaml
  • Canary Tokensrule:c2
    RECIPE-C2-CANARY
    egress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity MEDIUM.

    YAML
    - id: C2-CANARY
      pattern: (?i)canarytokens\.com
      title: Canary Tokens
      severity: MEDIUM
      confidence: 0.75
      tags:
        - exfiltration
        - c2
    
    policies/guardrail/strict/rules/c2.yaml
  • Pastebin raw fetchrule:c2
    RECIPE-C2-PASTEBIN
    egress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity MEDIUM.

    YAML
    - id: C2-PASTEBIN
      pattern: (?i)pastebin\.com/raw/
      title: Pastebin raw fetch
      severity: MEDIUM
      confidence: 0.7
      tags:
        - exfiltration
        - c2
    
    policies/guardrail/strict/rules/c2.yaml
  • AWS metadata endpoint (SSRF)rule:c2
    RECIPE-C2-METADATA-AWS
    sensitive_accessegress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity CRITICAL.

    YAML
    - id: C2-METADATA-AWS
      expression: f.commands.exists(c, c.argv_complete && defenseclaw.guardrail.semantic.v1.OperationKind.OPERATION_KIND_FETCH in c.operations && f.network.exists(n, n.command_id == c.id && n.action in [defenseclaw.guardrail.semantic.v1.NetworkAction.NETWORK_ACTION_DOWNLOAD, defenseclaw.guardrail.semantic.v1.NetworkAction.NETWORK_ACTION_CONNECT]))
      pattern: 169\.254\.169\.254
      title: AWS metadata endpoint (SSRF)
      severity: CRITICAL
      confidence: 0.95
      tags:
        - ssrf
        - credential
    
    policies/guardrail/strict/rules/c2.yaml
  • GCP metadata endpoint (SSRF)rule:c2
    RECIPE-C2-METADATA-GCP
    sensitive_accessegress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity CRITICAL.

    YAML
    - id: C2-METADATA-GCP
      pattern: (?i)(?:^|[^a-zA-Z0-9-])metadata\.google\.internal(?:[^a-zA-Z0-9.-]|$)
      title: GCP metadata endpoint (SSRF)
      severity: CRITICAL
      confidence: 0.95
      tags:
        - ssrf
        - credential
    
    policies/guardrail/strict/rules/c2.yaml
  • Azure metadata endpoint (SSRF)rule:c2
    RECIPE-C2-METADATA-AZURE
    sensitive_accessegress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity CRITICAL.

    YAML
    - id: C2-METADATA-AZURE
      pattern: 169\.254\.169\.254/metadata
      title: Azure metadata endpoint (SSRF)
      severity: CRITICAL
      confidence: 0.95
      tags:
        - ssrf
        - credential
    
    policies/guardrail/strict/rules/c2.yaml
  • AWS metadata endpoint (hex-encoded SSRF)rule:c2
    RECIPE-C2-METADATA-HEX
    sensitive_accessegress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity CRITICAL.

    YAML
    - id: C2-METADATA-HEX
      pattern: (?i)0xa9fea9fe
      title: AWS metadata endpoint (hex-encoded SSRF)
      severity: CRITICAL
      confidence: 0.95
      tags:
        - ssrf
        - credential
    
    policies/guardrail/strict/rules/c2.yaml
  • AWS metadata endpoint (decimal-encoded SSRF)rule:c2
    RECIPE-C2-METADATA-DECIMAL
    sensitive_accessegress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity CRITICAL.

    YAML
    - id: C2-METADATA-DECIMAL
      pattern: (?:^|[/])2852039166(?:$|[/])
      title: AWS metadata endpoint (decimal-encoded SSRF)
      severity: CRITICAL
      confidence: 0.93
      tags:
        - ssrf
        - credential
    
    policies/guardrail/strict/rules/c2.yaml
  • AWS metadata endpoint (octal-encoded SSRF)rule:c2
    RECIPE-C2-METADATA-OCTAL
    sensitive_accessegress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity CRITICAL.

    YAML
    - id: C2-METADATA-OCTAL
      pattern: 0251\.0376\.0251\.0376
      title: AWS metadata endpoint (octal-encoded SSRF)
      severity: CRITICAL
      confidence: 0.93
      tags:
        - ssrf
        - credential
    
    policies/guardrail/strict/rules/c2.yaml
  • DNS TXT query with high-entropy label (tunneling indicator)rule:c2
    RECIPE-C2-DNS-TUNNEL
    egress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity HIGH.

    YAML
    - id: C2-DNS-TUNNEL
      pattern: (?i)\b(?:dig|host|nslookup|drill)\b\s+[^;\n]*\$\((?:whoami|hostname|id(?:\s+-u)?|cat\s+(?:/etc/hostname|/etc/machine-id))\)[A-Za-z0-9._-]*\.[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+
      title: DNS TXT query with high-entropy label (tunneling indicator)
      severity: HIGH
      confidence: 0.78
      tags:
        - exfiltration
        - dns-tunnel
    
    policies/guardrail/strict/rules/c2.yaml
  • nslookup with hex subdomain (DNS exfil)rule:c2
    RECIPE-C2-DNS-EXFIL
    egress_external

    Pattern shipped in the bundled strict rule pack (c2.yaml). Severity HIGH.

    YAML
    - id: C2-DNS-EXFIL
      pattern: (?i)\bnslookup\b\s+[a-f0-9]{8,}\.\w+\.
      title: nslookup with hex subdomain (DNS exfil)
      severity: HIGH
      confidence: 0.8
      tags:
        - exfiltration
        - dns-tunnel
    
    policies/guardrail/strict/rules/c2.yaml
  • SOUL.md active-file mutationrule:cognitive-file
    RECIPE-COG-SOUL
    sensitive_access

    Pattern shipped in the bundled strict rule pack (cognitive.yaml). Severity CRITICAL.

    YAML
    - id: COG-SOUL
      tool_call_only: true
      expression: f.paths.exists(p, p.access in [defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_WRITE, defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_APPEND, defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_DELETE])
      pattern: (?i)SOUL\.md
      title: SOUL.md active-file mutation
      severity: CRITICAL
      confidence: 0.95
      tags:
        - cognitive-tampering
    
    policies/guardrail/strict/rules/cognitive.yaml
  • IDENTITY.md active-file mutationrule:cognitive-file
    RECIPE-COG-IDENTITY
    sensitive_access

    Pattern shipped in the bundled strict rule pack (cognitive.yaml). Severity CRITICAL.

    YAML
    - id: COG-IDENTITY
      tool_call_only: true
      expression: f.paths.exists(p, p.access in [defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_WRITE, defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_APPEND, defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_DELETE])
      pattern: (?i)IDENTITY\.md
      title: IDENTITY.md active-file mutation
      severity: CRITICAL
      confidence: 0.95
      tags:
        - cognitive-tampering
    
    policies/guardrail/strict/rules/cognitive.yaml
  • MEMORY.md mutation or referencerule:cognitive-file
    RECIPE-COG-MEMORY
    sensitive_access

    Pattern shipped in the bundled strict rule pack (cognitive.yaml). Severity HIGH.

    YAML
    - id: COG-MEMORY
      expression: f.paths.exists(p, p.access in [defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_WRITE, defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_APPEND, defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_DELETE])
      pattern: (?i)MEMORY\.md
      title: MEMORY.md mutation or reference
      severity: HIGH
      confidence: 0.85
      tags:
        - cognitive-tampering
    
    policies/guardrail/strict/rules/cognitive.yaml
  • CLAUDE.md active-file mutationrule:cognitive-file
    RECIPE-COG-CLAUDE-MD
    sensitive_access

    Pattern shipped in the bundled strict rule pack (cognitive.yaml). Severity HIGH.

    YAML
    - id: COG-CLAUDE-MD
      tool_call_only: true
      expression: f.paths.exists(p, p.access in [defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_WRITE, defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_APPEND, defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_DELETE])
      pattern: (?i)CLAUDE\.md
      title: CLAUDE.md active-file mutation
      severity: HIGH
      confidence: 0.85
      tags:
        - cognitive-tampering
    
    policies/guardrail/strict/rules/cognitive.yaml
  • TOOLS.md active-file mutationrule:cognitive-file
    RECIPE-COG-TOOLS-MD
    sensitive_access

    Pattern shipped in the bundled strict rule pack (cognitive.yaml). Severity HIGH.

    YAML
    - id: COG-TOOLS-MD
      tool_call_only: true
      expression: f.paths.exists(p, p.access in [defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_WRITE, defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_APPEND, defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_DELETE])
      pattern: (?i)TOOLS\.md
      title: TOOLS.md active-file mutation
      severity: HIGH
      confidence: 0.8
      tags:
        - cognitive-tampering
    
    policies/guardrail/strict/rules/cognitive.yaml
  • AGENTS.md active-file mutationrule:cognitive-file
    RECIPE-COG-AGENTS-MD
    sensitive_access

    Pattern shipped in the bundled strict rule pack (cognitive.yaml). Severity HIGH.

    YAML
    - id: COG-AGENTS-MD
      tool_call_only: true
      expression: f.paths.exists(p, p.access in [defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_WRITE, defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_APPEND, defenseclaw.guardrail.semantic.v1.PathAccess.PATH_ACCESS_DELETE])
      pattern: a^
      title: AGENTS.md active-file mutation
      severity: HIGH
      confidence: 0.8
      tags:
        - cognitive-tampering
    
    policies/guardrail/strict/rules/cognitive.yaml

Reading a recipe

FieldMeaning
kindWhat the recipe slots into: a rule file (rule:secret, rule:command, …) or a suppression list (pre_judge_strip, finding_suppression, tool_suppression).
idThe stable ID used for findings and telemetry. Keep it stable across edits.
patternThe Go RE2 pattern.
severityCRITICAL, HIGH, MEDIUM or LOW. The levels map it to an action.
confidenceHow often a match is a true positive, from 0 to 1.
tagsLabels for filtering and reporting.
examples / counterexamplesStrings the creator's tester runs through the pattern.

Paste a rule under the rules: key of a file in your pack's rules/ folder, and a suppression under the matching list in suppressions.yaml.

Regex patterns

DefenseClaw compiles every guardrail pattern with Go's RE2-based regexp. RE2 never backtracks, so no pattern can hang the gateway. A regex match on a tool call is detection only; a block needs a CEL expression over complete facts (Custom rules with CEL).

RE2 does not support

Lookarounds ((?=…), (?!…), (?<=…), (?<!…)), backreferences (\1, \k<name>), atomic groups ((?>…)) and possessive quantifiers (*+, ++). Re-author with a non-capturing group and tighter character classes. The creator's tester names the feature. A rule's fallback pattern can be at most 2,048 bytes.

Anatomy of a good rule

policies/guardrail/strict/rules/secrets.yaml (excerpt)
- id: SEC-AWS-KEY
  pattern: '\b(?:AKIA|ASIA)[0-9A-Z]{16}\b'
  title: "AWS access key"
  severity: CRITICAL
  confidence: 0.95
  tags: [credential]
  • A fixed prefix. AKIA and ASIA are the AWS key markers; without them any 20-character upper-case string would match.
  • An exact length. {16} matches the real key length, and \b stops a match inside a longer token.
  • Accurate confidence. SEC-OPENAI-V2 (sk-[a-zA-Z0-9]{40,}) uses 0.85 because other vendors also use sk-.
  • Useful tags group findings in dashboards.

Secrets

IDPatternCatches
SEC-AWS-KEY\b(?:AKIA|ASIA)[0-9A-Z]{16}\bAWS access key IDs, except the AWS documentation example
SEC-GITHUB-TOKEN(?:ghp_|gho_|ghu_|ghs_|ghr_)[a-zA-Z0-9]{36,}GitHub personal, OAuth, user, server and refresh tokens
SEC-PRIVKEY-----BEGIN (?:RSA |EC |OPENSSH |PGP |DSA )?PRIVATE KEY-----Complete PEM and OpenSSH private keys: header, a body that parses, and footer. A header line alone does not match.
SEC-OPENAIsk-proj-[a-zA-Z0-9]{20,}OpenAI project keys
SEC-SLACK-WEBHOOKhttps://hooks\.slack\.com/services/T[A-Z0-9]+/B[A-Z0-9]+/[a-zA-Z0-9]+Slack incoming-webhook URLs

A match is a finding only when the text can be a real secret. Documented public examples (such as the AWS sample key) and filler (placeholder, changeme) are dropped, so a quick test with them gets no finding.

These Claude Code Bash tool calls get these findings from the shipped default pack. A regex match on a tool call is an alert and does not block the call:

Bash tool callFinding
echo AKIA3FKJ2M5NQ7XZ8BWVSEC-AWS-KEY
echo AKIAIOSFODNN7EXAMPLEnone: the AWS documentation example key
echo -----BEGIN RSA PRIVATE KEY-----none: a header line with no key
cat of a key that ssh-keygen -t ed25519 wrote, in the tool outputSEC-PRIVKEY

Prompt injection

The shipped rules anchor the phrase to the start of a sentence, a list item or a role label (or an agent timestamp envelope before the user text), so a sentence that only mentions the phrase does not match. See TRUST-IGNORE-PREVIOUS in the catalog. For ambiguous wording, turn on the LLM judge rather than widening the regex.

policies/guardrail/strict/rules/trust-exploit.yaml (excerpt)
- id: TRUST-IGNORE-PREVIOUS
  pattern: '(?im)(?:^|^\[[^\]\n]{0,64}\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}[^\]\n]{0,32}\]\s*|[.!?;,:]\s*|(?:[-*>•]|<!--|["''])\s*|\b(?:task|instruction|system|assistant)\s*:\s*)(?:(?:please,?|(?:can|could|will|would)\s+you(?:\s+please)?|i\s+(?:want|need)\s+you\s+to(?:\s+please)?|now,?|next,?|you\s+(?:must|should|need\s+to))\s+)?ignore\s+(?:(?:all|any|every|the|these|those|of)\s+)*(?:(?:your|my)\s+)?(?:previous|prior|above|earlier|preceding|former)\s+(?:instructions?|rules|guidelines|directions|context)'
  title: "Ignore previous instructions"
  severity: CRITICAL
  confidence: 0.90
  tags: [prompt-injection]

Zero-width obfuscation

policies/guardrail/strict/rules/trust-exploit.yaml (excerpt)
- id: OBFUSC-UNICODE-ZWSP
  pattern: '(?:[A-Za-z0-9][\x{200B}\x{200C}\x{200D}\x{FEFF}][\s\S]*?){10,}'
  title: Zero-width character obfuscation
  severity: HIGH
  confidence: 0.95
  tags: [prompt-injection, obfuscation]

It counts U+200B, U+200C, U+200D and U+FEFF right after an ASCII letter or digit. Ten insertions are needed; nine do not match, and a joiner between two emoji does not count.

Exfiltration endpoints

Known collection endpoints match as a whole host name, so webhook.site matches but mywebhook.site.example does not:

policies/guardrail/strict/rules/c2.yaml (excerpt)
- id: C2-WEBHOOK-SITE
  pattern: '(?i)(?:^|[^a-zA-Z0-9-])webhook\.site(?:[^a-zA-Z0-9.-]|$)'
  title: "webhook.site (known exfil)"
  severity: HIGH
  confidence: 0.90
  tags: [exfiltration, c2]

Tool-call rules pair a CEL expression with a regex fallback for calls that cannot be parsed in full. Here the fallback catches a wget download piped into an interpreter:

policies/guardrail/strict/rules/commands.yaml (excerpt)
- id: CMD-PIPE-WGET
  tool_call_only: true
  expression: >-
    f.commands.exists(c, c.argv_complete && c.program in ['wget', 'wget.exe'] &&
    (defenseclaw.guardrail.semantic.v1.OperationKind.OPERATION_KIND_FETCH in c.operations ||
    defenseclaw.guardrail.semantic.v1.OperationKind.OPERATION_KIND_UPLOAD in c.operations))
  pattern: '(?i)\bwget\b\s+[^|]*\|\s*(?:[/\w.-]+/)?(?:bash|zsh|sh|dash|ksh|python(?:[0-9.]*)?|perl|ruby)\b'
  title: "wget piped to shell"
  severity: CRITICAL
  confidence: 0.95
  tags: [execution, download-exec]

Personal data

Numeric patterns false-positive more often than other patterns, so the shipped rules encode the structure of the number. ENT-BULK-SSN rejects area numbers that are never issued (000, 666, 9xx) and all-zero groups; the card rules check the scheme prefix and grouping. Suppressions cannot quiet these rules (they filter only judge findings): narrow the pattern or disable the rule in your pack.

policies/guardrail/strict/rules/enterprise-data.yaml (excerpt)
- id: ENT-BULK-SSN
  pattern: '\b(?:00[1-9]|0[1-9][0-9]|[1-5][0-9]{2}|6[0-5][0-9]|66[0-5]|66[7-9]|6[7-9][0-9]|[78][0-9]{2})-(?:0[1-9]|[1-9][0-9])-(?:000[1-9]|00[1-9][0-9]|0[1-9][0-9]{2}|[1-9][0-9]{3})\b'
  title: "US Social Security Number"
  severity: CRITICAL
  confidence: 0.85
  tags: [pii, regulated]
- id: ENT-CC-VISA
  pattern: '\b4\d{3}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b'
  title: "Visa credit card number"
  severity: CRITICAL
  confidence: 0.80
  tags: [pii, pci]

Patterns to avoid

  • An unanchored .* or [\s\S]*. Two harmless words far apart become a finding. Bound the gap ([\s\S]{0,120}) or anchor both sides.
  • Short or common prefixes alone. sk- or ghp match ordinary text; pair a prefix with the exact length and character class.
  • Nested quantifiers such as (\w+)+. They match far more than intended; the creator's REGEX_REDOS check flags them.
  • Case-insensitive matching without (?i). Use the inline flag so the engine and your tester agree.

Have an agent write a rule

Hand this to your agent

Read https://cisco-ai-defense.github.io/defenseclaw/docs/guardrail/recipes/llms.md and follow the section "Have an agent write a rule". Show me the rule before you apply it.