Almost every "crypto error" that shows up in a scan report or a code review is not a broken algorithm. AES is not broken. SHA-256 is not broken. The failures are in how they are used: the wrong mode, a reused nonce, a key committed to a repository, or a password hashed with something designed to be fast. Here are the ones that keep appearing, and how to spot each.
1. Deterministic encryption (ECB mode)
ECB encrypts each block independently, so identical plaintext blocks produce identical ciphertext blocks. Encrypt a bitmap and you can see the image. Encrypt a database column and you can tell which users share a value without decrypting anything.
# Spotting it in code
grep -rn "AES/ECB\|AES.MODE_ECB\|Cipher.getInstance(\"AES\")" .
# Java's "AES" default is ECB - the classic mistake
Use an authenticated mode instead: AES-GCM or ChaCha20-Poly1305 where available, AES-CBC with a MAC as a fallback. ECB has almost no legitimate use.
2. Static or reused IV / nonce
GCM and CBC both need a value that is unique per message. Hardcode it, or reset it per process restart, and you get the same problem as ECB plus, in GCM's case, a catastrophic one: reusing a nonce with the same key can expose the authentication key itself.
# A constant IV is a red flag
grep -rn "IvParameterSpec(new byte\|iv = b\"0\|nonce = \"fixed" .
The IV is not secret, but it must be random (or a counter) and it must be stored with the ciphertext.
3. Fast hashes used for passwords
MD5, SHA-1 and plain SHA-256 are built to be fast. A modern GPU tries billions of candidates per second, so a fast hash gives an attacker a free multiplier. Passwords need a deliberately slow, memory-hard function: Argon2id, scrypt or bcrypt.
# Password field hashed with SHA-256 - wrong primitive
grep -rn "sha256(password\|md5(password\|hexdigest()" .
4. Keys committed to the repository
A key in source control is public the moment the repository is shared, and it stays in the history after deletion. Rotating the key is the only fix; removing the line is not.
# What to look for
grep -rn "BEGIN.*PRIVATE KEY\|api[_-]key\s*=\s*\"\|secret\s*=\s*\"" --include=*.{py,js,ts,java,go,rb}
Secrets belong in a managed store or an environment variable injected at runtime, and the repository should be scanned on every commit.
5. Encoding mistaken for encryption
Base64 is a transport encoding with no key. It is reversible by anyone, instantly. The same mistake appears as hex encoding, "obfuscation" by ROT13, or XOR with a constant byte.
If a database column called password or api_token contains something ending in = or matching a base64 alphabet, check it. It is almost certainly plaintext wearing a hat.
6. Disabled certificate validation
The line exists in every codebase that ever hit a staging certificate problem and never cleaned up afterwards.
grep -rn "verify=False\|rejectUnauthorized: false\|InsecureSkipVerify: true\|CURLOPT_SSL_VERIFYPEER, 0" .
Any hit is a machine-in-the-middle waiting to happen. Fix the certificate or trust the internal CA properly.
7. Weak randomness
Tokens, session IDs and reset codes must come from a cryptographic random source. A general-purpose random generator can be seeded predictably and is not safe for security values.
grep -rn "Math.random()\|random.random()\|new Random()\|rand()" . | grep -i "token\|session\|reset\|nonce"
Use crypto.randomBytes, secrets.token_urlsafe, SecureRandom or the platform equivalent.
8. Home-made crypto
Custom schemes fail in ways the author cannot see: a MAC that does not cover the whole message, an encrypt-then-MAC order that leaks, a "simple" key derivation that is one concatenation. Use a vetted library and a vetted construction — libsodium, Google Tink, or the standard library's high-level API.
A ten-minute review
- Search for the seven patterns above. Fix the hits you find before anything else.
- List every place a key is created or loaded, and ask where it is stored.
- Check which algorithms are in use, then check the mode and the IV handling for each.
- Confirm password storage uses Argon2id, scrypt or bcrypt with sane parameters.
- Run a secret scanner over the full history, not just the working tree.
Related: Argon2id, cryptographically secure random numbers, and the Hash & JWT Inspector if you want to identify what a hash actually is before deciding it is wrong.