Security operations

What Is a Rainbow Table Attack? How It Works and How to Stop It

A rainbow table turns a stolen hash database into readable passwords — fast. The good news: one simple defense, salting, makes the whole attack impractical.

Cysoro Security TeamPublished · 7 min read
hash → passwordhash → passwordhash → passwordhash → passwordhash → passwordSECURITY OPERATIONSRainbow tableattackPrecomputed hashes — and the salt that stops them.
Quick answer

A rainbow table attack is a password-cracking technique that reverses stolen password hashes back into plaintext using a precomputed table of hash chains. An attacker steals a database of unsalted password hashes, then looks each hash up in the table instead of guessing passwords one by one. A unique random salt per password, combined with a slow key derivation function such as bcrypt, Argon2 or PBKDF2, makes the attack impractical.

Key takeaways

  • A rainbow table trades storage and one-time computation for very fast lookups against stolen hashes.
  • It only works well against unsalted hashes — a unique salt per password defeats it.
  • Use bcrypt, Argon2 or PBKDF2, strong unique passwords, and multi-factor authentication to limit the damage.

When a website is breached, attackers rarely steal passwords in plain text. They steal hashes — scrambled fingerprints of passwords. A rainbow table attack is a shortcut that turns those hashes back into readable passwords, fast.

What is a rainbow table attack?

A rainbow table attack is a password-cracking technique that reverses stolen password hashes back into plaintext using a precomputed lookup structure called a rainbow table, instead of guessing candidate passwords one at a time.

When you log in, the service does not usually store your actual password. It stores a hash: the fixed-length output of running your password through a one-way hash function. If an attacker steals the database of hashes, they cannot simply reverse the math, because hash functions are designed to be one-way.

What they can do is guess a candidate password, hash it, and see if the result matches a stolen hash. A rainbow table does that guessing work in advance, once, and stores the results compactly so the later lookup takes seconds rather than hours.

How does a rainbow table attack work?

A rainbow table attack works in two phases: build the table once, then look up stolen hashes in it. The table stores chains of hashes rather than every password-hash pair, which keeps it small enough to store and share.

First, the attacker picks a hash function, such as MD5 or SHA-1, and a set of candidate passwords. They hash each candidate, then apply a reduction function that turns a hash back into a plausible password, hash that again, and repeat. Each chain starts with one password and ends with one hash; only the start and end are stored.

To crack a stolen hash, the attacker applies the reduction functions in turn and checks whether the result matches a chain endpoint. If it does, they rebuild that chain from its start to find the password that produced the hash. The name comes from the different reduction functions used in each column, which early diagrams showed as different colors.

Rainbow tables were invented by Philippe Oechslin, who published the technique at the CRYPTO 2003 conference, improving on a 1980 time-memory trade-off by Martin Hellman, as described in the Wikipedia rainbow table article. They are a practical example of a space-time trade-off: they use less processing time and more storage than brute force, but more processing time and less storage than a simple table of every password and hash.

A rainbow table stores chains, not every passwordpasswordstart of chainhash itone-way functionreduce itback to a passwordhash againrepeat the chainOnly the start and the end of each chain are storedTo crack a hash, rebuild the chain that ends at it — the start reveals the password.Chains make the table far smaller than storing every password and hash.
Rainbow tables store hash chains, so only the start and end of each chain need to be kept. Illustration by Cysoro.

What does a rainbow table attack look like in practice?

In practice, an attacker first steals a database of password hashes, then runs a cracking program that compares each hash against a rainbow table. If a hash matches, the program retrieves the plaintext password that produced it.

Imagine a database stores the MD5 hash of the password summer2024 with no salt. That password is in most candidate lists, so its hash is almost certainly in a precomputed table. The attacker looks it up and recovers the password in seconds, without guessing it live.

Now imagine the same password stored with a unique random salt and a slow hash function. The salt changes the hash, so the precomputed table no longer matches, and the slow function makes each guess expensive. The same lookup now fails, and the attacker must fall back to slow, per-password guessing.

One well-known incident involved LinkedIn in 2012, when attackers stole password hashes for about 6.5 million user accounts, which were later posted on a password forum, as Netwrix's rainbow table guide notes. The case is often cited in rainbow-table explainers because the hashes were unsalted, which made them far easier to crack.

How is a rainbow table attack different from brute force?

A rainbow table attack precomputes hashes once and looks them up later, while a brute-force attack hashes every guess at crack time. Rainbow tables are faster per hash after the table exists, but they only work for the hash function and password set the table was built for.

MethodWork done whenStorage neededWorks against salted hashes?Best for the attacker
Rainbow tableBefore the breach, onceLarge, but compacted by chainsNo, not practicallyMany unsalted hashes, fast
Brute forceDuring the attack, per guessAlmost noneYes, but slow if the hash is slowShort or weak passwords
Dictionary attackDuring the attack, per guessSmall word listYes, but slow if the hash is slowCommon passwords
Simple lookup tableBefore the breach, onceEnormousNoVery small password sets

Rainbow tables are specific to one hashing algorithm, such as MD5 or SHA-1. A table built for MD5 cannot crack SHA-256 hashes, and a table built for short lowercase passwords cannot crack a long passphrase with symbols.

Why does salting stop a rainbow table attack?

Salting stops a rainbow table attack because it gives every password a unique random value before hashing, so the same password produces a different hash for every user. A precomputed table built for unsalted hashes no longer matches anything.

A salt is a random string stored in plain text alongside the hash. When a user logs in, the system combines the entered password with that user's salt and hashes the result. Two users with the same password end up with different hashes, and an attacker would need a separate rainbow table for every possible salt value — which is infeasible with modern salt lengths.

Salting alone is not enough. A fast hash function such as MD5 or SHA-1 still lets an attacker guess billions of passwords per second on modern hardware. That is why modern password storage uses a slow key derivation function as well.

Use bcrypt, Argon2 or PBKDF2, which are designed to be slow and configurable. They add a work factor or iteration count that makes each guess expensive, while login for a real user still takes a fraction of a second. NIST SP 800-63B recommends salted, iterated hashing for stored passwords.

Is a rainbow table attack still a threat in 2026?

Against properly built systems, no — rainbow tables are much less of a threat than they used to be, because salting is now standard. Against old systems, legacy databases and unsalted hashes, they remain a real and fast attack.

The risk today is not a new rainbow table, but an old database. A breach of a legacy system, a backup, or a test database that still stores unsalted MD5 or SHA-1 hashes can be cracked quickly with tables that already exist and circulate freely.

Rainbow tables also do not help against strong, unique passwords stored with a slow salted hash, or against multi-factor authentication. Even if an attacker recovers a password, a second factor can still block the login.

If you run a system that stores passwords, audit how they are stored now. If the answer is plain MD5, SHA-1 or unsalted SHA-256, that is a finding to fix, not a debate to have.

Same password, different hash — that is the point of saltWithout saltsummer2024 → one hash, alwaysRainbow table finds it fastWith a unique saltsummer2024 + salt → new hashEvery user gets a different hashAdd a slow hashbcrypt, Argon2 or PBKDF2Each guess costs timeAdd MFAA stolen password aloneis not enough to log inSalt defeats the table; a slow hash defeats guessing; MFA defeats the login.
Salted, slow hashing plus MFA is the defense against rainbow table attacks. Illustration by Cysoro.

How do you protect against a rainbow table attack?

For developers, use a unique random salt per password and a slow key derivation function, and never store passwords with a fast unsalted hash. For users, use long, unique passwords and turn on multi-factor authentication everywhere it is offered.

  • Developers: use bcrypt, Argon2 or PBKDF2 with a unique random salt per password and a work factor you review yearly.
  • Developers: never use MD5 or SHA-1 for password storage, and never store passwords in plain text.
  • Developers: migrate legacy hashes on next login: verify the old hash, then re-hash with the new scheme.
  • Users: use a password manager to create a long, unique password for every site.
  • Users: turn on multi-factor authentication, so a recovered password alone cannot log an attacker in.
  • Users: check whether a password has appeared in a known breach with our free pwned password checker, and change it if it has.

Test a new password's strength before you reuse it anywhere with our free password strength checker.

What should you do if your passwords were in a breach?

If a service tells you its password database was stolen, change that password immediately, change it anywhere else you reused it, and turn on multi-factor authentication. Do not wait to see whether your account is misused.

  1. Change the breached password first, from a device you trust, using a new unique password.
  2. Change it everywhere you reused it. Reuse is what turns one breach into many compromised accounts.
  3. Turn on multi-factor authentication on that account and on your email, which is the key to most password resets.
  4. Check for odd activity such as new logins, changed recovery details or forwarding rules.
  5. Use a password manager so you never need to reuse a password again.

If you are unsure whether a device or account is compromised, our guide to how to know if your phone is hacked covers the signs to check.

The bottom line

A rainbow table attack is fast only against unsalted hashes. A unique salt per password, a slow hash function such as bcrypt or Argon2, and multi-factor authentication together make it impractical — and they are all standard practice in 2026.

Check your own passwords first: use our free password strength checker to find weak passwords before an attacker does.

Also run exposed passwords through the pwned password checker to see whether they have appeared in a known breach.

Frequently asked questions

What is a rainbow table attack in simple terms?

It is a password-cracking shortcut. An attacker steals hashed passwords, then looks each hash up in a precomputed table of hash chains instead of guessing passwords one by one.

What is a rainbow table?

A rainbow table is a precomputed table for reversing cryptographic hash outputs, usually to crack password hashes. It stores chains of hashes and reduction functions compactly, so lookups are fast after the table is built.

Does salting stop a rainbow table attack?

Yes, in practice. A unique random salt per password means the same password produces a different hash for every user, so a table built for unsalted hashes no longer matches. Modern salt lengths make building a table per salt infeasible.

What is the difference between a rainbow table and brute force?

A rainbow table does the hashing work once in advance and looks results up later, while brute force hashes every guess during the attack. Rainbow tables are faster per hash but only work for the hash function and password set they were built for.

Are rainbow table attacks still used in 2026?

Against properly built systems with salted, slow hashing they are much less of a threat than they used to be. They remain a real risk against old systems and databases that still store unsalted MD5 or SHA-1 hashes.

How do I protect my passwords from rainbow table attacks?

Use long, unique passwords, a password manager, and multi-factor authentication. If you build systems, store passwords with bcrypt, Argon2 or PBKDF2 and a unique random salt per password.

Sources

  1. Wikipedia — Rainbow table
  2. TechTarget — Rainbow table
  3. Netwrix — Rainbow Table Attack: How It Works and How to Stay Safe
  4. NIST — SP 800-63B Digital Identity Guidelines: Authentication and Lifecycle Management
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against the Wikipedia rainbow table article, TechTarget and Netwrix explainers, and NIST SP 800-63B on password storage.

How we write and fact-check →

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free