Why is a MAC built as SHA256(secret concatenated with message) vulnerable to a length-extension attack?
mac = SHA256(secret || message)
- An attacker can extend the message and forge a MAC
- The output digest reveals the secret key directly
- Collisions in SHA-256 let the hash be reversed
- 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 ▸