python-cryptographic-failures

python-cryptographic-failures is a cursor rule for Cursor from ivangrynenko/cursorrules. It costs 2,054 tokens per session, scanned A, original, MIT.

Detect and prevent cryptographic failures in Python applications as defined in OWASP Top 10:2021-A02.

Cursor rule for Cursor

Install

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.

agentmods
npx agentmods add rules/ivangrynenko/cursorrules/python-cryptographic-failures
Clone the repo
git clone --depth 1 https://github.com/ivangrynenko/cursorrules

Made for: Cursor.

Wrote 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.

agentmods badge for python-cryptographic-failures

README.md
[![agentmods](https://agentmods.dev/badge/rules/ivangrynenko/cursorrules/python-cryptographic-failures.svg)](https://agentmods.dev/rules/ivangrynenko/cursorrules/python-cryptographic-failures)
Your own site
<a href="https://agentmods.dev/rules/ivangrynenko/cursorrules/python-cryptographic-failures"><img src="https://agentmods.dev/badge/rules/ivangrynenko/cursorrules/python-cryptographic-failures.svg" alt="Measured on agentmods" height="20"></a>
Per session 2,054 This file is loaded in full into every session.
When invoked 2,054 The same file — it is already loaded in full.
Security scan A 1 finding. Scan, not verified.
Origin unknown No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.02054 $0.02054
Opus 5 $0.01027 $0.01027
Sonnet 5 $0.00411 $0.00411
Haiku 4.5 $0.00205 $0.00205

Measured today against content hash 9782dd4b1873, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

python-cryptographic-failures 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 today.

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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

response = requests.get('https://example.com', verify=True)
.cursor/rules/python-cryptographic-failures.mdc · 193 lines

How it starts

The opening of the file, as written. The whole thing — 193 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Python Cryptographic Failures Security Standards (OWASP A02:2021)

This rule enforces security best practices to prevent cryptographic failures in Python applications, as defined in OWASP Top 10:2021-A02.

actions:

  • type: enforce conditions:

    Pattern 1: Weak or insecure cryptographic algorithms

    • pattern: "import\s+(md5|sha1)|hashlib\.(md5|sha1)\(|Crypto\.Hash\.(MD5|SHA1)|cryptography\.hazmat\.primitives\.hashes\.(MD5|SHA1)" message: "Using weak hashing algorithms (MD5/SHA1). Use SHA-256 or stronger algorithms from the hashlib or cryptography packages."

    Pattern 2: Hardcoded secrets/credentials

    • pattern: "(password|secret|key|token|auth)\s*=\s*['"][^'"]+['"]" message: "Potential hardcoded credentials detected. Store secrets in environment variables or a secure vault."

    Pattern 3: Insecure random number generation

    • pattern: "random\.(random|randint|choice|sample)|import random" message: "Using Python's standard random module for security purposes. Use secrets module or cryptography.hazmat.primitives.asymmetric for cryptographic operations."

    Pattern 4: Weak SSL/TLS configuration

    • pattern: "ssl\.PROTOCOL_(SSLv2|SSLv3|TLSv1|TLSv1_1)|SSLContext\(\s*ssl\.PROTOCOL_(SSLv2|SSLv3|TLSv1|TLSv1_1)\)" message: "Using deprecated/insecure SSL/TLS protocol versions. Use TLS 1.2+ (ssl.PROTOCOL_TLS_CLIENT with minimum version set)."

    Pattern 5: Missing certificate validation

    • pattern: "verify\s*=\sFalse|check_hostname\s=\s*False|CERT_NONE" message: "SSL certificate validation is disabled. Always validate certificates in production environments."

    Pattern 6: Insecure cipher usage

    • pattern: "DES|RC4|Blowfish|ECB" message: "Using insecure encryption cipher or mode. Use AES with GCM or CBC mode with proper padding."

    Pattern 7: Insufficient key length

    • 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])" message: "Using insufficient key length for asymmetric encryption. RSA keys should be at least 2048 bits, preferably 4096 bits."

    Pattern 8: Insecure password hashing

    • pattern: "\.encode\(['"]utf-?8['"]\)\.(digest|hexdigest)\(\)|hashlib\.[a-zA-Z0-9]+\([^)]*\)\.(digest|hexdigest)\(\)" message: "Using plain hashing for passwords. Use dedicated password hashing functions like bcrypt, Argon2, or PBKDF2."

    Pattern 9: Missing salt in password hashing

    • pattern: "pbkdf2_hmac\([^,]+,[^,]+,[^,]+,\s*[0-9]+\s*\)" message: "Ensure you're using a proper random salt with password hashing functions."
    • pattern: "set_cookie\([^)]secure\s=\sFalse|set_cookie\([^)]httponly\s=\sFalse" message: "Cookies with sensitive data should have secure and httponly flags enabled."
  • type: suggest message: | Python Cryptography Best Practices:

    1. Secure Password Storage:

      • Use dedicated password hashing algorithms:
        import bcrypt
        hashed = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt(rounds=12))
        
      • Or use Argon2 (preferred) or PBKDF2 with sufficient iterations:
        from argon2 import PasswordHasher
        ph = PasswordHasher()
        hash = ph.hash(password)
        
    2. Secure Random Number Generation:

      • Use the secrets module for cryptographic operations:
        import secrets
        token = secrets.token_hex(32)  # 256 bits of randomness
        
      • For cryptographic keys, use proper key generation functions:
        from cryptography.hazmat.primitives.asymmetric import rsa
        private_key = rsa.generate_private_key(public_exponent=65537, key_size=4096)
        

Read the full file on GitHub · 193 lines

Changes

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.

  1. today First seen · 193 lines · 2,054 tokens per session scan A 9782dd4b1873

Subscribe to this mod's changes

python-cryptographic-failures is a cursor rule published in the GitHub repository ivangrynenko/cursorrules (88 stars, last pushed 10mo ago), licensed MIT. It adds 2,054 tokens to every session, about $0.0103 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.