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.

Lesson 2 of 10 · 11 min read · practice only with authorization

Diagram

Three properties and which ones broke

Follow the path. One example at a time.

Step 1 of 4

Preimage

Given a hash, find any input: still infeasible for MD5 and SHA-1.

Illustration: Preimage
# 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.

  1. 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.
  2. 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.
  3. 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.

1 / 3

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.

  1. MapCryptography basics: hashes, symmetric and public-key encryption, and signaturesThe four primitives security work depends on, what each guarantees, and the common mistakes: encoding mistaken for encryption, fast hashes for passwords, and encryption without integrity.

Practice

  1. LabTerminal mission: Same rows, different hashFinance’s vendor file does not match the hash the bank sent, so someone suspects tampering. Compare the bytes and show that line endings, not edits, changed the hash.