Loading module...
Loading module...
OWASP-04
Failures related to cryptography which often lead to exposure of sensitive data.
Cryptographic failures focus on failures related to lack of cryptography, insufficiently strong cryptography, leaking of cryptographic keys, and related errors. Determine protection needs for data in transit and at rest - passwords, credit card numbers, health records, personal information, and business secrets require extra protection.
Impact: Common CWEs include weak pseudo-random number generators (CWE-327, CWE-331, CWE-338, CWE-1241), affecting data confidentiality and integrity.
Using old or weak cryptographic algorithms or protocols either by default or in legacy code.
Transmitting data in clear text using protocols like HTTP, SMTP, FTP, or not enforcing encryption via security headers.
Not properly validating received server certificates and trust chains.
Block ciphers (AES, DES, etc.) encrypt data in fixed-size blocks. A "mode of operation" defines how those blocks chain together. Electronic Codebook (ECB) mode is the simplest: each block is encrypted independently using the same key, with no chaining. That is exactly what makes it insecure: identical plaintext blocks produce identical ciphertext blocks. An attacker looking at the ciphertext can see structural patterns from the original data without recovering the key at all.
The classic demonstration is the "ECB penguin": encrypting a bitmap of the Linux Tux penguin logo with AES-ECB produces ciphertext that still visibly shows the penguin outline, because repeated color regions in the source image become repeated ciphertext regions. The same pattern leakage applies to structured records, fixed headers, padding, and any repeated data.
What to use instead:
Using passwords as cryptographic keys without proper password-based key derivation functions.
Using randomness not designed for cryptographic requirements, or overwriting strong seeding with low entropy seeds.
Using MD5, SHA1, or non-cryptographic hash functions when cryptographic hashes are needed.
Cryptographic error messages or side-channel information exploitable through padding oracle attacks.
Cryptographic algorithms that can be downgraded or bypassed.
A site doesn't use or enforce TLS for all pages or supports weak encryption.
Attack: An attacker monitors network traffic at an insecure wireless network, downgrades connections from HTTPS to HTTP, intercepts requests, and steals the user's session cookie. The attacker replays this cookie and hijacks the authenticated session.
Impact: Access to or modification of user's private data, including altering money transfer recipients.
The password database uses unsalted or simple hashes to store passwords.
Attack: A file upload flaw allows an attacker to retrieve the password database. All unsalted hashes are exposed with rainbow tables of pre-calculated hashes. Simple or fast hash functions can be cracked by GPUs even if salted.
Impact: Complete compromise of all user accounts.
Disable caching for responses containing sensitive data (CDN, web server, application caching like Redis).
Use strong adaptive and salted hashing functions with work factor:
Always use authenticated encryption instead of just encryption.
Avoid MD5, SHA1, CBC mode, PKCS number 1 v1.5.
Prepare for post-quantum cryptography (PQC) - high-risk systems should be safe by end of 2030.
Content adapted from OWASP Top 10:2025, licensed under CC BY-SA 4.0