Broken Cryptography
Use of a Broken or Risky Cryptographic Algorithm
CWE-327 · High severity · Updated November 6, 2026
What it is
CWE-327 covers the use of cryptographic algorithms that are known to be broken (DES, MD4), known to be unsuitable for the use case (MD5 for password hashing, ECB mode for encryption), or used incorrectly (predictable IVs, missing authentication on ciphertexts).
Why it matters
Broken cryptography is one of the most frequently-cited weaknesses in regulatory enforcement actions. PCI-DSS, HIPAA, FedRAMP, and CMMC all require specific algorithm and key-strength minimums. Use of MD5 or SHA-1 for password hashing has been the root cause of multiple credential-stuffing follow-on attacks because attackers can crack the hashes offline.
Common patterns
- Password hashing with MD5, SHA-1, SHA-256, or other fast hashes instead of bcrypt, argon2, scrypt, or PBKDF2.
- Symmetric encryption with ECB mode (visible patterns) or CBC without HMAC (padding oracle).
- Hardcoded IVs or using zero IVs.
- Weak random number generation (Math.random, rand(), time-seeded PRNGs) for cryptographic purposes.
- DES, 3DES, RC4, or Blowfish in new code.
- Custom or in-house cryptography ('rolled their own crypto').
Languages affected
Python, JavaScript, TypeScript, Java, Go, Ruby, PHP, C#
What Deva detects
Deva matches algorithm names, mode constructors, and library calls. The scanner flags hashlib.md5/sha1 used with password-like variables, javax.crypto.Cipher.getInstance with 'DES', 'RC4', or '/ECB/' modes, hardcoded byte arrays passed as IVs, and use of Math.random where the value is used as a token or salt. The fix recommendation depends on context: bcrypt/argon2 for passwords, AES-GCM (or ChaCha20-Poly1305) for symmetric encryption, ECDSA P-256 or Ed25519 for signing.
Example
Vulnerable
import hashlib
def hash_password(password):
return hashlib.md5(password.encode()).hexdigest()Fixed
from argon2 import PasswordHasher
from argon2.exceptions import VerifyMismatchError
hasher = PasswordHasher()
def hash_password(password: str) -> str:
return hasher.hash(password)
def verify_password(password: str, stored_hash: str) -> bool:
try:
return hasher.verify(stored_hash, password)
except VerifyMismatchError:
return FalseMD5 is a broken, fast hash. Modern GPUs compute billions of MD5 hashes per second. Once an attacker exfiltrates the hashed-password table, they can crack typical passwords offline in hours. argon2 (the current best practice, recommended by OWASP) is purposefully slow and memory-hard, raising the offline cracking cost by orders of magnitude. bcrypt and scrypt are also acceptable.
Where this fits in OWASP Top 10
- A04 Cryptographic FailuresSensitive data exposed because cryptography is missing, weak, or misused.
Compliance framework references
These references explain how the weakness relates to control topics. They do not mean Deva offers evaluation for every framework listed. CMMC evaluation and SPRS scoring are currently unavailable. See the FAQ for offered frameworks and preview status. Deva provides code-level evidence for your assessment, without certifying compliance.
| Framework | Controls |
|---|---|
| OWASP Top 10:2025 | A04:2025 Cryptographic Failures |
| NIST 800-53 Rev 5 | SC-13 Cryptographic Protection, IA-5 Authenticator Management |
| PCI-DSS v4.0.1 | 8.3.2 Strong cryptography for credentials |
| HIPAA Security Rule | 164.312(a)(2)(iv) Encryption and Decryption |
| FedRAMP | SC-13 Cryptographic Protection |