

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
123456 # Python Injection Security Standards (OWASP A03:2021)78This rule enforces security best practices to prevent injection vulnerabilities in Python applications, as defined in OWASP Top 10:2021-A03.910<rule>11name: python_injection12description: Detect and prevent injection vulnerabilities in Python applications as defined in OWASP Top 10:2021-A0313filters:14 - type: file_extension15 pattern: "\\.(py)$"16 - type: file_path17 pattern: ".*"1819actions:20 - type: enforce21 conditions:22 # Pattern 1: SQL Injection - String concatenation in SQL queries23 - pattern: "cursor\\.(execute|executemany)\\([\"'][^\"']*\\s*[\\+%]|cursor\\.(execute|executemany)\\([^,]+\\+\\s*[a-zA-Z_][a-zA-Z0-9_]*"24 message: "Potential SQL injection vulnerability. Use parameterized queries with placeholders instead of string concatenation."2526 # Pattern 2: SQL Injection - String formatting in SQL queries27 - pattern: "cursor\\.(execute|executemany)\\([\"'][^\"']*%[^\"']*[\"']\\s*%\\s*|cursor\\.(execute|executemany)\\([\"'][^\"']*{[^\"']*}[\"']\\.format"28 message: "Potential SQL injection vulnerability. Use parameterized queries with placeholders instead of string formatting."2930 # Pattern 3: Command Injection - Shell command execution with user input31 - 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['\"]"32 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."3334 # Pattern 4: Command Injection - Shell=True in subprocess35 - pattern: "(subprocess\\.Popen|subprocess\\.call|subprocess\\.run|subprocess\\.check_output)\\([^)]*shell\\s*=\\s*True"36 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."3738 # Pattern 5: XSS - Unescaped template variables39 - pattern: "\\{\\{\\s*[^|]*\\s*\\}\\}|\\{\\%\\s*autoescape\\s+off\\s*\\%\\}"40 message: "Potential XSS vulnerability. Ensure all template variables are properly escaped. Avoid using 'autoescape off' in templates."4142 # Pattern 6: XSS - Unsafe HTML rendering in Flask/Django43 - pattern: "render_template\\([^)]*\\)|render\\([^)]*\\)|mark_safe\\([^)]*\\)|safe\\s*\\|"44 message: "Potential XSS vulnerability. Ensure all user-supplied data is properly escaped before rendering in templates."4546 # Pattern 7: Path Traversal - Unsafe file operations47 - pattern: "open\\([^)]*\\+|open\\([^)]*format\\(|open\\([^)]*f['\"]"48 message: "Potential path traversal vulnerability. Validate and sanitize file paths before opening files. Consider using os.path.abspath and os.path.normpath."4950 # Pattern 8: LDAP Injection - Unsafe LDAP queries51 - pattern: "ldap\\.search\\([^)]*\\+|ldap\\.search\\([^)]*format\\(|ldap\\.search\\([^)]*f['\"]"52 message: "Potential LDAP injection vulnerability. Use proper LDAP escaping for user-supplied input in LDAP queries."5354 # Pattern 9: NoSQL Injection - Unsafe MongoDB queries55 - pattern: "find\\(\\{[^}]*\\+|find\\(\\{[^}]*format\\(|find\\(\\{[^}]*f['\"]"56 message: "Potential NoSQL injection vulnerability. Use parameterized queries or proper escaping for MongoDB queries."5758 # Pattern 10: Template Injection - Unsafe template rendering59 - pattern: "Template\\([^)]*\\)\\.(render|substitute)\\(|eval\\([^)]*\\)|exec\\([^)]*\\)"60 message: "Potential template injection or code injection vulnerability. Avoid using eval() or exec() with user input, and ensure template variables are properly validated."6162 - type: suggest63 message: |64 **Python Injection Prevention Best Practices:**6566 1. **SQL Injection Prevention:**67 - Use parameterized queries (prepared statements) with placeholders:68```python69 # Safe SQL query with parameters70 cursor.execute("SELECT * FROM users WHERE username = %s AND password = %s", (username, password))7172 # Django ORM (safe by default)73 User.objects.filter(username=username, password=password)7475 # SQLAlchemy (safe by default)76 session.query(User).filter(User.username == username, User.password == password)77```78 - Use ORM frameworks when possible (Django ORM, SQLAlchemy)79 - Apply proper input validation and sanitization8081 2. **Command Injection Prevention:**82 - Never use shell=True with subprocess functions83 - Pass command arguments as a list, not a string:84```python85 # Safe command execution86 subprocess.run(["ls", "-l", user_dir], shell=False)87```88 - Use shlex.quote() if you must include user input in shell commands89 - Consider using safer alternatives like Python libraries instead of shell commands9091 3. **XSS Prevention:**92 - Use template auto-escaping (enabled by default in modern frameworks)93 - Explicitly escape user input before rendering:94```python95 # Django96 from django.utils.html import escape97 safe_data = escape(user_input)9899 # Flask/Jinja2100 from markupsafe import escape101 safe_data = escape(user_input)102```103 - Use Content-Security-Policy headers104 - Validate input against allowlists105106 4. **Path Traversal Prevention:**107 - Validate and sanitize file paths:108```python109 import os110 safe_path = os.path.normpath(os.path.join(safe_base_dir, user_filename))111 if not safe_path.startswith(safe_base_dir):112 raise ValueError("Invalid path")113```114 - Use os.path.abspath() and os.path.normpath()115 - Implement proper access controls116 - Consider using libraries like Werkzeug's secure_filename()117118 5. **NoSQL Injection Prevention:**119 - Use parameterized queries or query builders120 - Validate input against schemas121 - Apply proper type checking122```python123 # Safe MongoDB query124 collection.find({"username": username, "status": "active"})125```126127 6. **Template Injection Prevention:**128 - Avoid using eval() or exec() with user input129 - Use sandboxed template engines130 - Limit template functionality to what's necessary131 - Apply proper input validation132133 - type: validate134 conditions:135 # Check 1: Safe SQL queries136 - pattern: "cursor\\.(execute|executemany)\\([\"'][^\"']*[\"']\\s*,\\s*\\(|cursor\\.(execute|executemany)\\([\"'][^\"']*[\"']\\s*,\\s*\\[|Model\\.objects\\.filter\\(|session\\.query\\("137 message: "Using parameterized queries or ORM for database access."138139 # Check 2: Safe command execution140 - pattern: "(subprocess\\.Popen|subprocess\\.call|subprocess\\.run|subprocess\\.check_output)\\(\\[[^\\]]*\\]"141 message: "Using subprocess with arguments as a list (safe pattern)."142143 # Check 3: Proper input validation144 - pattern: "validate|sanitize|clean|escape|is_valid\\(|validators\\."145 message: "Implementing input validation or sanitization."146147 # Check 4: Safe file operations148 - pattern: "os\\.path\\.join|os\\.path\\.abspath|os\\.path\\.normpath|secure_filename"149 message: "Using safe file path handling techniques."150151metadata:152 priority: high153 version: 1.0154 tags:155 - security156 - python157 - injection158 - sql-injection159 - xss160 - command-injection161 - owasp162 - language:python163 - framework:django164 - framework:flask165 - framework:fastapi166 - category:security167 - subcategory:injection168 - standard:owasp-top10169 - risk:a03-injection170 references:171 - "https://owasp.org/Top10/A03_2021-Injection/"172 - "https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html"173 - "https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html"174 - "https://cheatsheetseries.owasp.org/cheatsheets/OS_Command_Injection_Defense_Cheat_Sheet.html"175 - "https://docs.python.org/3/library/subprocess.html"176 - "https://docs.djangoproject.com/en/stable/topics/security/"177 - "https://flask.palletsprojects.com/en/latest/security/"178</rule>
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| ivangrynenko/cursorrules.cursor/rules/cursor-rules.mdc · 86 | Cursor rules | teststylearchgit+2 | 77/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/behat-steps.mdc · 86 | Cursor rules | lint-formatstyleperformanceagent-behaviour | 42/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/php-drupal-development-standards.mdc · 86 | Cursor rules | no sections | 34/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/python-insecure-design.mdc · 86 | Cursor rules | no sections | 40/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/python-cryptographic-failures.mdc · 86 | Cursor rules | security | 40/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/node-dependencies.mdc · 86 | Cursor rules | no sections | 16/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/behat-ai-guide.mdc · 86 | Cursor rules | testtesting-strategydo-not | 45/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/new-pull-request.mdc · 86 | Cursor rules | archtesting-strategygitsecurity+3 | 58/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/accessibility-standards.mdc · 86 | Cursor rules | ui | 44/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/api-standards.mdc · 86 | Cursor rules | api | 44/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/build-optimization.mdc · 86 | Cursor rules | build | 48/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/code-generation-standards.mdc · 86 | Cursor rules | lint-formatstyletypesdocs | 52/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/confluence-editing-standards.mdc · 86 | Cursor rules | stylearchsecuritydeployment | 60/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/debugging-standards.mdc · 86 | Cursor rules | no sections | 30/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/docker-compose-standards.mdc · 86 | Cursor rules | style | 62/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-authentication-failures.mdc · 86 | Cursor rules | security | 48/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-broken-access-control.mdc · 86 | Cursor rules | stylesecurity | 52/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-cryptographic-failures.mdc · 86 | Cursor rules | security | 48/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-database-standards.mdc · 86 | Cursor rules | database | 30/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-file-permissions.mdc · 86 | Cursor rules | stylearchsecurity | 62/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 14 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 14 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 14 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 14 days ago | |
| skillrecordings/egghead-next.cursor/rules/gh-task-plan.mdc · 1.4k | Cursor rules | teststylearchtypes+2 | 96/100 | 14 days ago | |
| skillrecordings/egghead-next.cursor/rules/project-update-rules.mdc · 1.4k | Cursor rules | buildtestlint-formatstyle+7 | 96/100 | 14 days ago | |
| skillrecordings/egghead-next.cursor/rules/project-update-user-rules.mdc · 1.4k | Cursor rules | buildtestlint-formatstyle+7 | 96/100 | 14 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/proto.mdc · 126 | Cursor rules | buildlint-formatstylearch+3 | 96/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/ivangrynenko-cursorrules-cursor-rules-python-injection)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.
Directory