Hash functions and collisions: what MD5 and SHA-1 breaks actually mean
A cryptographic hash should make collisions and preimages infeasible. What collision attacks on MD5 (2004) and SHA-1 (SHAttered, 2017) broke, why the birthday bound halves effective strength, and which hashes to use for signatures, integrity, and passwords.
Diagram
Three properties and which ones broke
Step 1 of 4
Preimage
Given a hash, find any input: still infeasible for MD5 and SHA-1.
# Preimage # Given a hash, find any input: still infeasible for MD5 # and SHA-1.
The example on the open step is one illustration, or the fix you can paste into an application you own.
What this page is made of
3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.
Collisions break signatures
- What fails
- If two documents share a hash, a signature on one fits the other.
- Who is affected
- Anyone relying on SHA-1 or MD5 signatures.
- What you would notice
- Certificates or code signed with SHA-1.
- What you change
- Use SHA-256 or stronger for all signatures.
Birthday bound
- What fails
- Finding a collision takes about the square root of the hash space.
- Who is affected
- Systems using short hashes or truncated digests.
- What you would notice
- Truncated 64-bit identifiers used for security.
- What you change
- Use at least 256-bit hashes when collisions matter.
Wrong tool
- What fails
- Fast hashes are wrong for passwords; plain hashes are wrong for MACs.
- Who is affected
- Users and API clients.
- What you would notice
- SHA-256(secret + message) as an authentication tag.
- What you change
- Use HMAC and password-hashing functions.
Timeline
Wang and colleagues published MD5 collisions in 2004. In 2008, researchers used MD5 collisions to create a rogue CA certificate. Google and CWI published the first SHA-1 collision (SHAttered) in 2017, and a chosen-prefix SHA-1 collision (SHA-1 is a Shambles) followed in 2020. Git moved to hardened SHA-1 and added SHA-256 repository support.
Check yourself
Recognition and the fix. Nothing here is a procedure.
Two different PDFs share a SHA-1 hash. Which property failed?
Sibling techniques
Pages at the same depth, plus a lab and a glossary card for this one.