

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
123456 # Python Security Misconfiguration Standards (OWASP A05:2021)78This rule enforces security best practices to prevent security misconfigurations in Python applications, as defined in OWASP Top 10:2021-A05.910<rule>11name: python_security_misconfiguration12description: Detect and prevent security misconfigurations in Python applications as defined in OWASP Top 10:2021-A0513filters:14 - type: file_extension15 pattern: "\\.(py|ini|cfg|yml|yaml|json|toml)$"16 - type: file_path17 pattern: ".*"1819actions:20 - type: enforce21 conditions:22 # Pattern 1: Debug mode enabled in production settings23 - pattern: "DEBUG\\s*=\\s*True|debug\\s*=\\s*true|\"debug\"\\s*:\\s*true|debug:\\s*true"24 message: "Debug mode appears to be enabled. This should be disabled in production environments as it can expose sensitive information."2526 # Pattern 2: Insecure cookie settings27 - pattern: "SESSION_COOKIE_SECURE\\s*=\\s*False|session_cookie_secure\\s*=\\s*false|\"session_cookie_secure\"\\s*:\\s*false|session_cookie_secure:\\s*false"28 message: "Insecure cookie configuration detected. Set SESSION_COOKIE_SECURE to True in production environments."2930 # Pattern 3: Missing CSRF protection31 - pattern: "CSRF_ENABLED\\s*=\\s*False|csrf_enabled\\s*=\\s*false|\"csrf_enabled\"\\s*:\\s*false|csrf_enabled:\\s*false|WTF_CSRF_ENABLED\\s*=\\s*False"32 message: "CSRF protection appears to be disabled. Enable CSRF protection to prevent cross-site request forgery attacks."3334 # Pattern 4: Insecure CORS settings35 - pattern: "CORS_ORIGIN_ALLOW_ALL\\s*=\\s*True|cors_origin_allow_all\\s*=\\s*true|\"cors_origin_allow_all\"\\s*:\\s*true|cors_origin_allow_all:\\s*true|Access-Control-Allow-Origin:\\s*\\*"36 message: "Overly permissive CORS configuration detected. Restrict CORS to specific origins rather than allowing all origins."3738 # Pattern 5: Default or weak secret keys39 - pattern: "SECRET_KEY\\s*=\\s*['\"]default|SECRET_KEY\\s*=\\s*['\"][a-zA-Z0-9]{1,32}['\"]|secret_key\\s*=\\s*['\"]default|\"secret_key\"\\s*:\\s*\"default|secret_key:\\s*default"40 message: "Default or potentially weak secret key detected. Use a strong, randomly generated secret key and store it securely."4142 # Pattern 6: Exposed sensitive information in error messages43 - pattern: "DEBUG_PROPAGATE_EXCEPTIONS\\s*=\\s*True|debug_propagate_exceptions\\s*=\\s*true|\"debug_propagate_exceptions\"\\s*:\\s*true|debug_propagate_exceptions:\\s*true"44 message: "Exception propagation in debug mode is enabled. This can expose sensitive information in error messages."4546 # Pattern 7: Insecure SSL/TLS configuration47 - pattern: "SECURE_SSL_REDIRECT\\s*=\\s*False|secure_ssl_redirect\\s*=\\s*false|\"secure_ssl_redirect\"\\s*:\\s*false|secure_ssl_redirect:\\s*false"48 message: "SSL redirection appears to be disabled. Enable SSL redirection to ensure secure communications."4950 # Pattern 8: Missing security headers51 - pattern: "SECURE_HSTS_SECONDS\\s*=\\s*0|secure_hsts_seconds\\s*=\\s*0|\"secure_hsts_seconds\"\\s*:\\s*0|secure_hsts_seconds:\\s*0"52 message: "HTTP Strict Transport Security (HSTS) appears to be disabled. Enable HSTS to enforce secure communications."5354 # Pattern 9: Exposed sensitive directories55 - pattern: "@app\\.route\\(['\"]/(admin|console|management|config|settings|system)['\"]"56 message: "Potentially sensitive endpoint exposed without access controls. Ensure proper authentication and authorization for administrative endpoints."5758 # Pattern 10: Default accounts or credentials59 - pattern: "username\\s*=\\s*['\"]admin['\"]|password\\s*=\\s*['\"]admin|password\\s*=\\s*['\"]password|password\\s*=\\s*['\"]123|user\\s*=\\s*['\"]root['\"]"60 message: "Default or weak credentials detected. Never use default or easily guessable credentials in any environment."6162 # Pattern 11: Insecure file permissions63 - pattern: "os\\.chmod\\([^,]+,\\s*0o777\\)|os\\.chmod\\([^,]+,\\s*777\\)"64 message: "Overly permissive file permissions detected. Use the principle of least privilege for file permissions."6566 # Pattern 12: Exposed version information67 - pattern: "@app\\.route\\(['\"]/(version|build|status|health)['\"]"68 message: "Endpoints that may expose version information detected. Ensure these endpoints don't reveal sensitive details about your application."6970 # Pattern 13: Insecure deserialization71 - pattern: "pickle\\.loads|yaml\\.load\\([^,)]+\\)|json\\.loads\\([^,)]+,\\s*[^)]*object_hook"72 message: "Potentially insecure deserialization detected. Use safer alternatives like yaml.safe_load() or validate input before deserialization."7374 # Pattern 14: Missing timeout settings75 - pattern: "requests\\.get\\([^,)]+\\)|requests\\.(post|put|delete|patch)\\([^,)]+\\)"76 message: "HTTP request without timeout setting detected. Always set timeouts for HTTP requests to prevent denial of service."7778 # Pattern 15: Insecure upload directory79 - pattern: "UPLOAD_FOLDER\\s*=\\s*['\"][^'\"]*(/tmp|/var/tmp)[^'\"]*['\"]|upload_folder\\s*=\\s*['\"][^'\"]*(/tmp|/var/tmp)[^'\"]*['\"]"80 message: "Insecure upload directory detected. Use a properly secured directory for file uploads, not temporary directories."8182 - type: suggest83 message: |84 **Python Security Configuration Best Practices:**8586 1. **Environment-Specific Configuration:**87 - Use different configurations for development, testing, and production88 - Never enable debug mode in production89 - Example with environment variables:90```python91 import os9293 DEBUG = os.environ.get('DEBUG', 'False') == 'True'94 SECRET_KEY = os.environ.get('SECRET_KEY')95```9697 2. **Secure Cookie Configuration:**98 - Enable secure cookies in production99 - Set appropriate cookie flags100 - Example for Django:101```python102 SESSION_COOKIE_SECURE = True103 SESSION_COOKIE_HTTPONLY = True104 SESSION_COOKIE_SAMESITE = 'Lax'105 CSRF_COOKIE_SECURE = True106 CSRF_COOKIE_HTTPONLY = True107```108 - Example for Flask:109```python110 app.config.update(111 SESSION_COOKIE_SECURE=True,112 SESSION_COOKIE_HTTPONLY=True,113 SESSION_COOKIE_SAMESITE='Lax',114 PERMANENT_SESSION_LIFETIME=timedelta(hours=1)115 )116```117118 3. **Security Headers:**119 - Implement HTTP security headers120 - Example with Flask-Talisman:121```python122 from flask_talisman import Talisman123124 talisman = Talisman(125 app,126 content_security_policy={127 'default-src': "'self'",128 'script-src': "'self'"129 },130 strict_transport_security=True,131 strict_transport_security_max_age=31536000,132 frame_options='DENY'133 )134```135 - Example for Django:136```python137 SECURE_HSTS_SECONDS = 31536000138 SECURE_HSTS_INCLUDE_SUBDOMAINS = True139 SECURE_HSTS_PRELOAD = True140 SECURE_CONTENT_TYPE_NOSNIFF = True141 SECURE_BROWSER_XSS_FILTER = True142 X_FRAME_OPTIONS = 'DENY'143```144145 4. **CORS Configuration:**146 - Restrict CORS to specific origins147 - Example with Flask-CORS:148```python149 from flask_cors import CORS150151 CORS(app, resources={r"/api/*": {"origins": "https://example.com"}})152```153 - Example for Django:154```python155 CORS_ALLOWED_ORIGINS = [156 "https://example.com",157 "https://sub.example.com",158 ]159 CORS_ALLOW_CREDENTIALS = True160```161162 5. **Secret Management:**163 - Use environment variables or secure vaults for secrets164 - Generate strong random secrets165 - Example:166```python167 import secrets168169 # Generate a secure random secret key170 secret_key = secrets.token_hex(32)171```172173 6. **Error Handling:**174 - Use custom error handlers to prevent information leakage175 - Example for Flask:176```python177 @app.errorhandler(Exception)178 def handle_exception(e):179 # Log the error180 app.logger.error(f"Unhandled exception: {str(e)}")181 # Return a generic error message182 return jsonify({"error": "An unexpected error occurred"}), 500183```184185 7. **Secure File Uploads:**186 - Validate file types and sizes187 - Store uploaded files outside the web root188 - Use secure permissions189 - Example:190```python191 import os192 from werkzeug.utils import secure_filename193194 UPLOAD_FOLDER = '/path/to/secure/location'195 ALLOWED_EXTENSIONS = {'txt', 'pdf', 'png', 'jpg'}196197 app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER198 app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB limit199200 def allowed_file(filename):201 return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS202```203204 8. **Dependency Management:**205 - Regularly update dependencies206 - Use tools like safety or dependabot207 - Pin dependency versions208 - Example requirements.txt:209```210 Flask==2.0.1211 Werkzeug==2.0.1212```213214 9. **Timeout Configuration:**215 - Set timeouts for all external service calls216 - Example:217```python218 import requests219220 response = requests.get('https://api.example.com', timeout=(3.05, 27))221```222223 10. **Secure Deserialization:**224 - Use safe alternatives for deserialization225 - Validate input before deserialization226 - Example:227```python228 import yaml229230 # Use safe_load instead of load231 data = yaml.safe_load(yaml_string)232```233234 - type: validate235 conditions:236 # Check 1: Proper debug configuration237 - pattern: "DEBUG\\s*=\\s*os\\.environ\\.get\\(['\"]DEBUG['\"]|DEBUG\\s*=\\s*False"238 message: "Using environment-specific or secure debug configuration."239240 # Check 2: Secure cookie settings241 - pattern: "SESSION_COOKIE_SECURE\\s*=\\s*True|session_cookie_secure\\s*=\\s*true"242 message: "Using secure cookie configuration."243244 # Check 3: Security headers implementation245 - pattern: "SECURE_HSTS_SECONDS|X_FRAME_OPTIONS|Talisman\\(|CSP|Content-Security-Policy"246 message: "Implementing security headers."247248 # Check 4: Proper CORS configuration249 - pattern: "CORS_ALLOWED_ORIGINS|CORS\\(app,\\s*resources"250 message: "Using restricted CORS configuration."251252metadata:253 priority: high254 version: 1.0255 tags:256 - security257 - python258 - configuration259 - deployment260 - owasp261 - language:python262 - framework:django263 - framework:flask264 - framework:fastapi265 - category:security266 - subcategory:configuration267 - standard:owasp-top10268 - risk:a05-security-misconfiguration269 references:270 - "https://owasp.org/Top10/A05_2021-Security_Misconfiguration/"271 - "https://cheatsheetseries.owasp.org/cheatsheets/Configuration_Security_Cheat_Sheet.html"272 - "https://flask.palletsprojects.com/en/latest/security/"273 - "https://docs.djangoproject.com/en/stable/topics/security/"274 - "https://fastapi.tiangolo.com/advanced/security/https/"275 - "https://owasp.org/www-project-secure-headers/"276</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/python-injection.mdc · 86 | Cursor rules | styledo-not | 51/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 |
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-security-misconfiguration)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