Module lessons (1/4)
Integrity with HMAC vs Broken Prefix Hashing
Exploit canonical boundary collisions in naive SHA-256 concatenation, then sign and verify payloads properly with HMAC-SHA256.
What you'll learn in this lesson
- Explain why concatenating
SHA-256(secret + fields)exposes canonical boundary collisions and length-extension attacks. - Exploit an unframed concatenation hash to collide
'admin_readonly' + 'billing'with'admin' + '_readonlybilling'. - Sign and verify canonical tuples via
crypto.subtleHMAC-SHA256 and enforce timestamp replay windows on webhooks.
Overview
A raw hash function (SHA-256) creates fingerprints of unkeyed bytes — it was never meant to work as sha256(secret + fieldA + fieldB) for message authentication. Two distinct flaws hit raw concatenated MACs: missing delimiters let values slide across field boundaries, and Merkle-Damgard hash internals permit length-extension attacks without…
Study how unframed SHA-256 fails and how HMAC fixes both structural and cryptographic bugs:
Sections covered in this lesson
- 11. Boundary Collisions, Length Extensions & Canonical HMAC
- 22. Interactive Explorer: HMAC vs Prefix Hash & Replay
- 33. Progressive Labs: Warm-Up → Attack → Defend → Harden
- 44. Checkpoints & Code Review
Unlock "Integrity with HMAC vs Broken Prefix Hashing" and the full Application & Web Security curriculum
Exploit canonical boundary collisions in naive SHA-256 concatenation, then sign and verify payloads properly with HMAC-SHA256.
Unlock all 6 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Application & Web Security plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.