A rainbow table attack is a password-cracking method that uses precomputed tables of hash values to recover plaintext passwords from stolen hashes. By matching a stolen hash to one in the table, an attacker recovers the original password without having to guess and hash every possibility.
When a password is created, the system usually stores a hash of it rather than the password itself. Hashing converts the password into a fixed-length string that can't be read directly. For example:
password123482c811da5d5b4bc6d497ffa98491e38A rainbow table attack is a precomputed lookup table that maps hash values back to plaintext passwords, using hash chains to cover far more passwords than it stores. When an attacker obtains a hashed password, they search the table for that hash. If there's a match, the original password is recovered. The technique was introduced by Philippe Oechslin in 2003.
Rainbow table attacks work for two reasons:
An attacker steals a database of hashed passwords. Without a rainbow table, they would have to guess millions of candidate passwords and hash each one to find a match. With a rainbow table, they compare the stolen hash against the table:
482c811da5d5b4bc6d497ffa98491e38482c811da5d5b4bc6d497ffa98491e38 corresponds to password123Three measures make rainbow table attacks ineffective:
Salt Your Passwords. Adding a unique random value (a salt) to each password before hashing means identical passwords produce different hashes, so a precomputed table can't match them:
password123password123+salta different hash for each saltUse slow hash functions. Algorithms such as bcrypt, scrypt and Argon2 are deliberately slow and memory-intensive, which makes building a table impractical.
Require multi-factor authentication (MFA). A recovered password alone isn't enough to log in when a second factor is required.
Because salting and slow hashing are now standard, rainbow table attacks are far less common than they used to be. But they still work against any system that stores unsalted fast hashes, which is why they remain worth understanding.
A stolen password database is only as safe as the way its passwords were hashed. Three consequences follow:
Blogs