Fix it in your stack

Tested fixes for the weaknesses A04:2025 maps, in Express, Flask, Spring Boot, ASP.NET Core, Next.js, FastAPI, Django, net/http and Laravel: the vulnerable code, the fix, a wrong fix and the regression tests.

Why it matters

Missing or weak cryptography exposes data in transit and at rest, and mistakes in key management or randomness undermine even strong algorithms.

How to prevent it

  • Classify data, keep as little sensitive data as possible, and encrypt what remains at rest and in transit.
  • Use current algorithms through trusted libraries, always with authenticated encryption, and TLS 1.2 or later with forward secrecy and HSTS.
  • Store passwords with adaptive, salted functions such as Argon2id, scrypt or PBKDF2.
  • Generate keys with a cryptographically secure random source, keep the most sensitive keys in an HSM or key management service, and plan for algorithm migration.

Guides on this site

Main subject · Reference

ECB mode: why it leaks patterns and what to use instead

Derive exactly what ECB reveals and why a longer key cannot fix it, find where ECB enters real code, and replace it with an authenticated mode.

Main subject · Reference

Padding oracle attacks

Use a byte-level CBC example to see how a tiny validity signal becomes plaintext information, then design verification that checks more than the error message.

Main subject · Reference

Hash collisions and digital signatures: MD5, SHA-1 and what to use

Distinguish collisions from preimages, follow a colliding pair through signing and verification, and retire MD5 and SHA-1 from the verifiers that still accept them.

Main subject · Reference

Weak RSA key generation: shared primes, ROCA and safe keys

Recover a toy RSA factor with a greatest common divisor, distinguish shared primes, structured primes, duplicate keys and key length, and check a fleet of real public keys.

Main subject · Reference

RC4 keystream bias

Understand why fresh RC4 keys do not remove keystream bias and how repeated secret positions turn a small statistical effect into evidence.

Main subject · Reference

64-bit block ciphers and the Sweet32 mechanism

Calculate the birthday effect for 64-bit blocks and derive the CBC relation that can turn a collision into a plaintext disclosure.

Main subject · Case study

WEP: RC4 key reuse and weak IVs

Separate WEP’s repeated-keystream failure, weak-IV key recovery, and unkeyed integrity weakness through a concrete two-packet exercise.

Main subject · Case study

Flame: MD5 certificate forgery

Follow how a weak digest and an overpowered certificate trust path enabled forged code-signing authority, without equating the event with RSA key theft.

Main subject · Case study

Lucky Thirteen and POODLE: two different oracles

Compare two CBC oracles by their signal, protocol rules, and attacker prerequisites instead of treating them as interchangeable padding bugs.

Main subject · Case study

FREAK and Logjam: export-grade key exchange

Trace two export-grade downgrade paths and separate RSA factorization from finite-field Diffie–Hellman discrete logarithms.

Main subject · Case study

DROWN: one RSA key across incompatible protocols

Map an RSA key across services to see how an SSLv2 oracle could compromise TLS traffic on a different endpoint.

Main subject · Case study

Sweet32: the cost of a small block size

Read the 2016 Sweet32 demonstrations as evidence about traffic volume, repeated secrets, and session lifetime rather than treating a block-size threshold as an instant exploit.

Main subject · Case study

ROCA: structured RSA key generation

Understand why mathematically structured RSA primes were factorable despite normal key lengths, then plan replacement around generation provenance.

Main subject · Guide

Password storage: hashing parameters and rehash on login

Choose Argon2id, scrypt, PBKDF2 or bcrypt with current minimum parameters, store a versioned hash, and upgrade old hashes after a successful login without overwriting a reset.

Main subject · Guide

AEAD records: AES-GCM nonces, associated data and key limits

Build an encrypted record whose tag binds ciphertext to the intended tenant, record, purpose and format, keep nonces unique within each key’s usage limit, and verify the design with actual AES-GCM.

Main subject · Guide

Envelope encryption and key rotation: data keys, KMS keys and backups

Encrypt each record with its own data key, wrap that key in a KMS or HSM key, and keep wrapping-key rotation, data re-encryption, key deletion and restored backups as separate, tested operations.

Main subject · Guide

Operate TLS and certificates: configuration, renewal and verification

Configure a modern TLS profile with hybrid post-quantum key exchange, automate renewal for certificate lifetimes that fall to 47 days, and verify every termination point with a fresh handshake.

Main subject · Guide

Post-quantum migration: cryptographic inventory, hybrid TLS and deadlines

Inventory public-key cryptography by operation, owner and lifetime, turn on hybrid ML-KEM key exchange where it is already available, and plan signature and archive migration against the NIST, NSA, NCSC and EU dates.

Main subject · Reference

Choose cryptographic algorithms and parameters by job

A sourced quick reference for October 2026: which algorithm and parameters to use for encryption, hashing, passwords, MACs, signatures, key agreement, key derivation, randomness and TLS, the matching APIs in Node.js, Python, Java, Go and .NET, and where post-quantum migration stands.

Also covers this · Guide

Secrets management: storage, rotation and leaked-secret response

Follow one application credential from issuance through caching, rotation, revocation and restored backups, prove that its old value stops working, and respond correctly when a secret leaks.

Also covers this · Guide

JWT validation: algorithms, keys, claims and key rollover

Validate a JWT against a fixed algorithm, trusted keys and the expected issuer, audience and type, reject the known header attacks, and rotate signing keys without accepting arbitrary keys or breaking valid tokens.

Practice

References

  1. A04:2025 Cryptographic Failures (OWASP)

List data from the publisher. A guide is listed as the main subject when the weakness or risk is what the guide is about, and as covering it when a dedicated section or worked example addresses it.