GJordao / simple-auth

An authentication service that aims to be simple and customisable
MIT License
3 stars 3 forks source link

Mitigate timing attack in authentication #36

Open bomany opened 2 years ago

bomany commented 2 years ago

When attempting to authenticate, if a user does not exist the it will throw invalidCredentialsError, while when a user exists it takes much longer as the attempted password gets hashed and compared with the stored password. This allows for an attacker to infer whether or not a given account exists based upon the response time of an authentication attempt.

A way to mitigate this is to run a hash of a dummy password that is guaranteed to fail.