$ ./guess_the_languageCybersecurity
Cybersecurity · hard · #288

Why is a MAC built as SHA256(secret concatenated with message) vulnerable to a length-extension attack?

mac = SHA256(secret || message)
  1. An attacker can extend the message and forge a MAC
  2. The output digest reveals the secret key directly
  3. Collisions in SHA-256 let the hash be reversed
  4. The exact message length leaks from the digest
Merkle-Damgard hashes expose internal state in the digest, so an attacker can append data and compute a valid MAC; HMAC avoids this.
Play Cybersecurity ▸