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.
git clone --depth 1 https://github.com/abderrahimghazali/cursor-rulesWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/abderrahimghazali/cursor-rules/python-injection)<a href="https://agentmods.dev/rules/abderrahimghazali/cursor-rules/python-injection"><img src="https://agentmods.dev/badge/rules/abderrahimghazali/cursor-rules/python-injection/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/rules/abderrahimghazali/cursor-rules/python-injection"><img src="https://agentmods.dev/badge/rules/abderrahimghazali/cursor-rules/python-injection.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What 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.1 | $0.00000 | $0.02203 |
| Opus 5.5 | $0.00000 | $0.00881 |
| Sonnet 5.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 1mo 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) This is a copy
100% identical to python-injection — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.
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.
- 1mo 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). It is 100% identical to python-injection, differing in 0 lines, and is treated as a copy.
Other cursor rules, from other repositories
010-python-tooling
Python tooling and dependency conventions for plugin-eval and tools/.
pyspark-etl-best-practices-cursorrules-prompt-file
Cursor rules for PySpark ETL development with code style, joins, window functions, map operations, and Iceberg patterns.
python-flask-json-guide-cursorrules-prompt-file
Cursor rules for Python Flask development with JSON guide.
python-llm-ml-workflow-cursorrules-prompt-file
Cursor rules for Python LLM & ML development with workflow integration.
py-fast-api
Cursor rules for Python FastAPI backend development and best practices.
python-github-setup-cursorrules-prompt-file
Cursor rules for Python development with GitHub setup integration.