

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
123456# Python Cryptographic Failures Security Standards (OWASP A02:2021)78This rule enforces security best practices to prevent cryptographic failures in Python applications, as defined in OWASP Top 10:2021-A02.910<rule>11name: python_cryptographic_failures12description: Detect and prevent cryptographic failures in Python applications as defined in OWASP Top 10:2021-A0213filters:14 - type: file_extension15 pattern: "\\.(py)$"16 - type: file_path17 pattern: ".*"1819actions:20 - type: enforce21 conditions:22 # Pattern 1: Weak or insecure cryptographic algorithms23 - pattern: "import\\s+(md5|sha1)|hashlib\\.(md5|sha1)\\(|Crypto\\.Hash\\.(MD5|SHA1)|cryptography\\.hazmat\\.primitives\\.hashes\\.(MD5|SHA1)"24 message: "Using weak hashing algorithms (MD5/SHA1). Use SHA-256 or stronger algorithms from the hashlib or cryptography packages."2526 # Pattern 2: Hardcoded secrets/credentials27 - pattern: "(password|secret|key|token|auth)\\s*=\\s*['\"][^'\"]+['\"]"28 message: "Potential hardcoded credentials detected. Store secrets in environment variables or a secure vault."2930 # Pattern 3: Insecure random number generation31 - pattern: "random\\.(random|randint|choice|sample)|import random"32 message: "Using Python's standard random module for security purposes. Use secrets module or cryptography.hazmat.primitives.asymmetric for cryptographic operations."3334 # Pattern 4: Weak SSL/TLS configuration35 - pattern: "ssl\\.PROTOCOL_(SSLv2|SSLv3|TLSv1|TLSv1_1)|SSLContext\\(\\s*ssl\\.PROTOCOL_(SSLv2|SSLv3|TLSv1|TLSv1_1)\\)"36 message: "Using deprecated/insecure SSL/TLS protocol versions. Use TLS 1.2+ (ssl.PROTOCOL_TLS_CLIENT with minimum version set)."3738 # Pattern 5: Missing certificate validation39 - pattern: "verify\\s*=\\s*False|check_hostname\\s*=\\s*False|CERT_NONE"40 message: "SSL certificate validation is disabled. Always validate certificates in production environments."4142 # Pattern 6: Insecure cipher usage43 - pattern: "DES|RC4|Blowfish|ECB"44 message: "Using insecure encryption cipher or mode. Use AES with GCM or CBC mode with proper padding."4546 # Pattern 7: Insufficient key length47 - pattern: "RSA\\([^,]+,\\s*[0-9]+\\s*\\)|key_size\\s*=\\s*([0-9]|10[0-9][0-9]|11[0-9][0-9]|12[0-4][0-9])"48 message: "Using insufficient key length for asymmetric encryption. RSA keys should be at least 2048 bits, preferably 4096 bits."4950 # Pattern 8: Insecure password hashing51 - pattern: "\\.encode\\(['\"]utf-?8['\"]\\)\\.(digest|hexdigest)\\(\\)|hashlib\\.[a-zA-Z0-9]+\\([^)]*\\)\\.(digest|hexdigest)\\(\\)"52 message: "Using plain hashing for passwords. Use dedicated password hashing functions like bcrypt, Argon2, or PBKDF2."5354 # Pattern 9: Missing salt in password hashing55 - pattern: "pbkdf2_hmac\\([^,]+,[^,]+,[^,]+,\\s*[0-9]+\\s*\\)"56 message: "Ensure you're using a proper random salt with password hashing functions."5758 # Pattern 10: Insecure cookie settings59 - pattern: "set_cookie\\([^)]*secure\\s*=\\s*False|set_cookie\\([^)]*httponly\\s*=\\s*False"60 message: "Cookies with sensitive data should have secure and httponly flags enabled."6162 - type: suggest63 message: |64 **Python Cryptography Best Practices:**6566 1. **Secure Password Storage:**67 - Use dedicated password hashing algorithms:68```python69 import bcrypt70 hashed = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt(rounds=12))71```72 - Or use Argon2 (preferred) or PBKDF2 with sufficient iterations:73```python74 from argon2 import PasswordHasher75 ph = PasswordHasher()76 hash = ph.hash(password)77```7879 2. **Secure Random Number Generation:**80 - Use the `secrets` module for cryptographic operations:81```python82 import secrets83 token = secrets.token_hex(32) # 256 bits of randomness84```85 - For cryptographic keys, use proper key generation functions:86```python87 from cryptography.hazmat.primitives.asymmetric import rsa88 private_key = rsa.generate_private_key(public_exponent=65537, key_size=4096)89```9091 3. **Secure Communications:**92 - Use TLS 1.2+ for all communications:93```python94 import ssl95 context = ssl.create_default_context()96 context.minimum_version = ssl.TLSVersion.TLSv1_297```98 - Always validate certificates:99```python100 import requests101 response = requests.get('https://example.com', verify=True)102```103104 4. **Proper Key Management:**105 - Never hardcode secrets in source code106 - Use environment variables or secure vaults:107```python108 import os109 api_key = os.environ.get('API_KEY')110```111 - Consider using dedicated key management services112113 5. **Secure Encryption:**114 - Use high-level libraries like `cryptography`:115```python116 from cryptography.fernet import Fernet117 key = Fernet.generate_key()118 f = Fernet(key)119 encrypted = f.encrypt(data)120```121 - For lower-level needs, use authenticated encryption (AES-GCM):122```python123 from cryptography.hazmat.primitives.ciphers.aead import AESGCM124 key = AESGCM.generate_key(bit_length=256)125 aesgcm = AESGCM(key)126 nonce = os.urandom(12)127 encrypted = aesgcm.encrypt(nonce, data, associated_data)128```129130 6. **Secure Cookie Handling:**131 - Set secure and httponly flags:132```python133 # Flask example134 response.set_cookie('session', session_id, httponly=True, secure=True, samesite='Lax')135```136 - Use signed cookies or tokens:137```python138 # Django example - uses signed cookies by default139 request.session['user_id'] = user.id140```141142 7. **Input Validation:**143 - Validate all cryptographic inputs144 - Use constant-time comparison for secrets:145```python146 import hmac147 def constant_time_compare(a, b):148 return hmac.compare_digest(a, b)149```150151 - type: validate152 conditions:153 # Check 1: Proper password hashing154 - pattern: "bcrypt\\.hashpw|argon2|PasswordHasher|pbkdf2_hmac\\([^,]+,[^,]+,[^,]+,\\s*[0-9]{4,}\\s*\\)"155 message: "Using secure password hashing algorithm."156157 # Check 2: Secure random generation158 - pattern: "secrets\\.|urandom|cryptography\\.hazmat\\.primitives\\.asymmetric"159 message: "Using cryptographically secure random number generation."160161 # Check 3: Strong TLS configuration162 - pattern: "ssl\\.PROTOCOL_TLS|minimum_version\\s*=\\s*ssl\\.TLSVersion\\.TLSv1_2|create_default_context"163 message: "Using secure TLS configuration."164165 # Check 4: Proper certificate validation166 - pattern: "verify\\s*=\\s*True|check_hostname\\s*=\\s*True|CERT_REQUIRED"167 message: "Properly validating SSL certificates."168169metadata:170 priority: high171 version: 1.0172 tags:173 - security174 - python175 - cryptography176 - encryption177 - owasp178 - language:python179 - framework:django180 - framework:flask181 - framework:fastapi182 - category:security183 - subcategory:cryptography184 - standard:owasp-top10185 - risk:a02-cryptographic-failures186 references:187 - "https://owasp.org/Top10/A02_2021-Cryptographic_Failures/"188 - "https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html"189 - "https://docs.python.org/3/library/secrets.html"190 - "https://cryptography.io/en/latest/"191 - "https://pypi.org/project/bcrypt/"192 - "https://pypi.org/project/argon2-cffi/"193</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-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 | |
| 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-cryptographic-failures)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