logo

Rainbow Table Attacks: How They Work and How to Defend Against Them

Introduction

Overview of Password Attacks in Cybersecurity

Many common password attack methods are quite straightforward — much like trying various physical keys to open the lock on a door. For example, in brute force attacks, adversaries systematically guess passwords until they find the correct one. Or instead of simply guessing, they can use a list of username/password combinations leaked from other breaches (credential stuffing) or cycle through known usernames combined with commonly used passwords (password spraying).

But hackers also have more sophisticated option: Rather than trying every key, they can pick the lock. With rainbow table attacks, they aim to exploit vulnerabilities in the password protection infrastructure itself. It’s a more advanced way for to break into user accounts, and it’s often much faster to boot.

Definition and Purpose of Rainbow Table Attacks

When a user creates a password, it gets turned into a hash, which is a fixed-length string that looks nothing like the original (plaintext) password. Hashing passwords helps keep them secure because there is no reverse algorithm to determine plaintext passwords from their hash values.

A rainbow table attack in cyber security exploits another core feature of hashing: A hashing algorithm will always yield the same hash for a given user password. Therefore, malicious actors can create lists of commonly used passwords and compute their hashes to create rainbow tables. Then, if they can get their hands on a company’s database of hashed passwords, they can simply look for each of the hashed values in their rainbow tables. If they find a match, they instantly know the corresponding plaintext password. This approach requires far less time and computational resources than cracking passwords.

Understanding Hashing and Its Role in Security

What Is Hashing?

Hashing is the process of converting input data (such as a plaintext password) into a fixed-size string of characters through a mathematical algorithm. It is commonly used to protect passwords, digital signatures and other sensitive information.

How Hash Functions Work

A hash function transforms input data, regardless of length, into a unique, fixed-length output string. This digital fingerprint appears to be completely unrelated to the original data. Even minimal changes to the input will yield substantial variations in the resulting hash. However, the same input always yields the same hash.

Why Hashing Is Vulnerable to Rainbow Table Attacks

Legacy hashing algorithms are particularly vulnerable to rainbow attacks because the hashes they create are easy to predict. Later in this article, we discuss effective strategies for reducing risk, including using techniques like salting to make rainbow tables less effective and adopting multifactor authentication to thwart attackers who do manage to discover plaintext passwords.

How Rainbow Table Password Attacks Work

Generation and Structure of Rainbow Tables

Rainbow tables are large databases that contain pairs of plaintext passwords and their corresponding hash values. Having a precomputed rainbow table makes it quite simple to determine plaintext passwords:

  1. An attacker obtains a database of password hashes from a compromised system.
  2. The attacker runs a program that attempts to match each hash value against their rainbow table.
  3. If a given hash is not found, the program applies a reduction function and searches again. This process is repeated until a match is found.
  4. The original password is then retrieved.

Differences Between Brute Force Attacks and Dictionary Attacks

In a brute force attack, an adversaries attempts to log on to a system by simply guessing many different possible username/password combinations. A dictionary attack is a specific type of brute force attack that uses words from the dictionary as candidate passwords. These types of attacks are relatively easy to carry out and do not depend on the hashing techniques in use. However, it is relatively easy for defenders to spot them, and many organizations follow the best practice of locking accounts after a certain number of failed logon attempts to thwart brute force attacks.

A rainbow table attack, on the other hand, involves stealing a database of hashed passwords and attempting to match them against a table of common password hashes. A key advantage is that once the password database has been stolen, there is no activity in the victim’s network for defenders to detect. However, rainbow tables take time to generate and require significant storage space.

Note that all these attacks work best against weak and common passwords because they are the ones attackers focus on, whether they are performing a brute-force attack or generating a rainbow table.

Examples of Rainbow Table Attacks

Rainbow table attacks are nothing new. One of the more famous incidents involving them occurred back in 2012: Attackers stole password hashes from LinkedIn, leading to the compromise of 6.5 million user account credentials that were later posted on a Russian password forum.

Hypothetical attack scenarios include the following:

  • Hackers use network sniffing tools to intercept insecure password hashes being transmitted between the servers hosting an e-commerce platform. Using a rainbow table, they decode the plaintext passwords and use them to access customers’ accounts and steal their personal information.
  • An attacker exploits a poorly secured web application to steal password hashes, which were generated using outdated hashing methods. They use a rainbow table to decrypt all the passwords and enter the corporate network.

Comparing Rainbow Table Attacks with Other Password Cracking Methods

Rainbow Table vs Dictionary Attack

Rainbow Table AttackDictionary Attack
Uses precomputed hash-password mappingsUses predefined word lists
Primarily used for offline attacks on leaked or stolen password databasesCan be used for both online and offline attacks
Limited by the algorithm used to generate the password hashesHighly customizable; wordlists can include common passwords, patterns, or user-specific terms
Requires significant storageLess storage-intensive


Rainbow Table vs. Brute Force Attack

Rainbow Table AttackBrute Force Attack
Attempts to match each stolen password hash against a precomputed list to determine the corresponding plaintext passwordAttempts to guess a password by systematically trying various combinations of characters, numbers and symbols
Highly effective against unsalted hashes of any complexityGuaranteed to find the password eventually, but may take an impractical amount of time
Trades computation time for storage spaceRelies entirely on computational power
Easily defeated by salting passwordsMitigated by strong passwords, account lockouts and limiting the rate of password attempts

Unique Characteristics of Rainbow Table Attacks

  • Generating rainbow tables requires extensive upfront computational resources and time investment.
  • Rainbow tables are specific to a particular hashing algorithm (e.g., MD5, SHA-1).
  • Rainbow table attacks are less effective against modern salting techniques.
  • Rainbow tables are not suitable for real-time password cracking attempts.

Key Motivations and Common Targets of Rainbow Table Attacks

Why Attackers Use Rainbow Tables

The key reason why attackers continue to use rainbow tables is that many organizations still have legacy systems that are highly vulnerable to them. Moreover, this attack method can uncover plaintext passwords significantly faster than brute force methods.

While building rainbow tables takes significant time and effort, the tables can be used for multiple attacks on different systems, provided the same hashing algorithm is used. This makes the one-time investment quite cost effective in the long run. In addition, once plaintext passwords are uncovered, they can be used in credential stuffing attacks on other popular web platforms and services.

Systems and Situations Prone to Rainbow Table Attacks

Organizations are most vulnerable to rainbow table attacks if they have any of the following:

  • Legacy applications that still use outdated and weak hashing algorithms like MD5 or SHA-1 without salting
  • Systems with weak password policies that allow default, common or easy to predict passwords, which are more likely to be included in precomputed rainbow tables
  • Platforms where users frequently reuse passwords, such as email and social media
  • Databases that do not use segmented password storage and have weak protection measures
  • Active Directory accounts that use outdated NTLM hashing algorithms

Risks and Consequences of Rainbow Table Attacks

A rainbow table attack can have catastrophic consequences. Once the attackers have plaintext passwords in hand, they can use them to gain a foothold in the network and move laterally to extract confidential data, deploy ransomware and disrupt operations. The full impact can include:

  • Downtime of websites and other critical systems that results in frustrated customers and lost revenue
  • Expensive forensics investigations and system restoration
  • Lasting damage to the organization’s reputation and brand image, and erosion of customer trust
  • Costs of public relations campaigns along with credit monitoring and other services for users whose data was breached
  • Expenses for legal action brought by individuals affected in the breach
  • Stiff penalties for non-compliance with data protection regulations such as GDPR, CCPA or HIPAA

Preventing Rainbow Table Attacks

Password Salting: How it Works and Its Importance

One of the most effective measures for defending against rainbow table attacks is to use password salting. This practice involves adding a unique, random string (called the salt) to each password before hashing it.  Since each password gets a unique salt, even if two users choose the same password, they will have different hash values — making rainbow tables impossible to build.

For example, suppose a user chooses password123 as their password. (Note that this is only an example; a good password tool will block this password from being used.) The system adds a salt of A1B2C3 and hashes the resulting string (password123A1B2C3).

Then another user chooses the same password, password123. The system adds a salt of Q7T4M9 and hashes the resulting string (password123Q7T4M9) — yielding a completely different hash for the same plaintext password.

Use Secure Hashing Algorithms

Modern hashing algorithms introduce computational complexity that requires more resources and time to crack. Hashing algorithms such as bcrypt, Argon2 and scrypt make it difficult for attackers to precompute tables of hashes or to run parallelized brute-force attacks.

Regularly Update Hashing Algorithms and Other Security Protocols

Hashing algorithms and other security protocols are constantly being improved. To reduce risk, transition to the latest options as soon as possible. After upgrading hashing algorithms, remember to rehash all stored passwords during the next user login or password change.

Building a Broad Defense Against Password-based Attacks

The following best practices will help defend against not only rainbow table attacks but other types of password attacks.

Implement Strong Password Policies

Requiring strong passwords increases the difficulty of password compromise across all attack vectors. Long and unique passwords reduce the likelihood of overlapping hashes even without salting, and they are unlikely to be included in the lists used in brute-force attacks.

Follow current password best practices, such as those from NIST, regarding passwords length and complexity. Adopting a password manager will make it easy for users to adhere to your policy and create a strong, unique password for each account.

Use Multifactor Authentication (MFA)

MFA requires users to provide two or more forms of verification to access an account. Often this is a traditional username/password combination plus a one-time code, a security key or biometric data such as a fingerprint.

With MFA in place, even if an attacker manages to learn a user’s plaintext password using a rainbow table or by guessing, they will be blocked because they are unable to provide the second authentication factor.

Follow Server and Network Security Best Practices

More broadly, it’s important to reduce the attack surface of your exposed systems. Key best practices include:

  • Strictly limiting access to servers and sensitive data
  • Establishing a rigorous patch management process to update systems and fix vulnerabilities
  • Using encryption to safeguard data both at rest and in transit
  • Using network segmentation to prevent attackers or malware from expanding into more sensitive areas
  • Performing regular security audits and penetration testing

How Netwrix Can Help

Visibility and control are crucial for securing your digital environment, and Netwrix offers advanced capabilities in both areas. Netwrix solutions enable organizations to proactively reduce their attack surface, continuously monitor activity across the infrastructure from cloud to data center, and get real-time alerts on potential threats to enable efficient investigation and prompt response.

In particular, Netwrix solutions can dramatically reduce your risk from password-based attacks by:

  • Securing your password databases and monitoring activity around them
  • Replacing highly privileged credentials with just-in-time access
  • Enabling strong password policies and providing a password manager that makes it easy for users to comply with those policies
  • Monitoring for signs of brute force attacks and automatically shutting them down
  • Baselining normal user behavior and alerting on anomalies that could indicate account compromise

FAQ

What is a rainbow table attack?

A rainbow table attack is a technique used to crack hashed passwords. Once attackers have obtained hashed passwords, they attempt to match those stolen hashes to entries in a rainbow table, which map common plaintext passwords to their hash values. This method is faster than brute force attacks but is effective only against systems that use unsalted hashes or weak hash algorithms

What is the difference between brute-force attack and rainbow table attacks?

In a brute force attack, hackers systematically try possible username/password combinations to log on to a system in real time. In a rainbow table attack, adversaries work offline, trying to match stolen password hashes against a table that lists the precomputed hash values of common plaintext passwords.

How do you protect against rainbow table attacks?

There are a number of effective measures you can take to protect against rainbow table attacks:

  • Use password salting to add unique random data to each password before hashing.
  • Implement strong hashing algorithms.
  • Use password policies to require strong passwords.
  • Consider passwordless authentication to eliminate the risk of password-based attacks altogether.

What is the best defense against rainbow table attacks?

The best way to defend against rainbow table attacks is to use salted hashes. A salt is a unique, random value that is added to a password before hashing, rendering precomputed tables ineffective.

It is also important to transition to modern hashing algorithms that are computationally intensive, adopt strong password policies and implement multifactor authentication (MFA).

What is an example of a rainbow table?

A rainbow table maps common plaintext passwords to their corresponding hashed values using a particular hash algorithm. For example, a table might include the following rows:

Plaintext PasswordHashed Value
12345678e10adc3949ba59abbe56e057f20f883e
qwertyd8578edf8458ce06fbc5bb76a58c5ca4

How do rainbow table attacks work?

Rainbow table attacks rely on the fact that a basic hashing algorithm will always yield the same hash for a given input string. This enables hackers to build a rainbow table that lists common plaintext passwords and their corresponding hashes. When they obtain hashed passwords, they simply look for them in the rainbow table. If a match is found, the corresponding plaintext password is revealed.

Note that this type of attack is effective only against unsalted hashes or systems using outdated hash algorithms.

What is a dictionary attack vs rainbow table attack?

A rainbow table attack vs dictionary attack can be explained as follows: In a dictionary attack, a hacker systematically attempts to authenticate using a list of common words and phrases found in a dictionary. It is relatively simple to implement and requires minimal storage.

In a rainbow table attack, attackers steal password hashes and then see if those hashes appear in their precomputed rainbow table, which lists common plaintext passwords and their corresponding hashes. This approach consumes considerable prep time but enables rapid password recovery with minimal real-time processing. Rainbow tables are primarily used for offline attacks on leaked password databases.

Dirk Schrader is a Resident CISO (EMEA) and VP of Security Research at Netwrix. A 25-year veteran in IT security with certifications as CISSP (ISC²) and CISM (ISACA), he works to advance cyber resilience as a modern approach to tackling cyber threats. Dirk has worked on cybersecurity projects around the globe, starting in technical and support roles at the beginning of his career and then moving into sales, marketing and product management positions at both large multinational corporations and small startups. He has published numerous articles about the need to address change and vulnerability management to achieve cyber resilience.