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:

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:

  1. Generates a large list of potential passwords—often starting with common or weak passwords.
  2. Runs each through a specific hashing function (e.g., SHA256, MD5) to get the corresponding hashed output.
  3. 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:

  1. Compare the leaked hashes against the hashed values in their Rainbow Table.
  2. If they find a match, they retrieve the corresponding plain-text password from the table.
  3. 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:

As a user:

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:

By following these guidelines, you can significantly reduce the success rate of Rainbow Table Attacks and protect both your application and your users.