Enough With The Rainbow Tables: What You Need To Know About Secure Password Schemes
Sep 7, 2007 at 5:20PM
Thomas Ptacek The socialbookmarkosphere is abuzz with talk of “rainbow tables”, what they mean for password security, and why they prove that Microsoft did a shoddy job of securing Windows for Workgroups 15 years ago. This really freaks me out. If the “advanced” pole of your threat model is “rainbow tables”, stop working on your social shopping cart calendar application right now: I can’t trust you with my Reddit karma score, let alone my credit card number.
.
To begin, password storage 101: servers don’t usually store actual passwords. Instead, they hash the password, store the hash, and discard the password. The hash can verify a password from a login page, but can’t be reversed back to the text of the password. So when you inevitably lose your SQL password table, you haven’t exposed all the passwords; just the crappy ones.
Now let’s re-explain rainbow tables:
take a “dictionary” —- say, of all combinations of alphanumerics less than 15 characters
hash all of them
burn the results onto a DVD.
You now have several hundred billion hash values that you can reverse back to text —- a “rainbow table”. To use,
take your stolen table of hashes
for each hash
find it in the rainbow table.
If it’s there, you cracked it.
.
Here’s what you need to know about rainbow tables: no modern password scheme is vulnerable to them.
Rainbow tables are easy to beat. For each password, generate a random number (a nonce). Hash the password with the nonce, and store both the hash and the nonce. The server has enough information to verify passwords (the nonce is stored in the clear). But even with a small random value, say, 16 bits, rainbow tables are infeasible: there are now 65,536 “variants” of each hash, and instead of 300 billion rainbow table entries, you need quadrillions. The nonce in this scheme is called a “salt”.
Cool, huh? Yeah, and Unix crypt —- almost the lowest common denominator in security systems —- has had this feature since 1976. If this is news to you, you shouldn’t be designing password systems. Use someone else’s good one.
.
No, really. Use someone else’s password system. Don’t build your own.
Most of the industry’s worst security problems (like the famously bad LANMAN hash) happened because smart developers approached security code the same way they did the rest of their code. The difference between security code and application code is, when application code fails, you find out right away. When security code fails, you find out 4 years from now, when a DVD with all your customer’s credit card and CVV2 information starts circulating in Estonia.
.
Here’s a “state of the art” scheme from a recent blog post on rainbow tables and salts:
hash = md5('deliciously-salty-' + password)
There are at least two problems with this code. Yeah, the author doesn’t know what a salt is; “deliciously-salty-” is not a nonce (also, Jeff, your computer really doesn’t care if you seperate the password from the nonce with a dash; it’s a computer, not a 2nd grade teacher).
But there’s a much bigger problem with this code: the letters “md5”.
Two reasons.
1.
You’re expecting me to go off on a rant about how there is no redeeming quality to justify using MD5 in 2007. That’s true (MD5 is broken; it’s too slow to use as a general purpose hash; etc). But that’s not the problem.
2.
The problem is that MD5 is fast. So are its modern competitors, like SHA1 and SHA256. Speed is a design goal of a modern secure hash, because hashes are a building block of almost every cryptosystem, and usually get demand-executed on a per-packet or per-message basis.
Speed is exactly what you don’t want in a password hash function.
Modern password schemes are attacked with incremental password crackers.
Incremental crackers don’t precalculate all possible cracked passwords. They consider each password hash individually, and they feed their dictionary through the password hash function the same way your PHP login page would. Rainbow table crackers like Ophcrack use space to attack passwords; incremental crackers like John the Ripper, Crack, and LC5 work with time: statistics and compute.
The password attack game is scored in time taken to crack password X. With rainbow tables, that time depends on how big your table needs to be and how fast you can search it. With incremental crackers, the time depends on how fast you can make the password hash function run.
The better you can optimize your password hash function, the faster your password hash function gets, the weaker your scheme is. MD5 and SHA1, even conventional block ciphers like DES, are designed to be fast. MD5, SHA1, and DES are weak password hashes. On modern CPUs, raw crypto building blocks like DES and MD5 can be bitsliced, vectorized, and parallelized to make password searches lightning fast. Game-over FPGA implementations cost only hundreds of dollars.
Using raw hash functions to authenticate passwords is as naive as using unsalted hash functions. Don’t.
.
What is the state of the art here?
1.
First, what your operating system already gives you: a password scheme “optimized” to be computationally expensive. The most famous of these is PHK’s FreeBSD MD5 scheme.
The difference between PHK’s scheme and the one you were about to use for your social shopping cart 2.0 application is simple. You were just going to run MD5 on a salt and a password and store the hash. PHK runs MD5 for thousands of iterations. That’s called “stretching”.
PHK’s MD5 scheme is straightforward to code and comes with Linux and BSD operating systems. If you have to choose between the PHP code you have now and PHK’s scheme, you choose PHK’s scheme or you fail your PCI audit. [∗]
2.
The best simple answer is “adaptive hashing”, which Neils Provos and David Mazieres invented for OpenBSD in 1999. Their original scheme is called “bcrypt”, but the idea is more important than the algorithm.
There are three big differences between Provos-Mazieres and PHK’s scheme:
Bcrypt was invented by two smart guys and PHK’s was only
invented by one smart guy. That's literally twice the smart.Bcrypt uses Blowfish instead of MD5. Blowfish is a block cipher with a notoriously expensive setup time. To optimize Blowfish to run much faster, you’d have to contribute a major advance to cryptography. We security practioners are all “betting people”, and we usually like to place our bets on the side that “demands major advances in cryptography”.
Provos and Mazieres extended Blowfish. They call theirs
takes even longer than Blowfish. How long? Your call. You can make a single password trial take milliseconds, or you can make it take hours."Eksblowfish". Eksblowfish is pessimized: the setup time
Why is bcrypt such a huge win? Think of the problem from two perspectives: the server, and the attacker.
First, the server: you get tens of thousands of logins per hour, or tens per second. Compared to the database hits and page refreshes and IO, the password check is negligable. You don’t care if password tests take twice as long, or even ten times as long, because password hashes aren’t in the 80/20 hot spot.
Now the attacker. This is easy. The attacker cares a lot if password tests take twice as long. If one password test takes twice as long, the total password cracking time takes twice as long.
Get it?
The major advantage of adaptive hashing is that you get to tune it. As computers get faster, the same block of code continues to produce passwords that are hard to crack.
3.
Finally, as your attorney in this matter, I am required to inform you about SRP.
SRP is the Stanford Secure Remote Password protocol. It is a public key cryptosystem designed to securely store and validate passwords without storing them in the clear or transmitting them in the clear.
That design goal is cooler than it sounds, because there’s usually a tradeoff in designing password systems:
You can store a hash of the password. Now if you lose the password database, you haven’t exposed the good passwords. However, you also don’t know the password cleartext, which means that to validate passwords, your customers need to send them to you in the clear.
You can use a challenge-response scheme, where both sides use a math problem to prove to each other that they know the password, but neither side sends the password over the wire. These schemes are great, but they don’t work unless both sides have access to the cleartext password —- in other words, the server has to store them in the clear.
Most practitioners will select the hashing scheme. Both attacks —- stolen databases and phished passwords —- happen all the time. But stolen databases compromise more passwords.
SRP resolves the tradeoff. It’s an extension of Diffie-Hellman. The salient detail for this post: instead of storing a salted password hash, you store a “verifier”, which is a number raised to the (obviously very large) power of the password hash modulo N.
If you understand DH, SRP is just going to make sense to you. If you don’t, the Wikipedia will do a better job explaining it than I will. For the test next Wednesday, you need to know:
SRP is related to Diffie-Hellman.
SRP is a challenge-response protocol that lets a server prove you know your password without your password ever hitting the wire.
SRP doesn’t require you to store plaintext passwords; you store non-reversable cryptographic verifiers.
“Cracking” SRP verifiers quickly would involve a significant advancement to cryptography.
SRP is simple enough to run out of browser Javascript.
Awesome! Why aren’t you using SRP right now? I’ll give you three reasons:
SRP is patented.
To make it work securely in a browser, you have to feed the login page over SSL; otherwise, like Meebo, you wind up with a scheme that can be beaten by anyone who can phish a web page.
SRP is easy to fuck up, so the first N mainstream Rails or PHP or Pylons SRP implementations are going to be trivially bypassable for at least the first year after they’re deployed.
.
We learned that if it’s 1975, you can set the ARPANet on fire with rainbow table attacks. If it’s 2007, and rainbow table attacks set you on fire, we learned that you should go back to 1975 and wait 30 years before trying to design a password hashing scheme.
We learned that if we had learned anything from this blog post, we should be consulting our friends and neighbors in the security field for help with our password schemes, because nobody is going to find the game-over bugs in our MD5 schemes until after my Mom’s credit card number is being traded out of a curbside stall in Tallinn, Estonia.
We learned that in a password hashing scheme, speed is the enemy. We learned that MD5 was designed for speed. So, we learned that MD5 is the enemy. Also Jeff Atwood and Richard Skrenta.
Finally, we learned that if we want to store passwords securely we have three reasonable options: PHK’s MD5 scheme, Provos-Maziere’s Bcrypt scheme, and SRP. We learned that the correct choice is Bcrypt.
This blog post was brought to you in part by a grant from the Jon M. Olin Foundation. Major underwriting for Matasano Chargen is provided by Archer Daniel Midland Company. ADM: Feeding A Hungry World. And of course, readers like you!
[∗] Disclaimer: I cannot actually flunk your PCI audit.


Reader Comments (100)
Are you sure Estonia is the best choice for the "random 3rd world shithole where the population feeds themselves by commiting crime" when it's the country that came up with Skype, will have 100 Mb/s fiber connection available to every resident by 2015 and is the location of NATO's cyber security center of excellence?
Why do you assume that he meant Estonia was a "random 3rd world shithole where the population feeds themselves by commiting crime"?
Is it not just as conceivable that he meant "a random country with the technological capabilities to perpetuate this sort of attack"?
Go get a bandaid for your butthurt.
Good article. But one nit. You said
and later mentioned
Of course, if cracking your password scheme exposes CVV2 values, then you ought to have already failed your PCI audit for storing CVV2 at all.
You should check out PKCS#5 PBKDF2, it is a standardized, iterative, salted password-to-key function which improves on what you describe. See http://en.wikipedia.org/wiki/PBKDF2
/Simon
I definitely love your own posting style, very interesting. don’t give up and also keep posting as it just simply that is worth to read it,excited to looked over far more of your articles, have a good one
Small Corner Computer Desk
Cheap Life Assurance Quote
Dolce and Gabbana Sunglasses
Female Hair Transplant
Hair Loss Solutions
Disney Minnie Mouse
I never knew that these password schemes can accommodate phishing. Anyhow, our password cannot even be safe in one way or another as what you have said. Hope that we will not be fooled by password scams over the internet and maintain the lifetime health security of our passwords.
Thank your for that post but I still don't understand something :
bcyrpt is not a hashing method, it's an encryption system right ?
So you still need to use a password to use it and if this password is found (which is as possible as to access your database), the attacker has access to all your password in clear text.
Where am I wrong ?
Excellent Article! Thanks very much for the info, and I will be writing my own (admittedly simplified) article on this shortly. As for my professional works, I will be taking your advice and "standing on the shoulders of giants," so to speak.
jackey
We learned that if it’s 1975, you can set the ARPANet on fire with rainbow table attacks. If it’s 2007, and rainbow table attacks set you on fire, we learned that you should go back to 1975 and wait 30 years before trying to design a password hashing scheme.Replace the bath
Ok, adding the extra brackets help, but should not be needed since arithmetic precedence was enabled.
I just sent this post to a bunch of my friends as I agree with most of what you’re saying here and the way you’ve presented it is awesome.
Thanks to this site I got some information...roulette en ligne
Just gone through your blog and found it wonderful. It was nice going through your blog. keep on posting.
People usually say :"Seeing is believing." GHD Each attempt has a corresponding gain, in part or obvious, or vague. At least we have the kind of satisfaction After I bought this watch ,in a sense,it means a great deal to me. net a porter thank you!it is very useful tools to protect our time.If you never pay attention to yourself ,please grasp this chance.a few days ago,I bought a Rolex watches.IT's very good to use.So i want to write an article about watches to share with everyone on So as to more and more people to konw it. UGG brand is relatively common, in addition to the Rolex ping g15even see watch on the movement and you don't know.
Rolex watches
People usually say :"Seeing is believing." GHD Each attempt has a corresponding gain, in part or obvious, or vague. At least we have the kind of satisfaction After I bought this watch ,in a sense,it means a great deal to me. net a porter thank you!it is very useful tools to protect our time.If you never pay attention to yourself ,please grasp this chance.a few days ago,I bought a Rolex watches.IT's very good to use.So i want to write an article about watches to share with everyone on So as to more and more people to konw it. UGG brand is relatively common, in addition to the Rolex ping g15even see watch on the movement and you don't know.
Rolex watches
It's not so simple to bring a excellent written buy essays, especially if you are occupied. I consult you to set buy custom essay papers and to be free from distrust that your work will be done by paper writing services.
You may have not intended to do so, but I think you have managed to express the state of mind that a lot of people are in. The sense of wanting to help, but not knowing how or where, is something a lot of us are going through.
You know that you could have a good job in dissertation writing or writing service, just because some students really want to write the superior fact just about this good post or buy thesis and they buy research papers online.
passwords should be protective.
The one following on the heels of lv bags is Louis Vuitton Monogram Canvas Tivoli GM. This cheap louis vuitton bags applies wrinkled Monogram canvas with the appearance like the bowling bag. It is finished with retaining screws at the bottom. Being so soft, it is particularly suitable for daily use. It can be carried on the shoulder or handheld. This lv bag was named after a well-known town of Lazio region of Italy.
if you want to be rich and famous click on casino en ligne
Umbrellas and wet tissues would aswell add to the absolute weight of the louis vuitton handbag
. As with the things that would go into the louis bag
, the louis bags
would aswell accept some added weight.
As scientific study show that a person’s life, not less than 1 third are situated in a various sports such as running and play basketball.As this, wearing a comfortable pair of air max shoes to exercise is significant.The my-nikeshoes.com online store have many kinds of nike max shoes,this nike air max shoes are all high quality but low price.If you a female,you may consider womens air max 2009,womens air max 2010,womens air max 90,womens air max classic BW,womens air max 95,womens air max ltd,womens air max 2012,womens air max 87,womens air max 97.If you are a kid,you can think out kids air max 90,kids air max classic BW,if you are a man,you can think over nike air max 180,nike air max 2009,nike air max 2010,nike air max 2012,nike air max 87,nike air max 90,nike air max 91,nike air max 93,nike air max 95,nike air max BW,nike air max ltd,nike air max TN,these nike air shoes are all breathable and durable.The most important thing is to wear comfortable, not to hurt the feet. Otherwise, if shoes aren't appropriate, makers a foot in numerous respects, the impact of internal organs, affecting appetite, skin, and a number of other health challenges. air max 2009 nike and air max 90 nike are developed for tourism,sports activities footwear,its technical content within the footwear. Plus a foot inside the movement,will do lots of friction and contact,not the excellent footwear can conveniently affect the comfort of your feet.For that reason,in motion to wear a pair of comfy,scientific,suitable sports activities footwear,it's rather incredibly fundamental. If you may possibly be a expert athlete, the system nike air max and acquire a perfect musculature.Actually, apart from as a trainer for running the boundary line of womens air max, who also has a taste of Fashion, or even enhance the functionality of style. The air max 2009 has made some major progress in terms of righting the air max. Although the classic Air Max models as air max 95,air max BW,air max 90 continue to sell, many of the newer designs have struggled to catch on. The air max tailwind 2010 and nike air max tailwind got off to a good start, impressing a lot of people with its sleek design and heavy use of Flywire technology. With its innovative lightweight construction and sleek look, the air max 2010 has definitely made the statement that there is plenty to still get excited about when it comes to the continuation of the air max nike legacy. The shoes still sports the same basic design, but the upper is simplified, using a mesh and leather upper with EVA outsole and tongue branding.nike kobe shoes, nike air max lebron vii shoes and nike lebron vii low shoes,nike air max lebron vii low shoes maintains a similar look to the prior versions by using a stitching pattern on the side of the upper that follows the same design as the crossed Flywire.kobe v shoes and nike lebron james vii PS shoes is the 2010 new designed specfically for LeBron's second season,Inherited air max lebron vii shoes advantages, and added many new technologies.The nike lebron vii PS shoes is very best suit to play basketball.If you are a Lebron fan,buy lebron vii PS are your best choice.Welcome to visit our online store.
I bought my Breitling Navitimer about 7 years ago and wear it nearly everyday. Despite wearing Breitling Avenger nearly every day, having gone diving with Chrono Superocean , kiteboarded with it, and trekked across Australia, Scandinavia and the Far East, Breitling Aeromarine looks as good today as the day I bought it.
Though, the second is still a respectable choice if these women are picking the Christian Louboutin from a reputed dealer. Like purchasing a Christian Louboutin Pumps form a store round the corner would not mean that folk would be footed by the fake red signature sole. The over all look of the footwear wouldn't let folk to take a second to gauge that one is wearing a poor imitation. Choosing the right Christian Louboutin Boots would not only make one look nice but at the same time would talk rather a lot about the social position of the lady wearing Christian Louboutin Sandals .
The christian audigier are the in thing and real fashion oriented. If you are looking for shades that draw attention then hardy shirt are the ones for you. The styles hardy shirts are very flashy with all of the stones and the tattoo designs look very nice. Women and Men are both drawn to hardy shirts stylish shades.
watch twilight eclipse online
watch twilight eclipse online
http://watch-eclipse-online.net