r/AskComputerScience • u/benmarvin • Apr 08 '26
Why does it take my computer slightly longer to tell me when I've entered the wrong login password than when I enter the right password?
I've noticed this on both Windows and Linux. If I enter the correct password, it almost instantly starts the login. But if it's the wrong password it takes like a second or so to tell me it's wrong.
32
Upvotes
View all comments
Show parent comment
11
u/SubstantialListen921 Apr 08 '26
Yes, the main reason is to make brute force attacks more difficult. See the man page for pam_unix, for example - https://linux.die.net/man/8/pam_unix - which notes that there is an approximately 2 second delay after each failure (and how to disable it if you don't want this defense).
Timing attacks generally work by exploiting early return from a password check function which allows an attacker to determine when a password guess is "getting closer" to a right answer; the most common fix is to make sure every password check takes the same amount of time. Generally the timings involved in these attacks are significant sub-human-perception level; while the attacks are very real, if you are sitting there at the terminal wondering what's happening, the intended effect is on humans.