3 ms·
You have to be careful though. If someone managed an SQL injection and can read tables, but you are using bcrypt hash properly, you might think you are [somewha
by ars 14y ago
You have to be careful though. If someone managed an SQL injection and can read tables, but you are using bcrypt hash properly, you might think you are [somewhat] safe. (i.e. at least they can't write anything.)
But if they can read the password reset tokens from your database they can login as any of the users. (This is especially bad if changing a password doesn't invalidate "keep me logged in" cookies.)
The solution is to treat those tokens as passwords, and hash them as well.
(I know this because I had to clean up after this exact senario happened to someone using Joomla. They got an admin login from a password reset token, from there they were able to write files to disk and fully take control of the server.)
- tptacek 14y agoIf you're writing injectable SQL queries, there is nothing I can tell you about crypto and password resets that can help you. Not all vulnerabilities are equally easy to blunder into. We can presume a competent development team will avoid SQL injection, or at least, will discover accidentally introduced SQLI quickly through testing. The same is not the case with crypto flaws.
- ars 14y agoIn that case why bother using bcrypt? After all your queries are perfect and no one can access the database. I'm being sarcastic if it wasn't obvious.
- tptacek 14y agoAnother way to think about it is: if you're using an SQL database at all, you've signed up for SQLI mitigation whether you use the database for reset tokens or not. However, you still have the option of not having to deal with crypto bugs.