10. HTTP Digest Access Authentication
Why MD5 Fails
- MD5 is weak due to its speed and lack of salting, which makes it vulnerable to pre-computation attacks using Rainbow Tables.
- Modern systems use slow, adaptive hashing algorithms like bcrypt or Argon2 with a unique salt for each password, rendering these attacks infeasible.
HTTP Digest Access Authentication
Uses a challenge-response mechanism to avoid sending anything that can be directly replayed or looked up in a simple rainbow table.
- Client: Requests a protected page.
- Server: Responds with a
401 Unauthorized
status and aWWW-Authenticate
header containing anonce
(a random, one-time-use number). - Client:
- Prompts the user for a password.
- Calculates a response by hashing the username, the password, the provided nonce, the HTTP method, and the requested URI.
- Re-sends the request for the page, this time with an
Authorization
header containing the calculated hash response and the nonce.
- Server:
- Performs the exact same calculation on its end with the user's known password.
- If the hashes match, access is granted.
- This prevents simple replay attacks (because the nonce changes) and protects the password itself from being sent over the wire.
- However, it is still vulnerable to MITM attacks where the attacker can capture the hash and attempt an offline brute-force attack.