|
| 1 | +# Cryptographic Weakness Vulnerability Hunt Guide |
| 2 | + |
| 3 | +## Dangerous API Patterns by Language |
| 4 | + |
| 5 | +### C/C++ |
| 6 | +- **Random Number Generation**: `rand()`, `srand(time(NULL))` for security purposes |
| 7 | +- **Hash Functions**: `MD5()`, `SHA1()` for password hashing, integrity verification |
| 8 | +- **Encryption**: `EVP_CIPHER_CTX_init()` with DES, RC4, CBC mode without HMAC |
| 9 | +- **Key Management**: Hardcoded encryption keys, keys in source code |
| 10 | +- **Memory**: Storing plaintext keys in memory, insufficient key clearing |
| 11 | + |
| 12 | +### Python |
| 13 | +- **Random**: `random.random()`, `random.randint()` for tokens/secrets |
| 14 | +- **Hash**: `hashlib.md5()`, `hashlib.sha1()` for passwords |
| 15 | +- **Encryption**: `Crypto.Cipher.DES`, `Crypto.Cipher.ARC4` |
| 16 | +- **Key Derivation**: `hashlib.md5(password)` instead of `bcrypt`/`argon2` |
| 17 | +- **Hardcoded Keys**: `SECRET_KEY = "abc123"`, `API_KEY = "..."` |
| 18 | + |
| 19 | +### Java |
| 20 | +- **Random**: `java.util.Random` for security tokens |
| 21 | +- **Hash**: `MessageDigest.getInstance("MD5")`, `SHA-1` |
| 22 | +- **Encryption**: `Cipher.getInstance("DES/ECB/PKCS5Padding")`, `RC4` |
| 23 | +- **KeyStore**: Hardcoded keystore passwords, weak key storage |
| 24 | +- **SSL**: `TrustAllManager`, `hostnameVerifier = (a, b) -> true` |
| 25 | + |
| 26 | +### Go |
| 27 | +- **Random**: `math/rand` instead of `crypto/rand` |
| 28 | +- **Hash**: `crypto/md5`, `crypto/sha1` for security purposes |
| 29 | +- **Encryption**: `cipher.NewRC4()`, ECB mode usage |
| 30 | +- **Key Derivation**: `md5.Sum(password)` instead of `bcrypt` |
| 31 | +- **TLS**: `tls.Config{InsecureSkipVerify: true}` |
| 32 | + |
| 33 | +### JavaScript/Node.js |
| 34 | +- **Random**: `Math.random()` for tokens/secrets |
| 35 | +- **Hash**: `crypto.createHash('md5')`, `createHash('sha1')` |
| 36 | +- **Encryption**: `crypto.createCipher('des-ecb', key)` |
| 37 | +- **JWT**: Weak algorithms, missing signature verification |
| 38 | +- **Hardcoded Secrets**: `process.env.SECRET = "abc123"` in code |
| 39 | + |
| 40 | +## Known False-Positive Signatures |
| 41 | + |
| 42 | +### Safe Patterns (DO NOT REPORT) |
| 43 | +- **Cryptographically Secure RNG**: `secrets.token_hex()`, `crypto.getRandomValues()`, `crypto/rand` |
| 44 | +- **Modern Hashing**: `bcrypt`, `argon2`, `scrypt`, `PBKDF2` for passwords |
| 45 | +- **Strong Encryption**: `AES-GCM`, `AES-256-CBC` with HMAC, `ChaCha20-Poly1305` |
| 46 | +- **Key Derivation**: `bcrypt.gensalt()`, `argon2.hash()`, `pbkdf2_derive()` |
| 47 | +- **Proper TLS**: Valid certificate verification, strong cipher suites |
| 48 | + |
| 49 | +## Bypass Detection Patterns |
| 50 | + |
| 51 | +### Weak Crypto Exploitation |
| 52 | +- **Hash Collisions**: MD5 collision attacks for certificate forgery |
| 53 | +- **Rainbow Tables**: Unsalted hashes vulnerable to precomputation |
| 54 | +- **Timing Attacks**: Non-constant-time string comparison for tokens |
| 55 | +- **Padding Oracle**: CBC padding oracle attacks |
| 56 | +- **Key Recovery**: Brute-force weak keys, default credentials |
| 57 | + |
| 58 | +### Implementation Flaws |
| 59 | +- **ECB Mode**: Patterns visible in encrypted data |
| 60 | +- **IV Reuse**: Same IV used multiple times with same key |
| 61 | +- **Short Keys**: Keys shorter than 128 bits |
| 62 | +- **Predictable Nonces**: Nonce reuse in stream ciphers |
| 63 | + |
| 64 | +## Chain Opportunities |
| 65 | + |
| 66 | +### Crypto Vulnerabilities Enable |
| 67 | +- **Credential Theft**: Cracking weak password hashes |
| 68 | +- **Session Hijacking**: Predicting session tokens from weak RNG |
| 69 | +- **Data Decryption**: Breaking weak encryption schemes |
| 70 | +- **Certificate Forgery**: MD5 collision for fake certificates |
| 71 | +- **Authentication Bypass**: Timing attacks on token comparison |
| 72 | + |
| 73 | +### Priority Indicators |
| 74 | +- **Critical**: Hardcoded encryption keys, weak RNG for tokens/passwords |
| 75 | +- **High**: MD5/SHA1 for passwords, ECB mode encryption, InsecureSkipVerify |
| 76 | +- **Medium**: Missing rate limiting on auth, weak password policies |
| 77 | +- **Low**: Outdated TLS versions (1.0/1.1), missing HSTS headers |
0 commit comments