227 points · by aparadja · 15y ago · 117 comments
1) many developers don't use salts / HMAC
2) MD5 is popular
3) hashed passwords end up on Google
From these 3 points I don't think it follows that MD5 is horrible.Any hashing function would have the same issues, simply because a hashing function is a mathematical function, so for any X from the domain of definition, H(X) will always have the same value, on every call. Therefore, if a hashing method is popular enough and developers don't salt their hashes, then hashes for common passwords will inevitably end up on Google. However, if you salt your hash calls with your own key, the hashes produced will be different from everybody else's.
The vulnerability is "not using a password hash construction", of which the best known are bcrypt and PBKDF2.
You could slap MD5 into PBKDF2 with a high iteration count and achieve comparable security. The problem is that devs often use a hash function a single time.
If you don't have a reasonable salt then you're vulnerable to time/space tradeoff attacks like rainbow tables/etc.
Also, in case you haven't used it. Scrypt is pretty damn awesome. It's designed to be memory hard, which makes it very hard to crack even with GPUs.
"Huge" being the key word here.
Try searching for the md5sums of arbitrary 8-character alphanumeric passwords. You won't find many results. 62^8 is a big number.
The currently available databases are surprisingly large, even if not in the scale of 62^8. Consider a random pick from decrypt.fr: "phytostrote972". It's far from a random string, but not exactly a trivial one either.
8-character alphanumeric are the ones that are being offered today, it's only going to go up as GPUs get better and HD space/bandwidth increases.
Hence the current advice is to use "alongpassphraseasyourpassword" rather than "L33$Pa55wd"
The solution is to pick a better algorithm and learn how to use it securely. That probably won't happen unless all the ridiculous PHP 'security' tutorials are erased from the history of the internet and only correct methods are shown.
If using MD5 is all you do, you'd still be
susceptible to brute force attacks.
Only if you know the algorithm and salt used (i.e. your source code is also compromised, not just your database).Otherwise, demonstrate to me how you can find the passwords that relate to these hashes (all of them use the same salt):
23C206503ABD36FCB575FC8F12791CF0
D82BDB4160F60B657D6F994B553D2E63
0DA0572E042F822F91772F14269548E6
CB8BF6C16029400885F9A68A17576FA7
7CE4F679810409CF1477CF142B481EF9
It should be easy, right?You use a salt so that time/space tradeoff attacks are no longer viable. All you need to do is provide a few bits (say 20) of entropy to make them infeasable.
There's always a lot of whining and complaining about how {crappyhash} algorithm is bad and how salts don't matter but not a lot a of {dothisinstead}.
It did however get a password that I use regularly (though not anymore) which I though was pretty complex.
So, friends with "idiot" passwords 1. Their so called computer-expert mate (me) 0.
I'm not so smug anymore.
We inherited a system, without inheriting the administrator passwords, that we had to work on. It was a spaghetti mess, so creating a new account didn't seem obvious, and I wasn't sure how the passwords were hashed, but they did seem md5-like to me, so I googled one.
Turns out, 90% of them, including most of the admin passwords, were just four numeric characters, like 9678.
What's actually wrong with bcrypt that prevents people from using it? Is it not available on all platforms? Too computationally expensive?
wordlist = response.split(/\s+/)
Thank God I use spaces liberally in my passwords.(If I had a dollar for every time the 'emailaddress+foo@gmail.com' failed to validate....)
Can we find these people and just let them know?
I use MD5 all the time, just not for security.
http://stackoverflow.com/questions/1581610/how-can-i-store-m...
I think we need more code examples of how to do things right, because that code is very, very wrong.
Shock and horror when geeks meet the real-world. Yes, I know.
http://blog.jgc.org/2009/05/can-you-trust-37signals-with-you...
That means they're both md5-hashed on the wire and in the database.
Bozo's idea was to show that unsalted MD5 is, for most passwords, as bad as no encryption at all. An attack doesn't get much easier than a lookup table.
See this script more as a fun little hack rather than a "Formal proof". Thanks aparadja for sharing. That being said, using MD5 without salt is asking for trouble. I mean, I know security is usually just a time vs $ vs quality problem, but it costs almost nothing more to add a salt in front of the password. Why not do it?
Using SHA256 with a salt is asking for trouble.
Use bcrypt, scrypt, or PBKDF2. Do not DIY your password hash.
1. http://www.postgresql.org/docs/current/static/pgcrypto.html
For instance, I've got lots of password with over 20 characters mixed with upper/lower cases with a few symbols in it. (i.e. Seems hard but: phzb0xis@mynickname.on.hackernews.com is already pretty long and hard to crack but still easy for me to type/remember), btw that is not my password ;) I wonder if I encrypt that with MD5.. Could it be contained in a rainbow table somewhere?
Your search - 822d6c6e12b26dd30161967354aa4302 - did not match any documents.
If somebody got read-level access to your password hashes, it follows (based purely on the assumption that any app with the rights to read the hash will probably have the right to change it when applicable) that one could simply overwrite the password hash with a new one that is already known, gain unauthorized access, and change the hash back to prevent the user from finding out. Unless you really need that password to crack multiple accounts that might be reusing it, it seems unnecessary. (And honestly I wouldn't care to implement these special password hashes just to protect extraneous accounts of my customers which I don't control)
edit I should clarify that while I agree that expensive compute time for password hashes helps prevent the ultimate compromise of a user's password, I find it a much more worrisome prospect that somebody got access to the database in the first place. To me, a person's password strength is almost irrelevant compared to the importance of preventing brute-force attacks on a login API or ensuring the integrity of the password database and db apps.
That being said, for those wishing to implement a bcrypt-type hash:
perl -le'print crypt("something", "\$2a\$random")'
should give you blowfish-encrypted password hashes on systems with it patched into glibc. ("6" instead of "2a" for SHA-512)They protect the (majority of) users that re-use passwords on multiple services, and, more importantly, they protect you from the PR shitstorm of having dumps of cracked passwords posted to Pastebin after a compromise.
Also, a note to anyone reading the above post, that is not how bcrypt works and is incredibly insecure.
Edit: I'm trying to illustrate the general principle, that you shouldn't take any action thats visible outside your secure perimeter, that depends on knowledge of your password.
What you define as 'outside the perimeter' depends. In the case of your corporate systems, its probably everything outside the corporate network. In the case of your gmail password, its everything outside of [your computer, the SSL connection to google's auth servers, and those servers].
You shouldn't ever leak any information outside that perimeter, that reveals knowledge of your password.
Its generally pretty hard to steal the password hash; if you start revealing what your password hash is to someone doing passive analysis, you compromise a lot.
If its worth thinking about poisoning hashes to protect, then don't try and poison the hashes!
The first result when I searched the hash for superman (84d961568a65073a3bcf0eb216b2a576) was a link to a page titled literally "Google Hash: md5(superman) = 84d961568a65073a3bcf0eb216b2a576", the page is hosted at(http://www.nth-dimension.org.uk/utils/ghash.php), basically someone's gone through the trouble of making a rainbow table that's easily crawlable that makes this method of lookup via Google even easier.
The page has a description:
> Google Hash is a PoC implementation of an hash search engine using Google.
> Unlike other implementations, the aim here is to get Google to store the
> word and associated hash. We do this by putting them into the title where it
> will always be stored by Google's spider....
The next top hit is md5rainbow.com etc. etc.
I would guess that most of the positive results from BozoCrack.rb are thanks these sites.(Source: http://codahale.com/how-to-safely-store-a-password/)