I have reviewed the patch applied to D7 regarding the #29706: More secure password hashing and while I think the code is secure as is, it is based on the assumption that MD5 secure, which has been demonstrated false numerous times since 1995, with much stronger attacks in 2008:
http://en.wikipedia.org/wiki/MD5#Vulnerability
In this article, numerous, reputed sources in the cryptographic world are quoted as saying that "no one should be using MD5 anymore" and that MD5 "should be considered cryptographically broken and unsuitable for further use".
I personally think that it is unlikely that someone would be able to recover the password from a D7 hash as it stands (because of the hash), but I am not sure (and I am not a cryptographer) because I feel the "prefix attack" could apply here (even though the salt is technically the prefix and would therefore render the attack impractical).
Nevertheless, I think that Drupal 7 would be a good occasion to finally drop MD5 from Drupal and start using another hashing function. SHA-1 is the obvious candidate since it's part of PHP, but it's also been demonstrated weaker recently. The current attacks on SHA-1 are limited to collision attacks, which are less a problem for Drupal's usage of the algorithm.
I attach a rather naive patch that switches the default hash to SHA-1. It's probably incomplete, but I rather put something up already.
Note that md5() is used all over the place in Drupal. I'm not trying to adress this issue here, but maybe it should be addressed too. Most of the time the md5() function is used as a formatting or non-critical hashing function (e.g. in css/js compression). I'm not sure session identifiers are a problem because once those are leaked, you're screwed anyways. The drupal_get_token() functionality is more interesting however, because the MD5 prefix vulnerability could allow an attacker to generate a valid token. The user_cancel_url() has a similar issue.
~/drupal-7.x$ grep -r md5 . | wc -l
81
Let me emphasis something here before finishing: I do not think we're at a very serious risk now. The salt hashing stuff is great work and I'm glad D7 took that turn. However, we must think forward right now: MD5 is dead and relying on it for anything else than a cute packing function is wrong and will bring security issues that *will* affect D7 when it is released. I'd even try to avoid SHA1, but it seems that staying with pure PHP function is a strong requirement here, so I will not argue that (yet).
| Comment | File | Size | Author |
|---|---|---|---|
| sha1.patch | 632 bytes | anarcat |
Comments
Comment #1
damien tournoud commentedDrupal 7 is voluntarily using the standardized PHPass framework ("portable hashs"). Moving from MD5 to SHA1 in PHPass is bigger then Drupal and will need to be discussed some other place ;)
If I'm not mistaken, drupal_get_token() is not affected by prefix attacks, but it could make sense to switch to SHA1 there.
Comment #2
sun.core commentedComment #3
chx commentedThis has been done.