Catalog My learning Blog
OWASP Top 10 2025 Explained with Examples and Fixes · Phase 3 · Lesson 5 · 5 min read

Cryptographic Failures (OWASP A04:2025)

On this page
  1. Encrypted and still readable: the Adobe breach
  2. Experiment 1: why ECB mode leaks patterns
  3. Experiment 2: AES-GCM detects tampering
  4. Experiment 3: SHA-256 vs Argon2id for passwords
  5. Cryptography checklist: data, TLS, keys and post-quantum
  6. Check yourself

Encrypted and still readable: the Adobe breach

In 2013 attackers took about 150 million Adobe user records. The passwords weren't hashed. They were encrypted with 3DES in ECB mode, using one key for everyone, next to plain-text password hints. Researchers never needed the key. Identical passwords produced identical ciphertext, so they grouped users by ciphertext, read the hints in each group, and guessed the most common passwords.

That's a cryptographic failure: the data was "encrypted", and still exposed. This category covers missing encryption, weak algorithms, wrong modes and bad key handling. Three experiments in Node make the common ones visible.

Experiment 1: why ECB mode leaks patterns

ECB (Electronic Codebook) mode encrypts each 16-byte block on its own. Encrypt "ATTACK AT DAWN!!" twice, then a different block:

JavaScript
const ecb = crypto.createCipheriv('aes-256-ecb', key, null);
Code
ECB block 0 32b255fb83383a0245e24fd539c6f529
ECB block 1 32b255fb83383a0245e24fd539c6f529
ECB block 2 c9bdb4380d7a5728cc0d554569252e85

Same plaintext, same ciphertext. Anyone watching learns which parts repeat without the key. AES is fine here; the mode is the problem.

Experiment 2: AES-GCM detects tampering

AES-GCM uses a fresh nonce per message, so repeats don't show. It also adds an authentication tag. Flip one bit of the ciphertext and decrypt:

JavaScript
const iv = crypto.randomBytes(12);                    // never reuse with the same key
const c = crypto.createCipheriv('aes-256-gcm', key, iv);
const ct = Buffer.concat([c.update('amount=100'), c.final()]);
const tag = c.getAuthTag();
ct[ct.length - 1] ^= 1;                               // attacker flips a bit
Code
GCM tampered: Unsupported state or unable to authenticate data

Decryption refuses. Without authentication, a flipped bit could quietly change amount=100 into something else. Use an authenticated mode (AES-GCM or ChaCha20-Poly1305), store the nonce and tag with the ciphertext, and never reuse a nonce with the same key.

Sensitive data is classified first, then protected in transit with TLS and at rest with authenticated encryption, with keys held in a key management service rather than in code.
Sensitive data is classified first, then protected in transit with TLS and at rest with authenticated encryption, with keys held in a key management service rather than in code.

Experiment 3: SHA-256 vs Argon2id for passwords

Passwords shouldn't be encrypted at all, because encrypted means someone can decrypt. Hash them, with a function built to be slow. On my laptop:

Code
sha256 per hash us 0.63
argon2id per hash ms 30.4

Argon2id with OWASP's suggested settings (19 MiB of memory, 2 passes) takes 30 ms, about 48,000 times slower than SHA-256. A user won't notice 30 ms at login. An attacker trying billions of guesses against a stolen database will. Memory-hard functions like Argon2id and scrypt also blunt GPU cracking. Node 24 includes Argon2 in node:crypto:

JavaScript
const salt = crypto.randomBytes(16);
const hash = crypto.argon2Sync('argon2id', {
  message: password, nonce: salt, parallelism: 1, tagLength: 32, memory: 19456, passes: 2,
});

bcrypt and scrypt are acceptable too. MD5, SHA-1 and plain SHA-256 aren't, salted or not.

In .NET, ASP.NET Core Identity's PasswordHasher uses PBKDF2, another accepted choice. Decoding a hash it generated on .NET 8 shows HMAC-SHA512 with 100,000 iterations. That's below OWASP's current PBKDF2 guidance, which runs to hundreds of thousands of iterations (600,000 for HMAC-SHA256). Raise it with PasswordHasherOptions.IterationCount; existing hashes verify as "rehash needed" and Identity upgrades each one the next time its user signs in. For encryption, System.Security.Cryptography.AesGcm gives you the authenticated mode from Experiment 2, with the same rule: a fresh 12-byte nonce for every message.

Cryptography checklist: data, TLS, keys and post-quantum

  • Classify and minimize first. Data you never store can't leak. Keep the last four card digits, not the number. Swap values for tokens where you can.
  • TLS 1.2 or later everywhere, including internal traffic, with forward secrecy so a stolen key can't decrypt old recordings.
  • Keys out of code. Use a key management service (KMS) or hardware security module (HSM), rotate keys, and scan repos for leaked secrets.
  • Use well-reviewed libraries, and patch them. Heartbleed (2014) was a bug in OpenSSL itself that let attackers read server memory, private keys included, 64 KB at a time.
  • Plan for post-quantum. Data recorded today could be decrypted by a future quantum computer ("harvest now, decrypt later"). NIST published its first post-quantum standards in 2024, and browsers already use hybrid post-quantum key exchange in TLS. Inventory where you use RSA and elliptic-curve crypto, starting with data that must stay secret for years.

Check yourself

Encryption can be reversed by anyone with the key, so a key leak exposes every password. Passwords need a slow one-way hash like Argon2id, bcrypt or scrypt.

AES-GCM is authenticated encryption: alongside the ciphertext it produces an authentication tag computed over it. Changing even one bit makes the tag check fail, so decryption raises an error instead of returning altered plaintext. That stops attackers from tampering with encrypted data undetected, which modes like CBC alone don't prevent.

That suggests deterministic encryption, such as ECB mode, or a nonce reused with the same key in a mode like GCM. Both leak which plaintexts are equal, and nonce reuse with GCM can let attackers recover the authentication key. Use a fresh random nonce for every encryption.

SHA-256 is designed to be fast, so attackers with stolen hashes can try billions of guesses per second on GPUs. Argon2id is deliberately slow and memory-hard, with a per-password salt, which makes large-scale guessing impractically expensive.

Mostly keeping TLS libraries, browsers and servers current, since hybrid post-quantum key exchange is being rolled out in TLS. Teams storing data that must stay secret for many years should track their crypto inventory and plan migration paths.