Course contentsShow
← Security
Lesson 697 of 3,05215. Web Security - Authentication and SessionsFree lesson

Rainbow Tables and Pre-computed Hash Attacks

Learn how rainbow tables enable rapid password cracking and why proper salting defeats these attacks.

Rainbow Tables and Pre-computed Hash Attacks

What you'll learn: How attackers use pre-computed hash tables to crack passwords instantly, and why salting is the essential defense.

The Pre-computation Problem

Remember from earlier lessons that attackers can crack unsalted hashes through brute force or dictionary attacks? What if an attacker did all that work once, saved the results, and reused them forever?

That's exactly what a rainbow table is: a massive pre-computed database mapping common passwords to their hash values. Instead of hashing millions of password guesses every time, the attacker simply looks up your hash in their table.

How Rainbow Tables Work

Imagine you have a phone book, but instead of names and numbers, it contains passwords and their hashes:

password123 → 5f4dcc3b5aa765d61d8327deb882cf99
letmein     → 0d107d09f5bbe40cade3de5c71e9e9b7
qwerty      → d8578edf8458ce06fbc5bb76a58c5ca4

When an attacker steals a database of unsalted hashes, they just look each one up in their rainbow table. Instant password recovery for common passwords.

Rainbow tables use clever compression techniques (time-memory trade-offs) to store billions of hash/password pairs in manageable file sizes—sometimes just a few gigabytes covering entire dictionaries.

Why Salting Defeats Rainbow Tables

When each password has a unique salt added before hashing, the rainbow table becomes useless. The attacker would need a separate rainbow table for every possible salt value—computationally infeasible when salts are long and random.

With proper salting, attackers are forced back to attacking each password individually, which is why we also use slow hashing algorithms like bcrypt or Argon2.

Key Takeaway: Rainbow tables enable instant cracking of unsalted hashes by pre-computing password-to-hash mappings; unique salts per password completely defeat this attack by making pre-computation impossible.