Re:Security Vulnerabilities in Heroku
by angkec on Wednesday January 09, 2013 @11:51AM
(#5032400)
from the article: "Initial fixes were in place within 24 hours." So it's all fixed? Great! I'll stick with Heroku as my hosting provider like the author does.
Re:Security Vulnerabilities in Heroku
by jiggy2011 on Wednesday January 09, 2013 @01:11PM
(#5032496)
"If the POST was made with ID removed from both the URL and body, the password of a random account would be reset and the account automatically logged in to:"
Re:Security Vulnerabilities in Heroku
by tmaher on Wednesday January 09, 2013 @03:32PM
(#5033317)
It was actually slightly more dumb than that.
Like most sites, after you register your account, we generate a nonce and email it to the provided address. You click the link with the nonce, we prompt you to set your password, and your account is ready. Our bug was that for already-verified users, the nonce column in the database is empty (it's a nonce, you see, so we only use it once...). This was the root cause for both bugs Mr. Sclafani describes.
If the token is nil, it basically turns into a `find_by_email`.
I'll also add that while we had tests that were intended to avoid this bad behavior, these tests were unfortunately broken and were instead verifying the incorrect behavior.
Re:Security Vulnerabilities in Heroku
by wulczer on Wednesday January 09, 2013 @04:09PM
(#5033526)
It's interesting how differently Django handles password resets - no nonce is generated.
Instead, the user is emailed a token that's just her user ID, HMAC-signed with the last login date and a secret site key.
You can't generate valid reset links without knowing the secret key and you can't tamper with the one you got because it's HMAC-signed. By adding the last login date to the HMAC you make sure the link can be used only once. After a user resets her password, the last login date is updated to now so the link is no longer valid due to broken HMAC.
I like this solution because it doesn't rely on storing any state anywhere between requesting the reset and completing it.
Re:Security Vulnerabilities in Heroku
by mikey_p on Wednesday January 09, 2013 @06:14PM
(#5034171)
This is pretty much exactly what Drupal does as well, with the exception of using the user's password hash instead of the ID as input before hashing and it also stores the timestamp of the reset request as part of the URL (and the token) to allow for expiring password resets.
Re:Security Vulnerabilities in Heroku
by zapu on Wednesday January 09, 2013 @03:44PM
(#5033385)
Thank you for being open about that issue. All the reading about vulnerabilities definitely made me more aware when writing critical parts of my applications.
Re:Security Vulnerabilities in Heroku
by jstanley on Wednesday January 09, 2013 @01:45PM
(#5032689)
If you build the query at runtime based on whichever arguments are available, it is quite easy for missing arguments to slip through to the inner query generator and end up with a blank where clause.
Re:Security Vulnerabilities in Heroku
by jiggy2011 on Wednesday January 09, 2013 @01:49PM
(#5032718)
a blank where clause throws an error (in mySQL at least) as it should do. Or will the query generator respond to missing arguments by removing the where clause altogether? In which case that's some pretty nasty behaviour.
Re:Security Vulnerabilities in Heroku
by latchkey on Wednesday January 09, 2013 @01:23PM
(#5032568)
I wish that Heroku would just use a third party open source auth system like Persona. This stuff is difficult and complicated to implement correctly. Sure, Persona could have had this same bug, but I'd rather trust someone who's job all day long is to implement auth systems (and which I can get the source to).
http://blog.heroku.com/archives/2013/1/9/password_hijacking_...
Thanks again to Stephen for giving us ample time to fix this.
-Tom Maher, Heroku Security Team
Way to responsibly disclose them after working with Heroku!
That seems like a very strange bug to occur.
SELECT @id = id FROM table --Oops, forgot where clause. This selects a "random" row
DELETE FROM table_2 WHERE id = @id
Like most sites, after you register your account, we generate a nonce and email it to the provided address. You click the link with the nonce, we prompt you to set your password, and your account is ready. Our bug was that for already-verified users, the nonce column in the database is empty (it's a nonce, you see, so we only use it once...). This was the root cause for both bugs Mr. Sclafani describes.
I'll also add that while we had tests that were intended to avoid this bad behavior, these tests were unfortunately broken and were instead verifying the incorrect behavior.
Instead, the user is emailed a token that's just her user ID, HMAC-signed with the last login date and a secret site key.
You can't generate valid reset links without knowing the secret key and you can't tamper with the one you got because it's HMAC-signed. By adding the last login date to the HMAC you make sure the link can be used only once. After a user resets her password, the last login date is updated to now so the link is no longer valid due to broken HMAC.
I like this solution because it doesn't rely on storing any state anywhere between requesting the reset and completing it.
I wish heroku would disclose this issues.