Threats and vulnerabilitiesAttacks and exploitsBeginner19 min read

What Is Rainbow table? Security Definition

Reviewed byJohnson Ajibi· Senior Network & Security Engineer · MSc IT Security

This page mentions older exam versions. See the Current Exam Context and Legacy Exam Context sections below for the updated mapping.

On This Page

Quick Definition

A rainbow table is like a huge cheat sheet for cracking passwords. Instead of trying every password one by one, it stores the results of common passwords already turned into secret codes. When an attacker steals a list of coded passwords, they can look up the code in the table and instantly see the original password. This makes it much faster than guessing each password over and over.

Commonly Confused With

Rainbow tablevsDictionary attack

A dictionary attack tries each password from a list against a live system or a hash file one by one in real time. A rainbow table precomputes the hash for every password in the list so that lookup is instant. The main difference is precomputation versus live trial.

Dictionary: trying 'apple' as a password by typing it into a login box. Rainbow table: looking up the hash of 'apple' in a precomputed list without ever typing it.

Rainbow tablevsBrute-force attack

A brute-force attack tries every possible combination of characters (aaaa, aaab, aaac, ...) until the correct password is found. It is exhaustive and slow. A rainbow table only works for passwords that were included in the precomputation; it cannot crack passwords not in the table.

Brute-force: trying all possibilities from 'a' to 'zzzzzzz'. Rainbow table: looking up a hash but only getting a result if the password was precomputed.

Rainbow tablevsHash collision attack

A hash collision attack finds two different inputs that produce the same hash output. This is used to bypass integrity checks or digital signatures. A rainbow table does not find collisions; it reverses a single hash to its original input.

Collision: finding two different documents with the same file checksum. Rainbow table: finding that hash '5d41402abc4b2a76b9719d911017c592' comes from 'hello'.

Must Know for Exams

Rainbow tables appear frequently in CompTIA Security+ (SY0-601 and SY0-701) under domain 1.2 on threats, specifically within the category of password attacks. Candidates must be able to differentiate rainbow tables from dictionary attacks and brute-force attacks. Exam objectives explicitly list rainbow tables as a type of cryptographic attack. Multiple-choice questions often present a scenario where a database of hashes is stolen, and the candidate must choose the best mitigation, such as implementing salting or using a key-stretching algorithm.

In the CEH exam from EC-Council, rainbow tables are part of the system hacking phase, particularly in password cracking. The exam may ask about tools like RainbowCrack or Ophcrack, or require the candidate to identify the time-memory trade-off approach. CEH scenario questions might describe an attacker who obtains a large precomputed table of hashes and asks which attack is being used.

For CISSP, rainbow tables fall under domain 3 (Security Architecture and Engineering) in the context of cryptography and authentication. The exam may require understanding why salting defeats rainbow tables and how hash functions interact with password storage. A typical question might present a database with unsalted SHA-1 hashes and ask which attack is most effective.

Other certifications like CySA+ (CompTIA Cybersecurity Analyst) might include rainbow tables in vulnerability management or threat detection. The exam could involve a log analysis scenario where an attacker has used rainbow tables and the candidate must identify the indicators.

Question types across these exams are usually multiple-choice, but can include drag-and-drop or matching. Common traps include confusing rainbow tables with dictionary attacks (which try passwords one by one without precomputation) or brute-force (which tries every possible key). Another trap is assuming that all hash attacks are equally effective, while rainbow tables are only useful for unsalted, non-stretched hashes. Mastering these nuances helps candidates avoid losing points on tricky items.

Simple Meaning

Think of a password like a key that opens a lock. Instead of keeping the actual key, most computer systems store a secret fingerprint of that key called a hash. When you type your password, the computer turns it into a hash and checks if it matches the stored hash. This way, even if someone steals the stored fingerprints, they should not be able to recreate your key.

A rainbow table is like a giant cookbook that already lists the fingerprints for millions of common keys. An attacker who steals a list of fingerprints can flip through the rainbow table and find which key produces each fingerprint. For example, if the table shows that the fingerprint ABC123 belongs to the key "password123", the attacker instantly knows the password.

The table is built by taking every word in a dictionary, every common password, and every possible combination of letters and numbers, then calculating the fingerprint for each one. The attacker does not have to do this work in real time because the table is already done. This makes cracking weak passwords almost instant.

However, modern systems fight rainbow tables by adding salt. Salt is like adding a secret ingredient to each password before fingerprinting it, so the same password gets a different fingerprint every time. This destroys the usefulness of a precomputed table because the attacker would need a separate table for each possible secret ingredient, which is impractical.

Full Technical Definition

A rainbow table is a data structure used in cryptanalysis to invert cryptographic hash functions, primarily for cracking password hashes. It is a time-memory trade-off technique originally described by Martin Hellman in 1980 and later refined by Philippe Oechslin in 2003 with the introduction of distinguished points and reduction functions. The table stores a chain of hashes and plaintexts, allowing an attacker to reverse a hash to its input without performing a brute-force search for each target.

The construction of a rainbow table begins with a set of initial plaintexts, often derived from a password policy or common password lists. Each plaintext is hashed, and the resulting hash is reduced to a new plaintext using a reduction function. This process repeats for a fixed chain length (e.g., 10,000 steps). Only the starting plaintext and the final hash of each chain are stored. To crack a target hash, the attacker applies the same reduction and hashing sequence starting from the target. If the resulting hash matches any stored endpoint, the chain is regenerated from the start to find the plaintext that produced the target hash.

Rainbow tables are highly effective against systems that use unsalted hashes, such as older LM (LAN Manager) hashes, NTLM (NT LAN Manager) without salting, or unsalted MD5 and SHA-1. Tools like RainbowCrack and Ophcrack implement this technique, and public rainbow tables exist for these algorithms covering up to 14 characters.

Modern countermeasures include salting (appending a random value to each password before hashing), key stretching (repeating the hash thousands of times with algorithms like bcrypt, PBKDF2, or Argon2), and using modern hash functions like SHA-256 or SHA-3. A salt of even 16 random bytes forces the attacker to generate a new rainbow table for each unique salt, making the attack computationally infeasible. In enterprise environments, Active Directory uses NTLM hashes that are still vulnerable if not salted, but modern implementations use Kerberos with salting. The CompTIA Security+ exam often covers rainbow tables under threats and vulnerabilities, specifically as a password attack vector.

Real-Life Example

Imagine you are at a huge costume party with thousands of guests. Everyone is wearing a mask and a nametag with a secret code printed on it. The host does not keep a list of real names; instead, they have a big book that matches every secret code to the costume description. To find out who someone is, the host looks up the code in the book and reads the costume.

Now, suppose a troublemaker wants to know everyone's real identity. They could run around the party, peek at each secret code, and then try to guess the costume that goes with it. That would take forever. Instead, the troublemaker builds their own book beforehand. They take every possible costume description they can think of, red hat, blue shoes, green cape, and compute what secret code the host would assign to that costume. They fill a giant book with costume descriptions and matching secret codes.

Later, at the party, the troublemaker looks at someone's nametag code, flips open their book, and immediately reads the costume description. They now know that code XYZ belongs to the person wearing the red cape. This is exactly how a rainbow table works. The attacker precomputes the hash (secret code) for millions of possible passwords (costumes). When they steal a list of hashes from a server, they just look up each hash in the table and instantly see the original password.

The weakness of this approach is that if the host changes the rule for generating secret codes for each guest (like adding a random unique ingredient for each person), the troublemaker's book becomes useless. In password terms, that ingredient is called a salt.

Why This Term Matters

For IT professionals, understanding rainbow tables is critical for assessing the security of authentication systems. Many legacy systems and even some modern databases store unsalted password hashes, making them highly vulnerable. An attacker who gains access to a database can use a rainbow table to recover millions of passwords within minutes. This is especially dangerous when users reuse passwords across multiple services, because a leaked password on one site can compromise accounts on other systems.

Rainbow tables also matter because they force security architects to adopt proper password storage practices. The use of salt is not optional but essential. Every hash must be salted with a cryptographically random value that is unique per user. Organizations must enforce password complexity requirements and use key-stretching algorithms to slow down brute-force attempts even further.

In penetration testing, knowing about rainbow tables helps testers evaluate password strength during audits. If a system uses unsalted hashes, it is a critical finding. Conversely, understanding rainbow tables helps defenders implement controls like account lockout policies, multi-factor authentication, and password expiration to mitigate the risk even if hashes are compromised.

Finally, this concept is a staple in IT certification exams. CompTIA Security+, CEH (Certified Ethical Hacker), and CISSP (Certified Information Systems Security Professional) all include rainbow tables under threats and password attacks. A solid grasp of rainbow tables helps candidates answer scenario-based questions about password cracking, hash security, and defense mechanisms like salting.

How It Appears in Exam Questions

Scenario-based questions are the most common. For example, a question might describe a company that stores user passwords using MD5 without salt. The attacker steals the database and is able to recover 90% of passwords within minutes. The question asks what technique the attacker most likely used. The correct answer is a rainbow table attack. Alternatively, the question might ask which defense would prevent this attack, and the answer is adding a salt or using a slow hash function like bcrypt.

Another pattern involves comparing attack types. A question could list three scenarios: one where the attacker tries every possible password until one works (brute-force), one where the attacker uses a list of common passwords (dictionary attack), and one where the attacker uses a precomputed table. The candidate must match each scenario to the correct attack name.

Troubleshooting-style questions might involve a security analyst who notices that a server's password file was compromised, but strong passwords remain uncracked. The candidate must infer whether the attacker used a rainbow table (only weak passwords would be cracked) or a brute-force attack (which might crack stronger passwords given enough time).

Configuration-based questions may ask what setting in Active Directory or a web application would mitigate rainbow tables. For instance, enabling password history, requiring complex passwords, or implementing salting. Some questions present a command output showing a hash file and ask what tool the attacker used.

Finally, exam items sometimes test the definition directly, requiring candidates to select the best description of a rainbow table from several options. These questions often include distractor answers that describe encryption, dictionary attacks, or key stretching. The key is to remember that a rainbow table is a precomputed time-memory trade-off that reverses a single hash into a plaintext quickly.

Practise Rainbow table Questions

Test your understanding with exam-style practice questions.

Practise

Example Scenario

You work as a security analyst for a small e-commerce company. One morning, the help desk reports that several user accounts have been taken over, and customers are complaining about unauthorized purchases. The IT team extracts the user database and discovers that the password hashes are stored as unsalted MD5 hashes.

The chief information officer (CIO) asks you to explain how the attacker could have recovered the passwords so quickly. You explain that the attacker likely used a rainbow table. You know that MD5 is fast, and without a salt, every time two users have the same password, their hash is identical. This makes the database perfect for a rainbow table lookup. The attacker simply downloaded or generated a rainbow table for MD5 and compared each hash to the table. Weak passwords like 'password123' or 'qwerty' were cracked instantly.

The CIO asks what you would have done differently. You recommend that all new user registrations must store passwords using a salted hash, such as SHA-256 with a 16-byte random salt per user. You also suggest implementing Argon2 or bcrypt for future password storage to slow down any offline cracking attempts. You advise enabling account lockout after five failed login attempts and requiring multi-factor authentication for all accounts.

A month later, you test the new system by simulating a database breach. Even though the attacker has the hash file, each hash now includes a unique salt, and the hash algorithm is deliberately slow. The attacker cannot use a rainbow table because they would need a separate table for every possible salt, which is computationally impossible. This scenario is a textbook example of why understanding rainbow tables is critical for defending against password attacks.

Common Mistakes

Thinking a rainbow table is the same as a brute-force attack

A brute-force attack tries every possible password one by one in real time. A rainbow table uses precomputed results to look up the password instantly. They are fundamentally different in method and speed.

Remember that brute-force guesses live, while a rainbow table looks up pre-made answers.

Believing that rainbow tables work against salted hashes

Salting adds a random unique value to each password before hashing. The same password with different salts produces different hashes. A precomputed table would need to include every possible salt, which makes it impossibly large.

If you see the word 'salt', know that rainbow tables are useless.

Confusing a rainbow table with a dictionary attack

A dictionary attack tries each word from a list against the live system. A rainbow table is built offline and used for offline hash lookup. The dictionary attack requires network interaction and is slower.

Dictionary = trying passwords one by one on the login screen. Rainbow table = looking up hashes from a precomputed list.

Assuming that all hash algorithms are equally vulnerable to rainbow tables

Rainbow tables exist for fast hash algorithms like MD5, SHA-1, and NTLM. Slow algorithms like bcrypt, scrypt, and Argon2 are designed to be computationally expensive, making precomputation impractical.

Check the hash algorithm. If it is a fast hash without salt, rainbow tables are a threat. If it is a slow hash, they are not.

Exam Trap — Don't Get Fooled

{"trap":"An exam question describes an attacker who uses a list of common passwords to try against a login page, and the answer choices include 'rainbow table attack'. Many learners select it incorrectly.","why_learners_choose_it":"Learners remember that rainbow tables involve lists of passwords and hashes.

The keyword 'list' makes them think of a rainbow table, but the attack is happening in real time against a live system, not offline.","how_to_avoid_it":"Always ask: Is the attack offline or online? If the attacker is interacting with a login page (online), it is not a rainbow table attack.

Rainbow tables are used only when the attacker has the hash file and can work offline."

Step-by-Step Breakdown

1

Select a set of possible passwords

The attacker chooses a large list of passwords, often based on dictionary words, common patterns, or all combinations of up to N characters. This list will be the basis of the table.

2

Hash the first password

Take the first password from the list and run it through the hash function (e.g., MD5, SHA-1). The output is a fixed-length string called a hash. This step is repeated for every password in the list.

3

Apply a reduction function

The hash is turned back into a new plaintext using a reduction function. This function maps the hash to a new possible password (not necessarily one from the original list). This creates a chain: password1 -> hash1 -> password2 -> hash2 -> password3 -> ...

4

Store the chain endpoints

Instead of storing every password and hash in the chain, only the first password of the chain and the final hash are saved. This dramatically reduces storage space while still allowing reconstruction when needed.

5

Repeat for many chains

The attacker generates many such chains, each starting from a different initial password. Over time, the collection of chain endpoints forms the full rainbow table. The table is saved to disk or shared online.

6

Load the target hash

When the attacker obtains a hash from a compromised database, they apply the same reduction and hashing sequence to the hash. If at any step they regenerate a hash that matches one of the stored endpoints, they found the chain.

7

Regenerate the chain to find the password

Starting from the original first password of that chain, the attacker applies reduction and hashing steps again, checking each intermediate plaintext until they find the one that produces the target hash. That plaintext is the password.

Practical Mini-Lesson

Rainbow tables are a classic time-memory trade-off in password cracking. In practice, an IT professional might encounter them during a penetration test or a forensic investigation. For example, you are tasked with assessing the security of a legacy application that stored user passwords using unsalted MD5. You can use a tool like RainbowCrack or Ophcrack with precomputed tables available from the Internet. The process is straightforward: load the hash file, specify the table, and let the tool match hashes. Within minutes, you can recover a significant percentage of weak passwords.

However, as a defender, you must understand how to prevent this. The simplest and most effective countermeasure is to use a random salt per user. When a user creates a password, generate a random string of at least 16 characters, append it to the password, then compute the hash. Store the salt and the hash together. Because the salt is different for every user, even if two users have the same password, their hashes will be different. A rainbow table built without that salt cannot be used.

use a slow hash function designed for passwords. Algorithms like bcrypt, PBKDF2, or Argon2 are intentionally slow. They iterate the hash thousands or millions of times, making it computationally expensive to generate a table even for a single salt. In a real-world environment, you might configure bcrypt with a cost factor of 12, meaning it takes about 250 milliseconds per password on modern hardware. This is acceptable for a login attempt but prohibitive for building a rainbow table covering billions of passwords.

For enterprise systems, Active Directory uses NTLM hashes, which are unsalted and vulnerable. However, Microsoft recommends using Kerberos with AES encryption and disabling NTLM. In cloud environments, AWS Cognito and Azure AD automatically handle password hashing with salt and key stretching.

What can go wrong? If a developer mistakenly uses a single global salt instead of a per-user salt, the attacker can still build one rainbow table for that salt. Another mistake is using a weak salt (e.g., only 4 bits). The best practice is to use a cryptographically secure random salt of at least 128 bits per user, and update it on every password change. In exams, you may be asked to identify the best practice among options, so remember: unique, random, and long salt with a slow hash algorithm.

Memory Tip

Rainbow Table = Precomputed Cheat Sheet. Think: 'Look it up, don't guess.' If there is salt, the cheat sheet doesn't work.

Covered in These Exams

Current Exam Context

Current exam versions that test this topic — use these objectives when studying.

Legacy Exam Context

Older materials may mention these exam versions, but learners should use the current objectives for their target exam.

SY0-601SY0-701(current version)

Related Glossary Terms

Frequently Asked Questions

Can a rainbow table crack any password?

No. A rainbow table can only crack passwords that were included in the precomputation. If a password is very long or not in the table, the lookup fails. Also, salts and slow hash functions make rainbow tables ineffective.

How do I defend against rainbow table attacks?

Use a unique, random salt for every password. Use a slow key-stretching algorithm like bcrypt, PBKDF2, or Argon2. Store the salt alongside the hash. Avoid fast hashes like MD5 or SHA-1 without salting.

Are rainbow tables still a threat today?

Yes, but only against systems that use unsalted, fast hashes. Many legacy systems still exist, and attackers target them. Modern systems with proper salting and slow hashing are safe.

What is a reduction function in a rainbow table?

A reduction function maps a hash (a fixed-length string) back to a new password plaintext. It is not the inverse of the hash; it is a deterministic way to pick a new password from the hash value to extend the chain.

What is the difference between a rainbow table and a hash table?

A hash table stores every password and its hash, requiring huge storage. A rainbow table stores only chain endpoints, using a time-memory trade-off that reduces storage while still allowing password recovery.

Can rainbow tables crack Windows NTLM passwords?

Yes, because NTLM hashes are unsalted. Tools like Ophcrack come with precomputed rainbow tables for NTLM and can recover many weak passwords quickly.

How large is a typical rainbow table?

A table covering all 1-8 character printable passwords for LM hash can be about 100 GB. For NTLM, a table for alphanumeric characters up to 14 characters can be over 1 TB. However, many tables are shared online for free.

Summary

A rainbow table is a precomputed data structure used to reverse cryptographic hash functions quickly, primarily for cracking passwords. It works by hashing millions of candidate passwords and storing only the starting point and ending point of chains, allowing instant lookup of a hash to find the original password. This attack is devastating against systems that store unsalted, fast hashes like MD5, SHA-1, or NTLM.

The primary defense against rainbow tables is salting, adding a random unique value to each password before hashing. When used with a slow key-stretching algorithm, salting makes precomputation impractical. IT professionals must understand this attack to design secure authentication systems, perform penetration tests, and respond to incidents.

For certification exams, rainbow tables are a core topic under threats and vulnerabilities. Candidates must differentiate them from dictionary and brute-force attacks, recognize the conditions under which they are effective, and recommend appropriate countermeasures. Common exam traps include confusing online password guessing with offline hash lookup and assuming that all hashes are equally vulnerable. Mastering this concept helps in exams like CompTIA Security+, CEH, and CISSP.