News for hackers. Stuff that matters.
Re:One way to fix your rubbish password database by healsdata on Friday June 08, 2012 @08:55AM (#4083915)
Is there a security disadvantage to taking the MD5 hashes you already have and running those through bcrypt? It seems like that would let you get to a salted bcrypt implementation in one day as opposed to waiting for all your users to log in. Perhaps you could do the mix (md5 + bcrypt) until the user logs in and then switch them solely to bcrypt?
Re:One way to fix your rubbish password database by tptacek on Friday June 08, 2012 @09:03AM (#4083938)
No. I don't believe there's any disadvantage to this. An MD5 hash is a 128 bit random number; it's 16 fully random characters, better than almost any human password.
Re:One way to fix your rubbish password database by tedunangst on Friday June 08, 2012 @09:36AM (#4084076)
Pedantically, it's 16 random bytes. You aren't going to lose much entropy from an upper/lower/number password unless it's at least 20 characters, or even longer if it's a pass phrase.
Re:One way to fix your rubbish password database by tptacek on Friday June 08, 2012 @09:37AM (#4084083)
Sorry; C programmer.
Re:One way to fix your rubbish password database by StavrosK on Friday June 08, 2012 @09:38AM (#4084085)
What's your opinion on SuperGenPass and the like? I'm sure it would still get cracked, but I feel that it would take a lot of effort to crack the provider's hash, even if it were md5, and then less effort to crack the SuperGenPass hash, so hopefully nobody would recognise it or bother...
Re:One way to fix your rubbish password database by simonbrown on Friday June 08, 2012 @10:23AM (#4084295)
Not entirely on-topic but SuperGenPass and probably similar bookmarklets has a security problem:

http://akibjorklund.com/2009/supergenpass-is-not-that-secure

Re:One way to fix your rubbish password database by StavrosK on Friday June 08, 2012 @11:56AM (#4084775)
Ah, I hadn't considered that... That's a shame...
Re:One way to fix your rubbish password database by icebraining on Friday June 08, 2012 @12:39PM (#4084997)
Just wanted to point out that any implementation as a browser extension (as opposed to bookmarklet) is safe from DOM manipulation; searching on Google for "supergenpass extension" returns results for at least Chrome, Firefox and Opera.
Re:One way to fix your rubbish password database by StavrosK on Sunday June 10, 2012 @03:48PM (#4091985)
I'm not so sure, the extension still appends DOM elements, I'm sure those are just as susceptible to sniffing...
Re:One way to fix your rubbish password database by simonbrown on Sunday June 10, 2012 @04:31PM (#4092110)
I haven't looked at the code or even used it that much, but it seems like it only uses content scripts to insert the password into the field, and everything else is dealt with by the popup/background page, which websites don't have access to.
Re:One way to fix your rubbish password database by lukeschlather on Friday June 08, 2012 @11:43AM (#4084705)
An MD5 hash is not a random number; it is generated from some text string. It's possible that bcrypt(salt + MD5(text)) opens you up to collision attacks that are not possible with bcrypt(salt + text). It seems unlikely that it would open you up to attacks that are not possible with md5(text) but MD5 is not a random number so I'm not too sure.
Re:One way to fix your rubbish password database by harshreality on Friday June 08, 2012 @04:52PM (#4086109)
The best means of colliding MD5 seems to require one collision block plus some extra "birthday" bits, all of which are controllable by the attacker. [1]

The idea is that you have two messages, m1 and m2, or m1 and m1' if you prefer, and you vary bits in both until you get a collision. You need some area of m1 and m2 that doesn't matter for the application, so that you can change those bits and find a collision. Since all bits of m1 are supplied when entering the password, you have no ability to modify it without getting the user to change his/her password.

If you could collide any arbitrary m1 as it's given to you, then attacks like fake certs with signed MD5 hashes could create the fake cert after submitting it to the CA and getting the signed cert back, rather than before.

Also, the collision process requires knowledge of m1 so you can see the intermediate hash states. If you know m1, the password/passphrase, why are you trying to find a new m1' that hashes to the same value rather than using the pass you already know?

An attack of concern for using MD5 as a password hashing step would be a first preimage attack. [2]

[1] https://www.google.com/search?q=md5+collision+block+birthday... (first link at present is http://www.win.tue.nl/hashclash/SingleBlock/ )

[2] http://en.wikipedia.org/wiki/Preimage_attack

Re:One way to fix your rubbish password database by joshuahedlund on Friday June 08, 2012 @12:21PM (#4084907)
I'm still trying to learn this stuff, but I do not understand fundamentally how bcrypt(salt + MD5(text)) could be worse than bcrypt(salt + text). What if everyone's plaintext password was already a string of characters identical to some MD5(text)? If bcrypt(salt + MD5(text)) could be bad, then doesn't that mean bcrypt(salt + text) could be bad too?
Re:One way to fix your rubbish password database by lmkg on Friday June 08, 2012 @01:25PM (#4085249)
If you compose hash functions, you get the union of possible collisions.

Let's say that "foo" and "bar" are two distinct passwords that have the same MD5 hash. Then bcrypt(md5("foo")) == bcrypt(md5("bar")), regardless of how bcrypt("foo") compares to bcrypt("bar"). By pre-hashing with MD5, you have added possible collisions that weren't there previously, and those collisions remain regardless of how many more hashes you pile on top.

Re:One way to fix your rubbish password database by chc on Friday June 08, 2012 @01:43PM (#4085344)
We're not pre-hashing with MD5. The MD5 was already there. It's the only source text we have. The proper comparison here isn't MD5+bcrypt vs. just bcrypt — it's MD5+bcrypt vs. just MD5. So any collisions that MD5 causes are immaterial — they'd be there either way.

It seems to me that the most obvious problem is that you get two chances at colliding — once with MD5 and once with bcrypt. But bcrypt is not known to be especially vulnerable to collision attacks, so this setup is probably not noticeably worse than MD5 alone. But that's just looking at probabilities — I ain't no fancy crypto expert or nothin', so there might be much more subtle vulnerabilities than the added chance of collision.

Re:One way to fix your rubbish password database by lmkg on Friday June 08, 2012 @06:33PM (#4086453)
> It seems to me that the most obvious problem is that you get two chances at colliding

Yeah, that's all I'm saying. I was answering a question about being "fundamental worse," and fundamentally, there are now two sources of potential collisions instead of one. In theory, that's twice as insecure! However, the practical effect is unlikely to rise above absolute nil anytime soon.

Re:One way to fix your rubbish password database by tedunangst on Friday June 08, 2012 @05:23PM (#4086231)
Let's say that "foo" and "bar" are two distinct passwords that have the same MD5 hash.

As a practical matter, we can basically say that never happens. Certainly not for passwords that are user selected and not designed to collide. And since the hash itself is hidden by bcrypt, the attacker won't know md5("foo") even if they were inclined to find a "bar" with the same hash.

Re:One way to fix your rubbish password database by tptacek on Friday June 08, 2012 @02:02PM (#4085424)
Can you cite a single example Of a pair of password-length strings that could be entered on a standard keyboard that collide in MD5?

Cryptographic pseudorandom number generators also collide and produce cycles. MD5 hashes of arbitrary ASCII strings are reasonably modeled as random numbers, and the concern you cite is unmeaningful.

Re:One way to fix your rubbish password database by pbhjpbhj on Saturday June 09, 2012 @08:14AM (#4087911)
That seems like a big ask, these are the closest I could find - http://www2.mat.dtu.dk/people/S.Thomsen/wangmd5/samples.html.

An upper limit on string length suddenly makes some sense.

Re:One way to fix your rubbish password database by tptacek on Sunday June 10, 2012 @12:55PM (#4091518)
Huh? Because some unsuspecting user might choose a password so long and so random that it turns out to be collidable with one other string?
Re:One way to fix your rubbish password database by pbhjpbhj on Sunday June 10, 2012 @02:14PM (#4091725)
I did say "some" sense. I was thinking choosing a string to collide and enter an account without it being apparent that you entered the account with anything other than the correct password. Alright the chances of someone wanting to do that seem slim but I can see someone saying in a meeting "if we leave the passphrase open at the max length side then people could enter a string with a matching hash".
Re:One way to fix your rubbish password database by abscondment on Friday June 08, 2012 @02:05PM (#4085436)
I'm very open to correction, but won't the increased time complexity of bcrypt also mitigate this kind of attack?
Re:One way to fix your rubbish password database by pilsetnieks on Friday June 08, 2012 @09:35AM (#4084068)
To nitpick a bit, it's 16 bytes, usually represented by 32 hexadecimal numbers.
Re:One way to fix your rubbish password database by tptacek on Friday June 08, 2012 @09:37AM (#4084079)
The hexadecimal is just UI; ignore it.
Re:One way to fix your rubbish password database by 16s on Friday June 08, 2012 @02:00PM (#4085413)
Amen to that. It could be b64 encoded or whatever. Focus on the raw bytes. They are truth.
Re:One way to fix your rubbish password database by cheatercheater on Sunday June 10, 2012 @02:54AM (#4090401)
Red light coming up in the back of my head. Wouldn't the MD5->scrypt pipeline expose new attacks that scrypt doesn't have? Maybe there's a higher collision probability or some known-text attack, but I'm really shooting in the dark here.
Re:One way to fix your rubbish password database by tptacek on Sunday June 10, 2012 @12:56PM (#4091519)
No.
Re:One way to fix your rubbish password database by cheatercheater on Monday June 11, 2012 @11:36AM (#4095132)
That's one person whose "no" I'll accept without further explanations. Thanks for clarifying.
Re:One way to fix your rubbish password database by __alexs on Friday June 08, 2012 @09:42AM (#4084102)
If you were on MD5 your passwords all have at most 128-bit of entropy. A user with a password of say, 30 random bytes from [a-ZA-Z0-9] will be getting some entropy truncated in the hashing process. If you now move to say, bcrypt your hashes are 448-bits long. So you are throwing a way a lot of the keyspace by using a shorter hash function first. So yes, it's weaker, in one sense, it's just massively more difficult to attack already and you can still upgrade to pure bcrypt as users log-in in future.
Re:One way to fix your rubbish password database by RyanMcGreal on Friday June 08, 2012 @12:03PM (#4084813)
Thanks to reading lots of articles on HN about password security, I upgraded my site's passwords from salted MD4 to bcrypt about a year and a half ago (a bit late to the party, but still). Here's what I did:

I added a second password column to the users table, then ran a script that queried the table for the existing hash, generated a bcrypt hash from that value and wrote it into the new password column. Then I removed the old password column. No need to wait for the user to log in.

When people log in today, the code takes their password, runs it through the old hash routine, runs the output through the new hash routine, and compares that to the password on file.

Re:One way to fix your rubbish password database by Yeroc on Saturday June 09, 2012 @10:17PM (#4089972)
Unless I missed something you're describing exactly what the linked article suggested to do.
Re:One way to fix your rubbish password database by StavrosK on Friday June 08, 2012 @09:03AM (#4083935)
That's what the article says.
Re:One way to fix your rubbish password database by healsdata on Friday June 08, 2012 @09:33AM (#4084062)
Thanks for pointing that out. For some reason, when I read it earlier, I missed the bullet point about the conversion process.
Re:One way to fix your rubbish password database by StavrosK on Friday June 08, 2012 @09:36AM (#4084074)
No problem, glad to have helped!
Re:One way to fix your rubbish password database by bmelton on Friday June 08, 2012 @11:41AM (#4084693)
Well, I mean there's always the possibility that you'll have users that won't log in any time soon, and you don't want them to be vulnerable in the mean time, right?

If it were me doing it, I'd take the article's approach as the first whack, and then as each user logs in, validate their password (as per the article), and then also set their password to scrypt('salt', 'password') vs. scrypt('salt', md5('password')), so that they were current. Then just set a flag on the user record like "new_password=True" or something.

That gets you the stopgap without having to muck around with scrypted hashes forever. Send out a few emails to your user population with a note that you've upgraded your password strategy and that they should log in. You're still not going to get 100% coverage, but at least for whoever you don't get to log in, their passwords aren't 'in the wind', so to speak.

Edit: I'm not sure if you edited yours, or if I just read it poorly, but I think we're saying the same thing. Note, the article's strategy is basically your first scenario -- just bcrypting (or scrypting in the article) the existing md5 hash.