python-cryptographic-failures

python-cryptographic-failures is a cursor rule for Cursor from abderrahimghazali/cursor-rules. It costs 0 tokens per session (2,054 once invoked), scanned A, a copy of python-cryptographic-failures, MIT.

A set of Python security checks based on the OWASP Top 10, a list of common application-security risks. It looks for weak hashing, hardcoded secrets, unsafe random-number use, and weak SSL/TLS settings.

In plain words
What is it for?
Use it when reviewing Python code that hashes data, stores credentials, generates security-sensitive values, or configures encrypted network connections.
Why use it?
It helps identify cryptography choices that can expose passwords, secrets, connections, or other protected data. The checks point developers toward safer Python security tools and settings.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when reviewing Python code that hashes data, stores credentials, generates security-sensitive values, or configures encrypted network connections.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/abderrahimghazali/cursor-rules/python-cryptographic-failures
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.

Clone the repo
git clone --depth 1 https://github.com/abderrahimghazali/cursor-rules

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/abderrahimghazali/cursor-rules/python-cryptographic-failures/github.svg)](https://agentmods.dev/rules/abderrahimghazali/cursor-rules/python-cryptographic-failures)
Your own site
<a href="https://agentmods.dev/rules/abderrahimghazali/cursor-rules/python-cryptographic-failures"><img src="https://agentmods.dev/badge/rules/abderrahimghazali/cursor-rules/python-cryptographic-failures/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.

agentmods 80×15 button for python-cryptographic-failures

Your own site · 80×15
<a href="https://agentmods.dev/rules/abderrahimghazali/cursor-rules/python-cryptographic-failures"><img src="https://agentmods.dev/badge/rules/abderrahimghazali/cursor-rules/python-cryptographic-failures.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,054 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin 100% copy Near-identical to another mod 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.1 $0.00000 $0.02054
Opus 5.5 $0.00000 $0.00822
Sonnet 5.5 $0.00000 $0.00411
Haiku 4.5 $0.00000 $0.00205

Measured 1mo ago against content hash 9782dd4b1873, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 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.

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)
Origin

This is a copy

100% identical to python-cryptographic-failures — 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.

.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. 1mo ago 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 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,054 tokens. A static security scan graded it A with 1 finding (makes network calls). It is 100% identical to python-cryptographic-failures, differing in 0 lines, and is treated as a copy.