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
- webhook.site (known exfil)rule:c2RECIPE-C2-WEBHOOK-SITEegress_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 - c2policies/guardrail/strict/rules/c2.yaml - ngrok tunnel (exfil risk)rule:c2RECIPE-C2-NGROKegress_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 - c2policies/guardrail/strict/rules/c2.yaml - Pipedream (known exfil)rule:c2RECIPE-C2-PIPEDREAMegress_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 - c2policies/guardrail/strict/rules/c2.yaml - RequestBin (known exfil)rule:c2RECIPE-C2-REQUESTBINegress_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 - c2policies/guardrail/strict/rules/c2.yaml - HookBin (known exfil)rule:c2RECIPE-C2-HOOKBINegress_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 - c2policies/guardrail/strict/rules/c2.yaml - Burp Collaborator (pentest C2)rule:c2RECIPE-C2-BURPegress_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 - c2policies/guardrail/strict/rules/c2.yaml - interact.sh (OOB exfil)rule:c2RECIPE-C2-INTERACTSHegress_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 - c2policies/guardrail/strict/rules/c2.yaml - oast.fun (OOB testing)rule:c2RECIPE-C2-OASTegress_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 - c2policies/guardrail/strict/rules/c2.yaml - Canary Tokensrule:c2RECIPE-C2-CANARYegress_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 - c2policies/guardrail/strict/rules/c2.yaml - Pastebin raw fetchrule:c2RECIPE-C2-PASTEBINegress_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 - c2policies/guardrail/strict/rules/c2.yaml - AWS metadata endpoint (SSRF)rule:c2RECIPE-C2-METADATA-AWSsensitive_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 - credentialpolicies/guardrail/strict/rules/c2.yaml - GCP metadata endpoint (SSRF)rule:c2RECIPE-C2-METADATA-GCPsensitive_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 - credentialpolicies/guardrail/strict/rules/c2.yaml - Azure metadata endpoint (SSRF)rule:c2RECIPE-C2-METADATA-AZUREsensitive_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 - credentialpolicies/guardrail/strict/rules/c2.yaml - AWS metadata endpoint (hex-encoded SSRF)rule:c2RECIPE-C2-METADATA-HEXsensitive_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 - credentialpolicies/guardrail/strict/rules/c2.yaml - AWS metadata endpoint (decimal-encoded SSRF)rule:c2RECIPE-C2-METADATA-DECIMALsensitive_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 - credentialpolicies/guardrail/strict/rules/c2.yaml - AWS metadata endpoint (octal-encoded SSRF)rule:c2RECIPE-C2-METADATA-OCTALsensitive_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 - credentialpolicies/guardrail/strict/rules/c2.yaml - DNS TXT query with high-entropy label (tunneling indicator)rule:c2RECIPE-C2-DNS-TUNNELegress_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-tunnelpolicies/guardrail/strict/rules/c2.yaml - nslookup with hex subdomain (DNS exfil)rule:c2RECIPE-C2-DNS-EXFILegress_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-tunnelpolicies/guardrail/strict/rules/c2.yaml - SOUL.md active-file mutationrule:cognitive-fileRECIPE-COG-SOULsensitive_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-tamperingpolicies/guardrail/strict/rules/cognitive.yaml - IDENTITY.md active-file mutationrule:cognitive-fileRECIPE-COG-IDENTITYsensitive_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-tamperingpolicies/guardrail/strict/rules/cognitive.yaml - MEMORY.md mutation or referencerule:cognitive-fileRECIPE-COG-MEMORYsensitive_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-tamperingpolicies/guardrail/strict/rules/cognitive.yaml - CLAUDE.md active-file mutationrule:cognitive-fileRECIPE-COG-CLAUDE-MDsensitive_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-tamperingpolicies/guardrail/strict/rules/cognitive.yaml - TOOLS.md active-file mutationrule:cognitive-fileRECIPE-COG-TOOLS-MDsensitive_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-tamperingpolicies/guardrail/strict/rules/cognitive.yaml - AGENTS.md active-file mutationrule:cognitive-fileRECIPE-COG-AGENTS-MDsensitive_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-tamperingpolicies/guardrail/strict/rules/cognitive.yaml
Reading a recipe
| Field | Meaning |
|---|---|
kind | What the recipe slots into: a rule file (rule:secret, rule:command, …) or a suppression list (pre_judge_strip, finding_suppression, tool_suppression). |
id | The stable ID used for findings and telemetry. Keep it stable across edits. |
pattern | The Go RE2 pattern. |
severity | CRITICAL, HIGH, MEDIUM or LOW. The levels map it to an action. |
confidence | How often a match is a true positive, from 0 to 1. |
tags | Labels for filtering and reporting. |
examples / counterexamples | Strings 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
- 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.
AKIAandASIAare the AWS key markers; without them any 20-character upper-case string would match. - An exact length.
{16}matches the real key length, and\bstops a match inside a longer token. - Accurate confidence.
SEC-OPENAI-V2(sk-[a-zA-Z0-9]{40,}) uses 0.85 because other vendors also usesk-. - Useful tags group findings in dashboards.
Secrets
| ID | Pattern | Catches |
|---|---|---|
SEC-AWS-KEY | \b(?:AKIA|ASIA)[0-9A-Z]{16}\b | AWS 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-OPENAI | sk-proj-[a-zA-Z0-9]{20,} | OpenAI project keys |
SEC-SLACK-WEBHOOK | https://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 call | Finding |
|---|---|
echo AKIA3FKJ2M5NQ7XZ8BWV | SEC-AWS-KEY |
echo AKIAIOSFODNN7EXAMPLE | none: 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 output | SEC-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.
- 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
- 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:
- 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:
- 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.
- 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-orghpmatch 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'sREGEX_REDOScheck 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.Cascade and Rego
Set the order guardrail layers decide a call in, the limits that always hold, guardrail.cascade settings, an optional Rego policy and managed locks.
Policy creator
Build a DefenseClaw policy in the browser with an admission preset, rule pack, suppressions, judges and webhooks, then test its install script safely.