Re:Password Hijacking Security Incident and Response
by jmillikin on Wednesday January 09, 2013 @04:09PM
(#5033527)
It's the "if nil, above line returns random user on some databases" I'm curious about. What databases behave thus? It's a very problematic behavior.
Re:Password Hijacking Security Incident and Response
by Xylakant on Wednesday January 09, 2013 @04:16PM
(#5033565)
It may be evaluated as "SELECT * FROM USERS WHERE password_reset_nonce IS NULL". If your password_reset_nonce field may contain null values, this will fetch the first row of those it finds. Some databases show quasi-random behavior when fetching that row.
Re:Password Hijacking Security Incident and Response
by t-crayford on Thursday January 10, 2013 @06:21AM
(#5036423)
Doing params.fetch(:password_reset_nonce) would get you out of that nil issue. Doing fetch is generally good practice, especially on params, as often without the right params you can't do anything anyway and should be bailing out with a 404 or another error code.
Re:Password Hijacking Security Incident and Response
by lacerus on Wednesday January 09, 2013 @04:56PM
(#5033797)
to_hex does not seem to be in the standard library, but these will work and are rather elegant to get a short random string. Thanks, Patrick!
rand(16**16).to_s(16)
rand(16**16).to_s(36)
Bugs like this one always make me think "There but for the grace of God go I."