An online shop requires long passwords with symbols at sign-up and calls its accounts secure. The login page came from a template and lets anyone try as often as they like. One night the logs fill with sign-in attempts from many addresses, each trying a different customer's email with a different password. By morning several accounts have placed orders to new addresses. Their passwords met every rule; the customers had used them on another site that was breached.
The common misconception
The belief: strong password rules on their own protect a login endpoint from brute-force and credential-stuffing attacks.
It comes from the classic picture of an attack: someone guessing one account's password over and over. Against that, length and complexity really do help, and frameworks push them by default. ASP.NET Core Identity, for instance, "requires that passwords contain an uppercase character, lowercase character, a digit, and a non-alphanumeric character" unless you change it. With rules like that in place, the login itself looks safe.
But password rules run once, at sign-up. They say nothing about how many times the login endpoint can be called, or whether the password was already leaked somewhere else.
What actually happens
Credential stuffing replays known pairs
OWASP's Credential Stuffing Prevention Cheat Sheet defines as "Testing username/password pairs obtained from the breach of another site." Brute force tries many passwords on one account; password spraying tries one weak password on many accounts. Stuffing needs no guessing at all: if the pair works elsewhere, a strong password helps the attacker as much as a weak one.
Strength rules are a weak lever anyway
NIST SP 800-63B-4 goes further than "not enough". It notes that users answer composition rules "in very predictable ways", turning "password" into "Password1!", and says verifiers "SHALL NOT impose other composition rules". Instead, new passwords are checked against a blocklist that includes "Passwords obtained from previous breach corpuses", and online guessing is handled at the login: "Throttling is the primary defense against online attacks".
Count per client and per account
A limit per IP address stops one machine from hammering your login. It isn't enough on its own: OWASP warns that stuffing tools use proxy networks that "may defeat both IP block-lists and rate limiting, as per IP request volume may remain relatively low". That's why the Authentication Cheat Sheet says the counter of failed logins "should be associated with the account itself, rather than the source IP address". NIST caps consecutive failures on one account at "no more than 100", and allows lower limits. In ASP.NET Core Identity that counter is , with defaults of 5 failures and 5 minutes, and it only counts when you pass lockoutOnFailure: true. The login page in Identity's own template passes false.
MFA changes the outcome
Both OWASP cheat sheets call multi-factor authentication "by far the best defense against the majority of password-related attacks". A replayed password then gets the attacker to the second factor and no further. The other controls buy time and reduce noise; MFA makes a correct password insufficient.
Locking down the login endpoint
C# · Program.cs
using Microsoft.AspNetCore.Identity;var builder = WebApplication.CreateBuilder(args);builder.Services.Configure<IdentityOptions>(o =>{ o.Password.RequiredLength = 12; // strong rules at sign-up...});var app = builder.Build();app.MapPost("/login", async (LoginForm form, SignInManager<AppUser> signIn) =>{ // ...but unlimited attempts, and failures never lock the account var result = await signIn.PasswordSignInAsync( form.Email, form.Password, isPersistent: false, lockoutOnFailure: false); return result.Succeeded ? Results.Ok() : Results.Unauthorized();});app.Run();
C# · Program.cs
using System.Threading.RateLimiting;using Microsoft.AspNetCore.Identity;var builder = WebApplication.CreateBuilder(args);builder.Services.AddRateLimiter(o =>{ o.RejectionStatusCode = StatusCodes.Status429TooManyRequests; o.AddPolicy("login", http => RateLimitPartition.GetSlidingWindowLimiter( http.Connection.RemoteIpAddress?.ToString() ?? "unknown", _ => new SlidingWindowRateLimiterOptions { PermitLimit = 10, SegmentsPerWindow = 6, Window = TimeSpan.FromMinutes(1), }));});var app = builder.Build();app.UseRateLimiter();app.MapPost("/login", async (LoginForm form, SignInManager<AppUser> signIn) =>{ var result = await signIn.PasswordSignInAsync( form.Email, form.Password, isPersistent: false, lockoutOnFailure: true); return result.Succeeded ? Results.Ok() : result.RequiresTwoFactor ? Results.Accepted() : Results.Unauthorized(); // same answer for wrong, unknown and locked}).RequireRateLimiting("login");app.Run();
The right version has two independent counters: the sliding window counts requests per client address, and Identity's lockout counts failures per account. We ran it on .NET 10 in a scratch app with an in-memory user store, behind the forwarded-headers middleware so each request could claim its own client address. First, one address tried twelve wrong passwords on one account. Then twelve addresses tried one wrong password each on a second account, and finally its real password came from a new address:
The rate limit caught the single address and never noticed the distributed run. The account counter caught it. Note what that last line means: lockout also locked out the real owner, which is why it needs the safeguards below.
Defense
Brute force on one account
Credential stuffing
Main weakness
Password composition rules
Partly
No
Reused and predictable passwords still pass
Rate limit per IP
Yes, from one address
Partly
Proxy networks spread requests thin
Failure counter per account
Yes
Partly
Attackers can lock real users out
Breached-password check
Partly
Yes, for leaked passwords
Only knows published breaches
Multi-factor authentication
Yes
Yes
Needs rollout and recovery flows
How to apply it in your project
Turn on the account counterPass lockoutOnFailure: true wherever passwords are checked, and choose the threshold and duration on purpose, with growing delays if you can.
Rate-limit every credential endpointApply a policy to login, password reset and MFA code checks, partitioned by client address. Behind a proxy, configure forwarded headers so the address is the client's, not the proxy's.
Check passwords against breaches, drop composition rulesReject new passwords found in breach lists, as NIST requires, and stop forcing symbol and digit mixes.
Roll out MFA, starting with adminsOffer passkeys or an authenticator app to everyone. Where MFA can't be mandatory for all users, OWASP suggests at least requiring it for administrators.
Watch the numbersTrack failed logins, lockouts and 429s per address and per account. OWASP recommends metrics for every defense, because they can reveal attacks you missed and defenses that quietly failed.
Key takeaways
Credential stuffing replays passwords leaked elsewhere; strength rules never see it.
NIST favors breached-password blocklists and throttling over composition rules.
Limit attempts per client address and count failures per account; each catches what the other misses.
Return one generic error for every failure, and guard lockout against abuse.
MFA is the defense that makes a correct, stolen password insufficient.
التعليقات (0)