Catalog My learning Blog
OWASP Top 10 2025 Explained with Examples and Fixes · Phase 4 · Lesson 8 · 4 min read

Authentication Failures (OWASP A07:2025)

On this page
  1. Credential stuffing vs brute force
  2. User enumeration through login timing
  3. The defences that stop credential stuffing
  4. JWT validation: audience, issuer and algorithm
  5. Check yourself

Credential stuffing vs brute force

Billions of username and password pairs from old breaches are public. Many people reuse passwords, so attackers replay those pairs against other sites automatically. This is credential stuffing. It differs from brute force, which tries many passwords against one account. Credential stuffing tries one known password per account, across many sites.

In 2023 attackers used credential stuffing to get into about 14,000 23andMe accounts without multi-factor authentication (MFA). Through a feature that shared data between relatives, that exposed information on about 6.9 million people.

Good authentication assumes some users' passwords are already known to attackers.

User enumeration through login timing

A careful team returns one message for "no such user" and "wrong password", so attackers can't tell which emails are registered. Here's that login, with Argon2id hashing (Day 5):

JavaScript
function loginV1(email, pw) {
  const u = users.get(email);
  if (!u) return false;                                   // returns immediately
  return crypto.timingSafeEqual(hash(pw, u.salt), u.hash); // ~25 ms of hashing
}

Average over 20 wrong-password attempts:

Code
v1 existing 26.6 ms   v1 unknown 0.0 ms

The message is identical, but the timing isn't. A known email takes 26 ms, an unknown one returns at once. An attacker can sort a list of emails into "registered" and "not registered" from response times alone.

The fix is to do the same work either way, hashing against a dummy record when the user doesn't exist:

JavaScript
function loginV2(email, pw) {
  const u = users.get(email) ?? DUMMY;
  const ok = crypto.timingSafeEqual(hash(pw, u.salt), u.hash);
  return ok && u !== DUMMY;
}
Code
v2 existing 25.7 ms   v2 unknown 25.6 ms

Signup and password reset leak the same information ("that email is taken"), so rate-limit them too.

The defences that stop credential stuffing

  • MFA. A leaked password alone stops working. Passkeys and other phishing-resistant methods are stronger than SMS codes.
  • Check passwords against breach lists at signup and change, for example with the Have I Been Pwned range API.
  • Follow NIST SP 800-63B (Revision 4, 2025): at least 15 characters when the password is the only factor (8 with MFA), no forced character mixes, and no forced periodic changes unless there's evidence of compromise.
  • Throttle failures per account and per source address, and alert on spikes (Day 10).
  • Manage sessions properly: random server-issued IDs, HttpOnly, Secure and SameSite cookies, expiry, and invalidation on logout and password change.
An attacker replays leaked credentials or abuses tokens; MFA, breach-list checks, throttling and strict token validation each block a different path.
An attacker replays leaked credentials or abuses tokens; MFA, breach-list checks, throttling and strict token validation each block a different path.

JWT validation: audience, issuer and algorithm

Services that accept JSON Web Tokens (JWTs) often only check the signature. In this test (HS256 with a shared secret) the auth server issued a token for reports-service, and the billing service verifies it:

Code
jwt.verify(token, secret);
Code
no aud check: alice accepted

The signature is valid, so billing accepts a token that was never meant for it. Pin what you expect:

JavaScript
const payload = jwt.verify(token, key, {
  algorithms: ['RS256'],               // never let the token choose
  audience: 'billing-service',
  issuer: 'https://auth.acme.example/',
});
if (!payload.scope?.split(' ').includes('billing:read')) return res.status(403).end();
Code
aud pinned: JsonWebTokenError jwt audience invalid. expected: billing-service

Pinning algorithms blocks tokens that name a different algorithm.

ASP.NET Core's JWT bearer handler validates issuer, audience, lifetime and signature by default once you configure them:

C#
builder.Services.AddAuthentication().AddJwtBearer(o =>
{
    o.Authority = "https://auth.acme.example/";
    o.Audience = "billing-service";                              // tokens for other services fail
    o.TokenValidationParameters.ValidAlgorithms = new[] { "RS256" };
});

The common way to break it is a fix for an error message: a token fails with an audience error during development, and someone sets ValidateAudience = false. That's exactly the hole shown above. Fix the audience the token is issued for instead. jsonwebtoken 9 already rejects unsigned alg: none tokens (jwt signature is required), but older libraries and hand-written checks have accepted them.

Check yourself

Response timing. If the password hash only runs for existing users, those responses are measurably slower. Hash against a dummy record for unknown users.

Brute force guesses many passwords for one account; credential stuffing replays leaked pairs across many accounts. MFA stops it best, because the correct password alone no longer works.

A correctly signed token may have been issued for another service or by another issuer. Without those checks, any token from the same key works everywhere.

Credential stuffing uses passwords leaked from other sites, so the password is often correct. MFA requires something the attacker doesn't have, such as a passkey or authenticator code, so a valid password alone isn't enough. Passkeys also resist phishing.

Some libraries once accepted tokens whose header said alg: none, meaning unsigned, so attackers could forge any claims. Configure validation with an explicit list of allowed algorithms and keys, and never let the token's header choose how it's verified.