Account lockout
| Type | Defence against online password guessing |
|---|---|
| Weakness when missing | CWE-307: Improper Restriction of Excessive Authentication Attempts |
| Weakness when too strict | CWE-645: Overly Restrictive Account Lockout Mechanism |
| OWASP Top 10 | A07:2025 Authentication Failures |
| Stops | Brute-force attack against one account; guessing of two-factor codes |
| Does not stop | Password spraying |
A sign-in system with account lockout keeps a count of failed attempts for each account. When the count reaches a set limit, the system refuses further attempts on that account for a period, or until the owner or an administrator lifts the lock.12 The same counter can cover guesses at two-factor authentication codes and security questions.3 Lockout is the usual defence against password guessing aimed at a single account. Anyone who knows a username can also trip it.
Threshold, window and duration
A lockout policy is defined by three numbers. The threshold is how many failures trigger it, the observation window is the period those failures have to fall within, and the duration is how long the account stays locked afterwards.1 Some systems drop the fixed duration for an exponential one, which starts near one second and doubles with every further failure.1 After a successful sign-in the earlier failures should be ignored; ASP.NET Core Identity resets both the count and the clock.45
The count belongs to the account. One kept per IP address starts again from zero for an attacker who sends each guess from a different machine.1 For one-time codes sent through a second channel such as a text message, issuing a new code must not reset the count, so the limit applies to the account and not to one code.5
| Source | Limit |
|---|---|
| NIST SP 800-63B-4 | No more than 100 consecutive failures with one sign-in method, which is then disabled until the user registers it again |
| Microsoft Entra smart lockout | 10 failures (3 in the Azure US Government cloud); first lock 60 seconds, longer after each repeat |
| Auth0 brute-force protection | 10 failures from one address to one user, adjustable from 1 to 100 |
| ASP.NET Core Identity defaults | 5 failures, 5 minutes |
| Windows default domain policy | 0, meaning accounts never lock; the security baselines suggest 10 as a starting point |
The US federal guideline set its ceiling with six-digit one-time codes in mind. An attacker who spends all 100 guesses on a code with a million possible values has a 1 in 10,000 chance, and a lower ceiling would send more real users into account recovery. The 100 is an upper bound; agencies may set lower ones.5
Lockout as an attack
Lockout that any visitor can trigger is a denial of service in its own right. The attacker needs no password, only the victim's username and a few wrong guesses.2 On a Windows domain with a threshold set, a script that tries passwords against every user can lock every account once each one passes the threshold.6
The case most often cited involves eBay auctions; the account of it gives no date. eBay displayed the user ID of the highest bidder, and three wrong passwords locked an account for a time. In the last minutes of an auction a rival could enter three bad passwords under the leader's ID, place a higher bid and win, since the leader could not sign in to bid back.2
Attacks that stay under the limit
Password spraying works around a per-account counter. One common password, or a short list, is tried against many accounts, so each account records one or two failures and none reaches its threshold.7
The attempt limit works together with the list of banned passwords. The list should be long enough that the passwords attackers try first are already refused before an account runs out of attempts.5 Limits across all accounts belong to Rate limiting.
Designs that spare the owner
Microsoft Entra smart lockout keeps separate counters for familiar and unfamiliar locations, so failures from an unknown network do not use up the allowance of the owner's usual one. It also stores the hashes of the last three wrong passwords and does not count a repeat of the same one.8
Auth0 counts failures per pair of IP address and username. By default, ten failures from one address block that address from signing in as that user, and the user can still sign in from anywhere else; a lock on the account for every address is a separate setting, off by default.9 The two kinds of counter pull against each other. One keyed on the account alone lets anyone lock it, and one that also uses the address starts over for each new address.12
Other ways to spare the real user are a wait after each failure that grows from 30 seconds to an hour as the account nears its limit, a bot check before each attempt, and risk signals such as location and request timing.5 A CAPTCHA raises the cost of automated guessing, but software and paid solving services defeat many of them, so it is a second layer on top of a lockout.13
Ending a lock
A lock can end after a set time, through a link sent to the registered email address, by an administrator, or by an administrator after confirming who the user is; the list runs from lowest to highest assurance. A timed lock of 5 to 30 minutes is a reasonable compromise, and an emailed link should be unique and valid once so that it cannot be guessed or replayed.3
One answer to the denial-of-service problem is to let the forgotten-password flow sign the user in while the account is still locked.1 Entra works this way: choosing I forgot my password in self-service reset sets the remaining lock to zero.8 The weight then moves to Account recovery, which has to stop an attacker from lifting the lock.3 Emailed links have a problem of their own. Mail scanners such as those in Microsoft 365 open links in incoming mail with a headless browser (one run by software, with no window) and can release an account before its owner reads the message; Auth0 offers a Manual option that asks for a button press after the link opens.9
Sign-in, password reset and recovery should give a locked account the same error message as a wrong password or an unknown username; a distinct message helps Account enumeration.1 Each lockout should also be logged and reviewed (see Security logging and alerting).1
Settings in common stacks
In ASP.NET Core Identity the options set the limits, but a failure only counts when the sign-in call passes lockoutOnFailure: true. The generated login page passes false, so lockout is configured but inactive until that argument is changed.4
// Program.cs
builder.Services.Configure<IdentityOptions>(options =>
{
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5);
options.Lockout.MaxFailedAccessAttempts = 5;
options.Lockout.AllowedForNewUsers = true;
});
// Login page
var result = await _signInManager.PasswordSignInAsync(
Input.Email, Input.Password, Input.RememberMe,
lockoutOnFailure: true);In Microsoft Entra the values are under Entra ID > Authentication methods > Password protection, as Lockout threshold and Lockout duration in seconds; changing them needs a P1 licence or higher.8 In Auth0 they are under Dashboard > Security > Attack Protection > Brute-force Protection.9
Find the sign-in code in this project and check how it handles repeated failed passwords. Report whether failed attempts are counted per account, what the threshold and lock duration are, whether a successful sign-in resets the count, and whether second-factor codes share the limit. If nothing is counted, add a per-account counter with a lock that grows after each failure, and make the locked-account response identical to the wrong-password response. If the project uses ASP.NET Core Identity, check that PasswordSignInAsync is called with lockoutOnFailure: true. List each file and line you changed.
See also
- Brute-force attack
- Password spraying
- Credential stuffing
- Rate limiting
- Multi-factor authentication
- Account recovery
- Category: Authentication
References
- a b c d e f g h i "Authentication Cheat Sheet". OWASP Cheat Sheet Series.
- a b c d "CWE-645: Overly Restrictive Account Lockout Mechanism". Common Weakness Enumeration 5.0. MITRE.
- a b c d "Testing for Weak Lock Out Mechanism" (WSTG-ATHN-03). OWASP Web Security Testing Guide v4.2. OWASP Foundation.
- a b Microsoft. "Configure ASP.NET Core Identity". Microsoft Learn.
- a b c d e "NIST SP 800-63B-4, Digital Identity Guidelines: Authentication and Authenticator Management". NIST.
- back Microsoft. "Account lockout threshold". Microsoft Learn, Windows security policy settings.
- back "Brute Force: Password Spraying, T1110.003". MITRE ATT&CK. MITRE.
- a b c Microsoft. "Protect user accounts from attacks with Microsoft Entra smart lockout". Microsoft Learn.
- a b c Auth0. "Brute-force protection". Auth0 Docs. Okta.
External links
- Authentication Cheat Sheet, OWASP Cheat Sheet Series