rules: # ── CRITICAL: prompt injection ── - id: prompt-injection-0 severity: CRITICAL pattern: prompt-injection message: "Prompt injection attempt detected" regex: '(?i)(ignore\s+(all\s+)?previous\s+instructions|disregard\s+(all\s+)?rules|you\s+are\s+now\b|forget\s+everything|override\s+safety)' - id: prompt-injection-1 severity: CRITICAL pattern: prompt-injection message: "SYSTEM: prompt override detected" regex: '(?im)^\s*(SYSTEM|OVERRIDE|IGNORE|ADMIN|ROOT):' # Lowercase config keys whose value is data on the same line are not # directives; uppercase labels always match. Each key accepts only the # value kinds its config uses: scalars for all, space-free paths for root # (RE2 has no backreferences, so each quoting is listed), and inline # objects for ignore whose words are joined by punctuation, not spaces or # slashes, or inline arrays of quoted space-free items (globs). root also # accepts a typed parameter (root: Path, lang: set[str] | None = None): # every type and type argument is a capitalized or builtin name, and # further parameters must be name: Type. No empty values (an indented # block follows) and no trailing comments (# and // do not hide text in # Markdown). exclude: '^\s*(?:(?:system|override|ignore|admin|root):\s*(?:true|false|yes|no|on|off|null|~|-?\d+(?:\.\d+)?)|root:\s*(?:"(?:[.~/]|\w[\w.-]*/|[A-Za-z]:\\)[^\s"'']*"|''(?:[.~/]|\w[\w.-]*/|[A-Za-z]:\\)[^\s"'']*''|(?:[.~/]|\w[\w.-]*/|[A-Za-z]:\\)[^\s"'']*)|ignore:\s*\{\s*(?:["'']?[\w-]*["'']?\s*[:,\[\]]\s*)*["'']?[\w-]*["'']?\s*\}|ignore:\s*\[\s*(?:(?:"[^\s"]*"|''[^\s'']*'')(?:\s*,\s*(?:"[^\s"]*"|''[^\s'']*''))*\s*,?\s*)?\]|root:\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\[(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\[(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\s*[,|]\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object))*\])?(?:\s*[,|]\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\[(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\s*[,|]\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object))*\])?)*\])?(?:\s*\|\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\[(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\[(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\s*[,|]\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object))*\])?(?:\s*[,|]\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\[(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\s*[,|]\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object))*\])?)*\])?)*(?:\s*=\s*(?:None|True|False|-?\d+(?:\.\d+)?|"[^\s"]*"|''[^\s'']*''))?(?:\s*,\s*\w+\s*:\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\[(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\[(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\s*[,|]\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object))*\])?(?:\s*[,|]\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\[(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\s*[,|]\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object))*\])?)*\])?(?:\s*\|\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\[(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\[(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\s*[,|]\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object))*\])?(?:\s*[,|]\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\[(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object)(?:\s*[,|]\s*(?:[A-Z]\w*|str|int|float|bool|bytes|list|dict|set|tuple|object))*\])?)*\])?)*(?:\s*=\s*(?:None|True|False|-?\d+(?:\.\d+)?|"[^\s"]*"|''[^\s'']*''))?)*),?\s*$' - id: prompt-injection-2 severity: HIGH pattern: prompt-injection message: "Agent directive tag detected" regex: '(?i)<\/?(system|instructions|override|prompt|rules)\b[^>]*>' - id: prompt-injection-3 severity: CRITICAL pattern: prompt-injection message: "Directive-style prompt override detected" regex: '(?im)^\s*(DEV(ELOPER)?[\s_]*MODE|JAILBREAK|DAN[\s_.]*MODE)\b' # ── CRITICAL: data exfiltration (curl/wget + secrets) ── - id: data-exfiltration-2 severity: MEDIUM pattern: data-exfiltration message: "External image with query parameters — potential data exfiltration vector" regex: '!\[[^\]]*\]\(https?://[^)]*\?[^)]+\)' - id: data-exfiltration-0 severity: CRITICAL pattern: data-exfiltration message: "Command may exfiltrate sensitive data" regex: '(?i)(curl|wget)\s+.*(\$SECRET|\$TOKEN|\$API_KEY|\$OPENAI_API_KEY|\$ANTHROPIC_API_KEY|\$AWS_SECRET)' - id: data-exfiltration-1 severity: CRITICAL pattern: data-exfiltration message: "Command sends environment variables externally" regex: '(?i)(curl|wget)\s+.*\$\{?(HOME|USER|PATH|SSH|GPG|AWS|GITHUB_TOKEN|OPENAI|ANTHROPIC)' # ── CRITICAL/HIGH/MEDIUM/LOW: credential access ── # Credential-access rules are now table-driven (see credentials.go). # To disable a specific credential rule, use its descriptive ID in audit-rules.yaml: # - id: credential-access-ssh-private-key # enabled: false # ── CRITICAL: invisible payload (Unicode tag characters U+E0001–E007F) ── # Primary vector for Pillar Security "Rules File Backdoor" attack. # Tag characters render 0px wide but are fully processed by LLMs. - id: hidden-unicode-1 severity: CRITICAL pattern: invisible-payload message: "Unicode tag characters detected — may contain invisible payload" regex: '[\x{E0001}-\x{E007F}]' # ── CRITICAL: output suppression directives ── # Explicit concealment of actions or instructions is a strong malicious signal. - id: prompt-injection-4 severity: CRITICAL pattern: prompt-injection message: "Output suppression directive — attempts to hide actions from user" regex: '(?i)((don''t|do\s+not)\s+tell\s+the\s+user\s+(about\s+)?(this|the)\s+(instruction|change|action)\b|do\s+not\s+(mention|reveal)\s+this\s+(instruction|change|action|to\s+the\s+user)|never\s+(mention|reveal)\s+this\s+instruction|hide\s+this\s+from\s+the\s+user|remove\s+(this\s+)?from\s+(chat|conversation)\s+history)' # A generic disclosure restriction may be advice or concealment. Keep it # visible without treating an ambiguous prefix as confirmed malicious intent. - id: prompt-injection-5 severity: HIGH pattern: prompt-injection message: "Possible output suppression — review disclosure restriction" regex: '(?i)(don''t|do\s+not)\s+tell\s+the\s+user' exclude: '(?i)(don''t|do\s+not)\s+tell\s+the\s+user\s+(about\s+)?(this|the)\s+(instruction|change|action)\b' # ── HIGH: hidden unicode (zero-width characters) ── - id: hidden-unicode-0 severity: HIGH pattern: hidden-unicode message: "Hidden zero-width Unicode characters detected" regex: "[\u200B\u200C\u200D\u2060\uFEFF]" # ── HIGH: bidirectional text control (Trojan Source CVE-2021-42574) ── - id: hidden-unicode-2 severity: HIGH pattern: hidden-unicode message: "Bidirectional text control characters — may reorder visible text (Trojan Source)" regex: "[\u202A-\u202E\u2066-\u2069]" # ── HIGH: config/memory file poisoning ── # Skills should not modify agent config files (MEMORY.md, CLAUDE.md, .cursorrules). - id: config-manipulation-0 severity: HIGH pattern: config-manipulation message: "Instructions to modify AI agent configuration or memory files" regex: '(?i)\b(write|modify|edit|update|append|add|insert|inject)\b.{0,20}(MEMORY\.md|SOUL\.md|CLAUDE\.md|\.cursorrules|\.windsurfrules|\.clinerules)\b' # ── HIGH: prompt injection in markdown reference-link comment ── - id: hidden-comment-injection-1 severity: HIGH pattern: hidden-comment-injection message: "Prompt injection hidden in markdown comment" regex: '(?i)\[//\]:\s*#\s*\(.*?(ignore\s+(all\s+)?previous|disregard|you\s+are\s+now|forget\s+everything|override\s+safety|SYSTEM:|ADMIN:)' # ── HIGH: DNS data exfiltration ── - id: data-exfiltration-3 severity: HIGH pattern: data-exfiltration message: "Potential DNS data exfiltration via encoded subdomain" regex: '(?i)\b(dig|nslookup|host)\b\s+.*(\$[({]|`)' # ── HIGH: self-replication / propagation instructions ── - id: self-propagation-0 severity: HIGH pattern: self-propagation message: "Self-replication instruction — may spread payload to other files" regex: '(?i)(add|inject|insert|include)\s+(this|these)\s+(instruction|rule|directive|text)\s+(to|into|in)\s+(all|every|each|other)\b' # ── MEDIUM: untrusted package execution ── - id: untrusted-install-0 severity: MEDIUM pattern: untrusted-install message: "Auto-execute untrusted npm package without confirmation" regex: '(?i)\bnpx\s+(-y\s+|--yes\s+)' - id: untrusted-install-1 severity: MEDIUM pattern: untrusted-install message: "pip install from URL (not PyPI registry)" regex: '(?i)\bpip3?\s+install\s+https?://' # ── MEDIUM: additional invisible Unicode (soft hyphen, math operators, directional marks) ── - id: hidden-unicode-3 severity: MEDIUM pattern: hidden-unicode message: "Invisible Unicode characters detected (soft hyphen, directional marks, math operators)" regex: "[\u00AD\u200E\u200F\u2061-\u2064]" # ── HIGH: destructive commands ── - id: destructive-commands-0 severity: HIGH pattern: destructive-commands message: "Potentially destructive command" regex: '(?i)\brm\s+-rf\s+(/(\s|$|\*)|\*|\./)' - id: destructive-commands-1 severity: HIGH pattern: destructive-commands message: "Unsafe permission change" regex: '(?i)\bchmod\s+777\b' - id: destructive-commands-2 severity: HIGH pattern: destructive-commands message: "Sudo escalation" regex: '(?i)\bsudo\s+' - id: destructive-commands-3 severity: HIGH pattern: destructive-commands message: "Disk overwrite command" regex: '(?i)\bdd\s+if=' - id: destructive-commands-4 severity: HIGH pattern: destructive-commands message: "Filesystem format command" regex: '(?i)\bmkfs\.' # ── HIGH: dynamic code execution (JS/Python eval/exec) ── - id: dynamic-code-exec-0 severity: HIGH pattern: dynamic-code-exec message: "Dynamic code execution (eval/exec) detected" regex: '(?i)\b(eval|exec)\s*\(' exclude: '(?i)\b(eval|exec)\w+\s*\(' - id: dynamic-code-exec-1 severity: HIGH pattern: dynamic-code-exec message: "Dynamic Function constructor detected" regex: '(?i)\bnew\s+Function\s*\(' # ── HIGH: Python shell execution ── - id: shell-execution-0 severity: HIGH pattern: shell-execution message: "Python shell execution detected" regex: '(?i)\b(os\.system|subprocess\.(run|call|Popen|check_output|check_call))\s*\(' # ── HIGH: hidden injection in HTML comments ── - id: hidden-comment-injection-0 severity: HIGH pattern: hidden-comment-injection message: "Prompt injection hidden in HTML comment" regex: '(?i)