Passwords, brute force and credential stuffing: how login is attacked and defended
Brute force tries many passwords on one account, spraying tries common passwords across many accounts, stuffing uses pairs from breaches. Defence is layered: limits per account, per IP and global, anomaly detection, MFA, breach-list checks and identical responses to any login error. A full account lockout lets an attacker lock other people's accounts.
Pentest · Authentication
A thousand failed logins a minute from different IPs. Is it an attack, and will the login hold?
The log shows a burst of POST /login requests answered with 401. Did somebody forget a password? No: 4000 different accounts and only a few attempts on each. The login form is the first target of any service, and there are three typical attack scenarios. This lesson covers how they differ, why one lockout of failed attempts does not save you and what QA checks.
How it works and why. All three attacks automate login attempts but differ in what they substitute:
- Brute force — many passwords for one account (from a dictionary to full enumeration);
- Password spraying — one or two very common passwords for many accounts so as not to exceed the per-account limit;
- Credential stuffing — login and password pairs from other breaches: it works because people reuse passwords across sites.
What each attack substitutes
This gives the logic of defence. Rate limiting of logins is set on several levels: per account, per IP address and overall, and anomalies (many different accounts tried with the same password) are detected separately. A full lockout of an account after N attempts has a downside: an attacker can deliberately lock other people’s accounts (denial of service), so progressive delays or a temporary lockout together with a challenge are used more often. Against stuffing, multi-factor authentication, checking passwords against lists of known breaches and bot protection help.
Password policy. NIST SP 800-63B-4 (revision 4) drops the usual requirements. For a password as the only factor the minimum is 15 characters (8 if the password is only part of MFA); the verifier should allow a length of at least 64; must not impose composition rules such as “a capital letter, a digit, a symbol”; must not require periodic changes without signs of compromise; must compare a new password against a list of common and compromised ones. The limit of failed attempts on one authenticator must not exceed 100. The reason: complex rules produce predictable passwords (Winter2026!) and forced rotation produces “Winter2027!”.
Example: what the login gives away. QA sends a login with a non-existent account and with an existing one but a wrong password. The defective responses differ:
POST /login {"email":"nobody@shop.example","password":"x"}
HTTP/1.1 401 {"error":"user not found"}
POST /login {"email":"anna@shop.example","password":"x"}
HTTP/1.1 401 {"error":"wrong password"}
Now an attacker can check whether an account exists (user enumeration) and work only on real ones. The fix is the same message, the same code and about the same response time (a difference of milliseconds also gives away whether the server computed a password hash):
HTTP/1.1 401 Unauthorized
{"error":"Invalid email or password"}
The limit can also be seen from the client side: after a series of failed attempts a refusal is expected with a hint when to retry:
HTTP/1.1 429 Too Many Requests
Retry-After: 60
Such checks are done only on a test account on a test system or in labs (PortSwigger Web Security Academy, the Authentication section, OWASP Juice Shop). Brute force against someone else’s production service without written permission is a crime, and on your own it can lock out real users.
A real case. In October 2023 23andMe reported account takeovers through credential stuffing, and in December, after its investigation, stated that the attacker had accessed about 14,000 accounts (less than 0.1% of 14 million customers): logins and passwords matched those customers used on other sites that had been compromised earlier. According to the company, its own systems were not breached. Through the DNA Relatives feature about 5.5 million relatives’ profiles and 1.4 million family tree profiles were viewed. The company made everyone reset passwords and introduced mandatory two-step verification. The lesson: the weak link is password reuse, and the defence on the service side is MFA, checking against breach lists and detecting mass logins.
Limits. CAPTCHA slows bots down, but services for solving it exist. A per-IP limit is bypassed by a distributed attack from thousands of addresses, so it is complemented by a per-account limit. A password manager and unique passwords are protection on the user’s side that the service does not control. Passkeys remove the password and with it the whole class of attacks on it.
Common mistakes.
- Different messages for “no such user” and “wrong password”, and the same in the password recovery form.
- A limit by IP only: spraying from a botnet does not notice it.
- A full account lockout with no way out: an attacker locks the director out before a decisive day.
- The “one capital, one digit, one symbol” requirement instead of length and a breach list check.
Check yourself
A limit of “5 failed attempts per account, then a 15-minute lockout”. Which attack does it not stop?
Answer
Password spraying: one or two attempts per account never reach the limit. Limits per IP and overall, anomaly detection and MFA are needed. Credential stuffing with correct pairs also passes on the first attempt.
A login with a non-existent email answers in 12 ms and with an existing one and a wrong password in 180 ms. Why is it a defect even though the messages are the same?
Answer
The different time gives away that for an existing account the server computed the password hash: this is user enumeration by timing. A hash is computed for a non-existent account as well (a dummy one) so that the time matches.