Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/abderrahimghazali/cursor-rules/python-injectiongit clone --depth 1 https://github.com/abderrahimghazali/cursor-rulesWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.02203 |
| Opus 5 | $0.00000 | $0.01102 |
| Sonnet 5 | $0.00000 | $0.00441 |
| Haiku 4.5 | $0.00000 | $0.00220 |
Grade A, and why
python-injection scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Runs shell commandslowCapability
Expected in a hook, worth knowing in a rule or an instructions file.
subprocess.run(["ls", "-l", user_dir], shell=False) How it starts
The opening of the file, as written. The whole thing — 178 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Python Injection Security Standards (OWASP A03:2021)
This rule enforces security best practices to prevent injection vulnerabilities in Python applications, as defined in OWASP Top 10:2021-A03.
actions:
-
type: enforce conditions:
Pattern 1: SQL Injection - String concatenation in SQL queries
- pattern: "cursor\.(execute|executemany)\(["'][^"']\s[\+%]|cursor\.(execute|executemany)\([^,]+\+\s*[a-zA-Z_][a-zA-Z0-9_]*" message: "Potential SQL injection vulnerability. Use parameterized queries with placeholders instead of string concatenation."
Pattern 2: SQL Injection - String formatting in SQL queries
- pattern: "cursor\.(execute|executemany)\(["'][^"']%[^"']["']\s*%\s*|cursor\.(execute|executemany)\(["'][^"']{[^"']}["']\.format" message: "Potential SQL injection vulnerability. Use parameterized queries with placeholders instead of string formatting."
Pattern 3: Command Injection - Shell command execution with user input
- pattern: "(os\.system|os\.popen|subprocess\.Popen|subprocess\.call|subprocess\.run|subprocess\.check_output)\([^)]\+\s[a-zA-Z_][a-zA-Z0-9_]*|\b(os\.system|os\.popen|subprocess\.Popen|subprocess\.call|subprocess\.run|subprocess\.check_output)\([^)]*format\(|\b(os\.system|os\.popen|subprocess\.Popen|subprocess\.call|subprocess\.run|subprocess\.check_output)\([^)]*f['"]" message: "Potential command injection vulnerability. Never use string concatenation or formatting with shell commands. Use subprocess with shell=False and pass arguments as a list."
Pattern 4: Command Injection - Shell=True in subprocess
- pattern: "(subprocess\.Popen|subprocess\.call|subprocess\.run|subprocess\.check_output)\([^)]shell\s=\s*True" message: "Using shell=True with subprocess functions is dangerous and can lead to command injection. Use shell=False (default) and pass arguments as a list."
Pattern 5: XSS - Unescaped template variables
- pattern: "\{\{\s*[^|]\s\}\}|\{\%\sautoescape\s+off\s\%\}" message: "Potential XSS vulnerability. Ensure all template variables are properly escaped. Avoid using 'autoescape off' in templates."
Pattern 6: XSS - Unsafe HTML rendering in Flask/Django
- pattern: "render_template\([^)]\)|render\([^)]\)|mark_safe\([^)]\)|safe\s\|" message: "Potential XSS vulnerability. Ensure all user-supplied data is properly escaped before rendering in templates."
Pattern 7: Path Traversal - Unsafe file operations
- pattern: "open\([^)]*\+|open\([^)]*format\(|open\([^)]*f['"]" message: "Potential path traversal vulnerability. Validate and sanitize file paths before opening files. Consider using os.path.abspath and os.path.normpath."
Pattern 8: LDAP Injection - Unsafe LDAP queries
- pattern: "ldap\.search\([^)]*\+|ldap\.search\([^)]*format\(|ldap\.search\([^)]*f['"]" message: "Potential LDAP injection vulnerability. Use proper LDAP escaping for user-supplied input in LDAP queries."
Pattern 9: NoSQL Injection - Unsafe MongoDB queries
- pattern: "find\(\{[^}]*\+|find\(\{[^}]*format\(|find\(\{[^}]*f['"]" message: "Potential NoSQL injection vulnerability. Use parameterized queries or proper escaping for MongoDB queries."
Pattern 10: Template Injection - Unsafe template rendering
- pattern: "Template\([^)]\)\.(render|substitute)\(|eval\([^)]\)|exec\([^)]*\)" message: "Potential template injection or code injection vulnerability. Avoid using eval() or exec() with user input, and ensure template variables are properly validated."
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 178 lines · 2,203 tokens per session scan A d3e54b843186
python-injection is a cursor rule published in the GitHub repository abderrahimghazali/cursor-rules (2 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,203 tokens. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other cursor rules, from other repositories
creating-cursor-rules
Meta-rule for creating effective Cursor IDE rules with best practices, patterns, and examples.
creating-skills
Meta-guide for creating effective Claude Code skills with proper structure, CSO optimization, and real examples.
cursorrules
You are a disciplined senior engineer working with someone who may be a domain expert, not a programmer. Build it correctly and safely, not just fast.
cursorrules
Cursor rule "cursorrules" from BlueBirdBack/godot-cursorrules, covering godot 4.4 game development .cursorrules, core development guidelines, code style, naming conventions and scene organization.
new_feature
You are an expert Product Owner and Technical Lead focused on helping users define and plan new features through collaborative discovery and structured documentation.
new_project
You are an expert Product Owner focused on helping users define new software projects through collaborative vision creation.