Detection patterns for malicious IDE rule files. Scan .cursorrules, .clinerules, .windsurfrules, CLAUDE.md, AGENTS.md, .github/copilot-instructions.md, and other AI coding assistant configuration files for hidden attacks.
No competitor scanner covers this surface.
AI coding assistants trust rule files implicitly. Attackers exploit this with:
- Unicode obfuscation -- invisible characters (zero-width joiners, bidirectional markers, Unicode Tags block) that hide malicious instructions from human reviewers but are readable by LLMs
- Prompt injection -- instructions that override safety filters, suppress logging, or redirect code generation
- Exfiltration directives -- rules that instruct the AI to embed attacker-controlled endpoints, steal environment variables, or leak code context
- Behaviour suppression -- instructions that tell the AI to hide what it did from the developer ("do not mention this in your response")
- Supply chain propagation -- a single poisoned rule file in a repo affects every developer who clones it
The Rules File Backdoor attack demonstrated this against Cursor and Copilot. 30+ vulnerabilities have been found across Cursor, Copilot, and Windsurf.
| Format | Tool | File(s) |
|---|---|---|
| Cursor Rules | Cursor | .cursorrules, .cursor/rules/*.mdc |
| Cline Rules | Cline | .clinerules, .cline/rules/*.md |
| Windsurf Rules | Windsurf | .windsurfrules |
| Claude Config | Claude Code | CLAUDE.md, .claude/settings.json |
| Codex Rules | OpenAI Codex | AGENTS.md |
| Copilot Instructions | GitHub Copilot | .github/copilot-instructions.md |
| Aider Conventions | Aider | .aider.conf.yml, CONVENTIONS.md |
| Roo Rules | Roo Code | .roo/rules/*.md |
| Zed Rules | Zed | .zed/rules.md |
Hidden characters that conceal malicious instructions from human review.
Instructions that override system behaviour, bypass safety filters, or hijack the agent's goals.
Directives to leak secrets, environment variables, source code, or context to external endpoints.
Instructions that prevent the AI from revealing its actions to the developer.
Rules that cause the AI to silently inject malicious code (script tags, backdoors, vulnerable patterns).
Instructions that expand the AI agent's capabilities beyond intended scope.
Rules that manipulate the AI's understanding of the codebase or task to produce subtly wrong output.
ide-rule-detector/
patterns/
unicode-obfuscation.yaml # CAT-01
prompt-injection.yaml # CAT-02
data-exfiltration.yaml # CAT-03
behaviour-suppression.yaml # CAT-04
code-injection.yaml # CAT-05
permission-escalation.yaml # CAT-06
context-poisoning.yaml # CAT-07
samples/
benign/ # Clean rule files for testing
malicious/ # Known-malicious patterns for testing
scripts/
scan.py # Standalone scanner script
docs/
file-formats.md # Detailed file format documentation
threat-model.md # Attack surface analysis
Each pattern file uses a structured YAML format:
- id: "CAT-02-001"
name: "System prompt override"
severity: critical
category: prompt-injection
description: "Instruction to ignore or override system/safety prompts"
patterns:
- regex: "(?i)ignore\\s+(all\\s+)?(previous|prior|above|system)\\s+(instructions|prompts|rules)"
- regex: "(?i)disregard\\s+(all\\s+)?(safety|security|previous)\\s+(filters|rules|instructions)"
references:
- "https://genai.owasp.org/llmrisk/llm01-prompt-injection/"
mitre_atlas: "AML.T0051"# Clone
git clone https://github.com/spiffy-oss/ide-rule-detector.git
cd ide-rule-detector
# Scan a rule file
python scripts/scan.py path/to/.cursorrules
# Scan a directory
python scripts/scan.py --recursive path/to/project/
# Output JSON
python scripts/scan.py --format json path/to/.cursorrulesThis library powers Layer 3 of artguard. The patterns are designed to be consumed standalone or as a dependency.
import yaml
with open("patterns/prompt-injection.yaml") as f:
patterns = yaml.safe_load(f)We accept pattern contributions. Each pattern must include:
- A unique ID following the
CAT-XX-XXXconvention - At least one regex pattern
- A severity level (critical, high, medium, low, info)
- A description explaining what the pattern detects and why it matters
- A reference link where possible
See CONTRIBUTING.md for details.
MIT