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

Run the token through a secure HMAC function before storing it in the DB. Problem solved. KISS. :)


Why would something derived from a random string have better comparison properties than the random string?


You can’t perform a timing attack for a token “foo” in SELECT WHERE token = :token if the token stored in the DB is the HMAC of “foo”. E.g. trying “f” and then “fo” produce 2 entirely different, random tokens from the query’s POV. The attacker could never deduce that the correct token is “foo.”




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

Search: