I'm currently using PostgreSQL with the pgcrypto
extension to store and verify user passwords. When a user logs in, I compare the entered password with the stored hash using the following query:
SELECT id FROM users WHERE email = '[email protected]' AND password = crypt('entered_password', password);
Note: In this example, the password is passed as a constant, but in the real application, a SQL injection-free method is used.
My understanding is that this approach could be insecure against timing attacks because the use of =
operator in the query.
However, I want to confirm with security experts if this method is indeed secure and if there are any potential vulnerabilities or better practices I should be aware of.
Question: Is the use of crypt
in this manner secure against timing attacks?
Thank you for your insights!