64 points · by ssclafani · 13y ago · 19 comments
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.
User.find_by_email_and_token(params[:email], params[:token])
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.
I wish heroku would disclose this issues.