Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You'll also want to implement some defense against short-term replay attacks (i.e. before the token expires).

You could include a sequence number in the token, but this, of course, involves a database write, which is what you were trying to avoid in the first place.

A better approach would be to store in the database the time that the user's password was last changed, and refuse to honor any reset tokens that are timestamped prior to that time.



Beter yet, mix in a random data field from the user record into the reset link (have it signed with HMAC), and regenerate the random each time reset it done. This way no reset link can be used twice, and no db writes are done when reset link is created.


That's a good point. You want the signed url to be one-use only. last_changed_password_at is a good solution, and a useful field to keep anyway.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: