What is a Rainbow Table Attack?
In this article, you will learn about Rainbow Table Attacks. By the end of the article, you
will be able to:
- Describe how a Rainbow Table Attack works
- Describe personal and developer actions you can take to prevent Rainbow Table Attacks
Rainbow Table Attacks
Recall from earlier lessons that a hash table is a data structure connecting inputs to outputs.
In the context of password security, a hashing function transforms plain-text passwords into hashed outputs.
If these hashed outputs leak, an attacker could use a special kind of hash table, often called a
Rainbow Table, to map these leaked hashed passwords back to their plain-text versions.
How does this attack work? The attacker:
- Generates a large list of potential passwords—often starting with common or weak passwords.
- Runs each through a specific hashing function (e.g., SHA256, MD5) to get the corresponding hashed output.
- Stores both the plain-text password and its hashed output in a big table, effectively creating a
“dictionary” of input-to-output mappings.
If the attacker then obtains any leaked hashed passwords from a real database, they:
- Compare the leaked hashes against the hashed values in their Rainbow Table.
- If they find a match, they retrieve the corresponding plain-text password from the table.
- Use that plain-text password to access the user’s account.
This works because hashing functions are deterministic: the same plain-text input
always yields the same hashed output. So even though hashing is a one-way function (you can’t “reverse” the hash),
attackers use this “matching” approach to guess the original password.
How to Prevent Rainbow Table Attacks
As a developer:
- Never expose hashed passwords to the client. Rainbow Table Attacks only become
feasible if attackers can get their hands on leaked hashed passwords.
- Consider additional protections such as salting passwords, which makes guessing
or matching hashes much more difficult. You’ll learn more about salting in an upcoming lesson.
- Stay aware of hashing algorithms that are considered insecure or outdated,
and use modern, time-tested algorithms with suitable complexity.
As a user:
- Use different passwords for every website to reduce the impact if one password leaks.
- Use complex, unique passwords that aren’t easily guessable.
Simple or common passwords are prime targets for Rainbow Tables.
In 2012, LinkedIn announced that a number of hashed passwords had been leaked. This real-world example
highlights that password breaches can happen to any platform—even major ones—and underscores the importance
of proper security measures like salting and strong hashing algorithms.
What You've Learned
Rainbow Table Attacks exploit the deterministic nature of hashing functions. By comparing hashed passwords
with pre-computed tables (Rainbow Tables), attackers can potentially recover the plain-text passwords,
especially if those passwords are weak or reused.
Takeaways to remember:
- Securely store passwords on the server side (never in plain-text or exposed hashed form).
- Use salting to prevent easy matches of identical hashes.
- As a user, always use unique, hard-to-guess passwords.
By following these guidelines, you can significantly reduce the success rate of Rainbow Table Attacks
and protect both your application and your users.