Security & Privacy/Guide/Explainer

What Is a Rainbow Table Attack? Rainbow Table vs. Brute Force

What a rainbow table attack is, how precomputed hash chains crack passwords faster than brute force, and why salted hashing keeps your accounts safe.

Diagram of a rainbow table showing password hash chains built from a plaintext through repeated hashing and reduction-function steps
Diagram of rainbow table hash chains, by Dake, CC BY-SA 2.5. Image: Wikimedia Commons.

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. Because the hardest work — hashing millions or billions of candidate passwords — is done once in advance and stored compactly as chains, an attacker who later steals a database of unsalted password hashes can look up many of them in seconds rather than hours. Salting each password before hashing, which every modern password-storage scheme does by default, is what makes this attack impractical against properly built systems today.

Rainbow table attack, in brief

  • What it is: A precomputed table of hash "chains" that lets an attacker reverse a stolen hash into its original password far faster than hashing every guess from scratch.
  • Who invented it: Cryptographer Philippe Oechslin published the technique at the CRYPTO 2003 conference, improving on a 1980 time-memory trade-off by Martin Hellman.
  • What stops it cold: A unique random salt per password, which forces an attacker to build (or buy) a separate table for every possible salt value — effectively infeasible with modern salt lengths.
  • Who's still at risk: Systems storing passwords as unsalted MD5/SHA-1/SHA-256 hashes, and legacy breach dumps that get recirculated for years after the original leak.

What is a rainbow table attack?

When you log into a website, 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 cryptographic hash function. If an attacker steals the database of hashes, they can't simply reverse the math to recover the passwords; hash functions are designed so that going from output back to input is computationally infeasible directly. What attackers can do instead is guess a candidate password, hash it, and see if the result matches a stolen hash. A rainbow table attack is a highly efficient version of that guessing game: rather than hashing every candidate at crack time, the attacker (or someone they bought the table from) spends the computation up front, once, and stores the results in a compact precomputed structure that can be searched very quickly later.

The result is a classic time-memory trade-off: you spend disk space and a large one-time computation so that the actual attack, run later against a stolen hash dump, takes seconds to minutes per hash instead of a brute-force run that might take years. This is also why rainbow tables are almost always discussed alongside brute-force password attacks — they attack the same weakness (weak or absent salting) from a different angle.

How rainbow tables actually work

A naive approach to precomputation would be to build a full lookup table: hash every possible password of a given length and character set, and store every (plaintext, hash) pair. That works, but the storage requirement explodes immediately — even a modest character set and length produces more hash-plaintext pairs than is practical to store, let alone distribute. Rainbow tables solve this storage problem by storing chains of hashes instead of every individual hash.

Here's the core mechanism, according to the technique's original description and its Wikipedia summary of the published literature:

  1. Pick a starting plaintext candidate (for example, a random string).
  2. Hash it.
  3. Apply a reduction function to the hash output, which maps it back down into something that looks like a plaintext password (not a true inverse of the hash — just a deterministic way to produce another candidate plaintext).
  4. Hash that result, reduce again, hash again, and so on — alternating hash and reduction many times to build a "chain."
  5. Store only the first and last values of the chain — not every intermediate step.

Repeat this for millions of starting points, and you get a table where each row represents a long chain of hash/reduction steps, but only consumes the storage of two values. To crack a stolen hash later, the attacker applies the final reduction function to it and checks whether the result matches any stored chain endpoint. If not, they apply the next reduction and hash step backward and check again, repeating until they either find a matching endpoint or exhaust the possibilities. Once a match is found, they regenerate that specific chain from its stored starting point forward until the target hash reappears — and the plaintext that produced it is the cracked password.

Hash chains, reduction functions, and why "rainbow" matters

Hellman's original 1980 time-memory trade-off used this chaining idea but applied the same reduction function at every step of every chain. That created a practical problem: when two different chains happened to collide at the same point, they would merge and continue identically from then on, wasting precomputation effort and shrinking the effective coverage of the table relative to its size.

Philippe Oechslin's 2003 innovation — the one that gave the technique its name — was to use a different reduction function at each position (each "column") of the chain. Two chains can now only merge if they collide at exactly the same column using exactly the same reduction function, which is far less likely. Oechslin's own paper, presented at CRYPTO 2003 and demonstrated against Windows password hashes, reported cracking 99.9% of alphanumeric hashes in roughly 13.6 seconds using about 1.4 GB of precomputed table data — compared with around 101 seconds using the older distinguished-points variant of the same general idea. The color-coded diagram Oechslin used to illustrate the different reduction functions per column is why the technique is called a "rainbow" table.

This is a meaningfully different attack shape than guessing from a wordlist, which is sometimes confused with rainbow tables but works differently — see the comparison below.

Rainbow table vs. brute force vs. dictionary attack

All three techniques try to recover a plaintext password from a stolen hash, but they differ in when the work happens and what they trade off.

Attack typeCore ideaWhen the heavy computation happensStorage neededDefeated by
Rainbow table attackPrecomputed hash chains reversed via reduction functionsUp front, once, reused for many targetsModerate–large (gigabytes, via chain compression)Per-password salting; slow/memory-hard hashing
Brute-force attackHash every possible candidate at crack timeAt crack time, per targetMinimalLong passwords; slow hashing; rate limiting/lockouts
Dictionary attackHash a curated wordlist (real words, leaked passwords, common patterns) at crack timeAt crack time, per targetMinimal (just the wordlist)Unique, non-dictionary passwords; salting; slow hashing

In practice, a dictionary attack is really a smarter-ordered brute-force attack: instead of trying candidates in a fixed sequential order, it tries the most likely human-chosen passwords and leaked-password patterns first, which is why it's often grouped with brute-force methods rather than treated as a separate category. A rainbow table attack is different in kind, not just degree: it shifts the expensive hashing work to before the attacker even has the target hash, which is only a winning trade if the same precomputed table can be reused against many hashes — and that reuse is exactly what a unique salt per password prevents.

It's also worth distinguishing rainbow table attacks from session hijacking, which steals an already-authenticated session token instead of cracking a password hash at all, and from the credential-stuffing and MFA fatigue attacks that come after an attacker already has a working password — rainbow tables sit upstream of both, at the point where raw hash data first gets reversed into usable credentials.

Why salting defeats rainbow tables

A salt is a random value generated for each password and stored alongside its hash. Instead of hashing just the password, the system hashes password + salt (combined in some defined way). Two users with the identical password now get two completely different stored hashes, because their salts differ.

This single change breaks the rainbow table economics. A precomputed table is only valuable because it can be built once and reused against many hashes. If every password hash in a database uses a different salt, an attacker would need a separate precomputed table for every possible salt value — and with a modern random salt of 128 bits or more, the number of possible salts is astronomically larger than anyone could precompute for. As OWASP's Password Storage Cheat Sheet puts it, a unique per-user salt means an attacker has to crack hashes one at a time using the respective salt, which is precisely the brute-force-per-target scenario that rainbow tables were built to avoid. OWASP notes this directly: salting "protects against an attacker pre-computing hashes using rainbow tables or database-based lookups."

Historically, this is also why rainbow tables were devastating against systems that used no salt, or short salts. Wikipedia's technical summary of the history notes that older Unix crypt implementations used only a 12-bit salt — just 4,096 possible values, small enough that an attacker could precompute 4,096 tables and still come out ahead. Modern schemes such as bcrypt and SHA-2-crypt use salts of 128 bits or more, which puts brute-forcing the salt space itself entirely out of reach.

Salting alone isn't the whole story, though. NIST's digital identity guidelines (SP 800-63B) require that verifiers store memorized secrets using a salt of at least 32 bits chosen to avoid collisions, combined with an approved password-hashing scheme and a deliberately expensive "cost factor" — and recommend increasing that cost factor over time as attacker hardware gets faster. That second ingredient, deliberate slowness, is what also blunts plain brute-force and dictionary attacks against salted hashes, not just rainbow tables.

Why rainbow table attacks are still a relevant threat

If every modern system salts its password hashes, why does this topic still come up? A few reasons keep rainbow tables practically relevant rather than purely historical:

  • Legacy and poorly built systems persist. Internal tools, older self-hosted software, embedded devices, and systems built by teams unaware of current guidance still sometimes hash passwords with unsalted MD5 or SHA-1 — exactly the conditions rainbow tables are built for.
  • Breach dumps recirculate for years. When a database of unsalted or weakly hashed passwords leaks, it doesn't just get used once. It gets redistributed, re-cracked with improved tables, and fed into password-reuse and credential-stuffing attacks against unrelated services for years afterward.
  • Password reuse multiplies the damage. A rainbow table doesn't need to crack a hash on the service you actually care about — if it cracks the same password reused on a weaker, unsalted system, the attacker can try that same password against your accounts directly, no hash-cracking required there at all.
  • It's foundational knowledge for every other hash-cracking method. Understanding the hash-chain/reduction-function trade-off is the basis for understanding why hashing speed, salting, and memory-hardness all matter for defense — it underpins the reasoning behind OWASP's and NIST's current hashing recommendations.

How site operators should defend against this

If you store user credentials, the defense against rainbow tables is the same defense that protects against brute-force and dictionary attacks on a stolen hash dump — because all three rely on the attacker being able to cheaply test large numbers of guesses against your hashes:

  • Always salt, uniquely, per password. Never hash passwords without a salt, and never reuse a salt across users. Modern libraries for the algorithms below generate and manage this automatically.
  • Use a slow, memory-hard password hashing algorithm — not a general-purpose fast hash. OWASP's current cheat sheet ranks Argon2id first (minimum configuration of roughly 19 MiB of memory, an iteration count of 2, and 1 degree of parallelism, with several equivalent memory/CPU trade-off profiles listed), followed by scrypt where Argon2id isn't available, and PBKDF2 (600,000 iterations with HMAC-SHA256) where FIPS-140 compliance is required. bcrypt is recommended only for legacy systems that can't use the newer options, with a work factor of at least 10.
  • Never use unsalted MD5, SHA-1, or raw SHA-256 for password storage. These are fast, general-purpose hash functions — exactly what makes both brute-force guessing and rainbow-table precomputation cheap against them.
  • Add a secret pepper for defense in depth. NIST's SP 800-63B guidance recommends an additional keyed hashing or encryption step using a secret key stored separately from the password database (ideally in a hardware security module or similar), so that a database-only breach (e.g., via SQL injection) doesn't hand over crackable hashes at all.
  • Plan for algorithm migration. Store the hashing scheme and cost factor alongside each hash so you can raise the cost factor over time, per NIST's recommendation, as attacker hardware improves.

How to protect your own passwords as a user

You can't control how a service stores your password hash, but you can limit how much a rainbow table — or any other hash-cracking method — can hurt you if it does leak:

  • Use a unique password for every account. This is the single highest-leverage habit: even if an attacker fully cracks one weak, unsalted hash, a unique password on every other site means that crack doesn't open any other door.
  • Use a password manager to generate and store long, random, unique passwords — CISA's current guidance on strong passwords recommends length (CISA suggests at least 16 characters) and randomness as the two habits that matter most, specifically because they resist both guessing and precomputation attacks.
  • Switch to passkeys where offered. Passkeys use public-key cryptography instead of a shared secret that gets hashed and stored server-side at all, which sidesteps rainbow tables, brute force, and credential stuffing simultaneously.
  • Enable multi-factor authentication so that a cracked or guessed password alone isn't enough to log in as you.
  • Check whether your email or passwords have appeared in known breaches, and rotate any reused passwords immediately if they have.

What to do next

Rainbow table attacks are a reminder that "hashed" is not automatically "safe" — the strength of the hash function, and whether it's salted and deliberately slowed down, determines whether a stolen database is a minor incident or a full credential breach. If you run a service, audit how you store passwords against OWASP's current cheat sheet and NIST SP 800-63B today, not after an incident. If you're a user, the fix is simpler and entirely in your control: unique passwords (ideally generated and stored by a password manager), passkeys where available, and multi-factor authentication everywhere else.

Frequently asked questions

What is a rainbow table attack in simple terms?

It's a way of cracking a stolen password hash by looking it up in a precomputed table instead of guessing passwords from scratch. The table stores compressed chains of hash computations done in advance, so reversing a hash to find the original password takes seconds instead of the hours or years a brute-force guess-by-guess attack would take.

How is a rainbow table attack different from a brute-force attack?

A brute-force attack hashes every candidate password at the moment of the attack, using no precomputation. A rainbow table attack does the expensive hashing work once, in advance, and stores it as compact hash chains, so the actual attack against a stolen hash is just a fast lookup. The trade-off is storage: rainbow tables need real disk space to hold the precomputed chains.

How is a rainbow table attack different from a dictionary attack?

A dictionary attack hashes a curated wordlist of likely passwords (real words, common patterns, leaked passwords) at crack time, trying the most probable guesses first. Like brute force, all of that hashing happens live, per target. A rainbow table attack, by contrast, reuses one precomputed table across many stolen hashes without hashing anything new at crack time, which is why unique per-password salts (rather than just longer or less common passwords) are what stops it.

Does salting really stop rainbow table attacks?

Yes. A rainbow table is only cost-effective because it can be reused against many hashes. A unique random salt per password means every hash needs its own separate precomputed table, and with a modern salt of 128 bits or more, the number of required tables is far beyond what anyone could precompute. OWASP's Password Storage Cheat Sheet states directly that salting protects against precomputed rainbow-table and lookup attacks.

Are rainbow table attacks still a threat in 2026?

Yes, mainly against legacy or poorly configured systems that still store passwords as unsalted MD5, SHA-1, or SHA-256 hashes, and against old breach dumps that keep circulating and getting re-cracked. Properly salted, slow hashing algorithms like Argon2id, scrypt, bcrypt, or PBKDF2 (as recommended by OWASP and NIST SP 800-63B) make the technique impractical.

Can rainbow tables crack any password hash?

No. They only work efficiently against hashes that were computed without a unique salt, using the exact hash algorithm the table was built for, within the password length and character set the table covers. Salted hashes, and hashes produced by deliberately slow algorithms like Argon2id or bcrypt, make precomputed rainbow tables impractical to build or use.

Sources

More on Rainbow Table Attack →Rainbow Table AttackPassword SecurityHashingCybersecurityOWASP
Sana Qureshi
Written bySana Qureshi

Sana Qureshi runs the security and privacy desk. She reports on actively exploited vulnerabilities, vendor patches and data breaches, and covers the password managers, VPNs and authentication tools readers use to protect themselves. Her alerts cite vendor advisories, CISA and the CVE record directly.

More from Security & Privacy

See all