← Blog

Claude MCP skill brute-force protection — account enumeration in login flow — SA-SKL-AUTH14

Insufficient brute-force protection and account enumeration are rarely flashy vulnerabilities — no RCE, no data breach in a single step — but they are force multipliers. An attacker who can confirm which emails are registered and then bypass per-IP rate limiting can run credential stuffing at scale against developer accounts that hold API keys, private skill repos, and billing access. SA-SKL-AUTH14 covers the four login-flow weaknesses SkillAudit finds consistently in MCP skill registry developer portals.

By SkillAudit  |  12 Nov 2026
SA-SKL-AUTH14 findings at a glance
HIGHAUTH14-001 — Login endpoint returns 401 "Invalid password" vs 404 "User not found"; timing difference (bcrypt runs only when user exists) and distinct status codes together confirm registered email addresses
MEDIUMAUTH14-002 — Password reset endpoint returns "Email not found" for unknown addresses; confirms which email addresses are registered; usable for targeted credential stuffing
HIGHAUTH14-003 — Login rate limit keyed by IP only; attacker distributes attempts across a botnet or proxy pool; per-account lockout absent; unlimited attempts against any single account
HIGHAUTH14-004 — Account lockout check performed after bcrypt.compare(); attacker learns from the timing whether the account exists (bcrypt takes ~100ms) before lockout fires; full timing oracle before protection engages

AUTH14-001 — Login response leaks account existence

When a login endpoint distinguishes between "user not found" and "invalid password" in its response — whether via different HTTP status codes, different error message strings, or measurable timing differences — an attacker can enumerate which email addresses are registered. This is a prerequisite step in credential stuffing: the attacker first builds a list of confirmed accounts, then targets only those accounts with password spray attacks, drastically increasing the signal-to-noise ratio.

The timing difference is especially reliable even when status codes are unified: bcrypt takes ~100ms per comparison, so a login attempt for a non-existent user returns in <5ms (no bcrypt needed), while a failed login for an existing user returns in ~100ms. This timing oracle is consistent across network jitter and can be exploited at scale.

Vulnerable
// AUTH14-001 — VULNERABLE
// Different status codes + messages leak account existence.
// Timing difference (bcrypt only runs when user exists) is a secondary oracle.

app.post('/api/auth/login', async (req, res) => {
  const { email, password } = req.body;

  const user = await db.getUserByEmail(email);

  // VULNERABLE: 404 vs 401 reveals whether email is registered
  if (!user) {
    return res.status(404).json({ error: 'User not found' });
  }

  const valid = await bcrypt.compare(password, user.passwordHash);

  // VULNERABLE: distinct message reveals wrong-password vs unknown-user
  if (!valid) {
    return res.status(401).json({ error: 'Invalid password' });
  }

  const token = generateJwt(user);
  res.json({ token });
});
Fixed
// AUTH14-001 — FIXED
// Uniform response for all failures.
// Constant-time bcrypt compare regardless of whether user exists.

const DUMMY_HASH = await bcrypt.hash('dummy-to-prevent-timing', 12);

app.post('/api/auth/login', async (req, res) => {
  const { email, password } = req.body;

  const user = await db.getUserByEmail(email);

  // Fix 1: always run bcrypt to equalise timing (prevents timing oracle)
  const hashToCompare = user ? user.passwordHash : DUMMY_HASH;
  const valid = await bcrypt.compare(password, hashToCompare);

  // Fix 2: uniform response — same status code, same message, for all failures
  if (!user || !valid) {
    return res.status(401).json({ error: 'Invalid credentials' });
  }

  const token = generateJwt(user);
  res.json({ token });
});

DUMMY_HASH must be a real bcrypt hash: If the dummy hash value is not a valid bcrypt hash, bcrypt.compare() returns very quickly (no work factor applied). Pre-compute the dummy hash once at startup and store it in a module-level constant — not inside the request handler — so the same hash is reused across all requests without the per-request hashing cost. The important property is that the compare operation takes ~100ms whether the user exists or not.

AUTH14-002 — Password reset endpoint email disclosure

Password reset flows are a secondary enumeration surface. Even when the login endpoint is hardened to return uniform messages, the password reset endpoint often returns "Email not found" for unregistered addresses. An attacker who cannot enumerate via login can enumerate via password reset — both surfaces must return the same non-informative message.

Vulnerable
// AUTH14-002 — VULNERABLE
// Password reset endpoint confirms whether an email is registered.

app.post('/api/auth/reset-password-request', async (req, res) => {
  const { email } = req.body;

  const user = await db.getUserByEmail(email);

  // VULNERABLE: distinct response based on whether email exists
  if (!user) {
    return res.status(404).json({ error: 'Email not found' });
  }

  await sendPasswordResetEmail(user.email, generateResetToken());
  res.json({ message: 'Reset email sent' });
});
Fixed
// AUTH14-002 — FIXED
// Always return the same message regardless of whether the email exists.
// Email is sent silently if the account exists; no feedback if it doesn't.

app.post('/api/auth/reset-password-request', async (req, res) => {
  const { email } = req.body;

  // Fire-and-forget — no await; don't let DB timing leak account existence
  db.getUserByEmail(email).then(async (user) => {
    if (user) {
      await sendPasswordResetEmail(user.email, generateResetToken());
    }
    // If user not found: silently do nothing — no email sent
  }).catch(err => console.error('Reset email error', err));

  // Fix: always return the same message
  res.json({ message: 'If that email is registered, a reset link has been sent.' });
});

AUTH14-003 — IP-only rate limit bypassed by distributed attack

Rate limiting login by IP address alone is insufficient against attackers who control a botnet, proxy pool, or cloud function farm. Each IP contributes one attempt per time window; a pool of 1000 IPs can make 1000 attempts per window, effectively eliminating any per-IP limit. The correct defence combines per-IP rate limiting (to slow individual sources) with per-account rate limiting (to cap attempts against any single email address regardless of how many IPs are used).

Vulnerable
// AUTH14-003 — VULNERABLE
// Rate limit keyed on IP only.
// Attacker distributes attempts across 100 IPs to try 100 passwords per minute.

import rateLimit from 'express-rate-limit';

const loginLimiter = rateLimit({
  windowMs: 60 * 1000,  // 1 minute
  max: 5,               // 5 attempts per IP per minute
  keyGenerator: (req) => req.ip,  // VULNERABLE: keyed on IP only
  message: 'Too many login attempts',
});

app.post('/api/auth/login', loginLimiter, async (req, res) => {
  // Per-account lockout absent — unlimited attempts against one email via multiple IPs
  // ...
});
Fixed
// AUTH14-003 — FIXED
// Two-layer rate limiting: per-IP (burst protection) + per-email (account protection).
// Per-account limit prevents distributed brute-force regardless of IP count.

import rateLimit from 'express-rate-limit';
import RedisStore from 'rate-limit-redis';

const ipLimiter = rateLimit({
  windowMs: 60 * 1000,
  max: 10,
  keyGenerator: (req) => req.ip,
  store: new RedisStore({ ... }),
});

const accountLimiter = rateLimit({
  windowMs: 15 * 60 * 1000,  // 15-minute window
  max: 10,                    // 10 attempts per email per 15 minutes
  // Fix: keyed on email address — prevents distributed brute-force
  keyGenerator: (req) => `account:${req.body.email?.toLowerCase() || 'unknown'}`,
  store: new RedisStore({ ... }),
  skipSuccessfulRequests: true,  // don't count successful logins
});

app.post('/api/auth/login', ipLimiter, accountLimiter, async (req, res) => {
  // Both limiters must pass; account limiter protects against distributed attacks
  const DUMMY_HASH = await bcrypt.hash('dummy', 12);
  const user = await db.getUserByEmail(req.body.email);
  const hashToCompare = user ? user.passwordHash : DUMMY_HASH;
  const valid = await bcrypt.compare(req.body.password, hashToCompare);
  if (!user || !valid) return res.status(401).json({ error: 'Invalid credentials' });
  res.json({ token: generateJwt(user) });
});

Exponential backoff on the per-account limiter: A flat 15-minute lockout after 10 attempts can be circumvented by an attacker who times their attempts to stay just under the limit. Progressive backoff (first lockout: 1 minute; second: 15 minutes; third: 1 hour; fourth: 24 hours) makes distributed brute-force economically unviable without blocking legitimate users indefinitely. Store the lockout state in Redis with an expiry keyed on the email address hash.

AUTH14-004 — Lockout check after bcrypt timing oracle

When the account lockout check is placed after the bcrypt comparison, an attacker can exploit the timing difference to confirm whether the account exists before lockout fires: if the response time is ~100ms, bcrypt ran, meaning the account exists. If the response time is ~1ms, the account lookup returned nothing and no bcrypt ran — but the lockout counter was never checked either. The lockout provides no protection against enumeration when it only fires after the hash comparison already reveals the account's existence.

Vulnerable
// AUTH14-004 — VULNERABLE
// Lockout check performed AFTER bcrypt compare.
// Attacker already received timing oracle before lockout fires.

app.post('/api/auth/login', async (req, res) => {
  const { email, password } = req.body;
  const user = await db.getUserByEmail(email);
  const DUMMY_HASH = '$2b$12$dummyhashfortimingnormalization';
  const hashToCompare = user ? user.passwordHash : DUMMY_HASH;

  // bcrypt runs here — timing reveals account existence
  const valid = await bcrypt.compare(password, hashToCompare);

  if (!user || !valid) {
    // VULNERABLE: lockout check AFTER bcrypt — attacker already has timing signal
    if (user) {
      await db.incrementLoginFailures(user.id);
      const failures = await db.getLoginFailures(user.id);
      if (failures >= 10) {
        await db.lockAccount(user.id);
        return res.status(429).json({ error: 'Account locked' });
      }
    }
    return res.status(401).json({ error: 'Invalid credentials' });
  }

  await db.resetLoginFailures(user.id);
  res.json({ token: generateJwt(user) });
});
Fixed
// AUTH14-004 — FIXED
// Lockout check BEFORE bcrypt.
// If account is locked, return immediately — no bcrypt, no timing oracle.

app.post('/api/auth/login', async (req, res) => {
  const { email, password } = req.body;
  const user = await db.getUserByEmail(email);

  // Fix 1: check lockout BEFORE bcrypt — no timing oracle if locked
  if (user) {
    const failures = await db.getLoginFailures(user.id);
    if (failures >= 10) {
      return res.status(429).json({ error: 'Account temporarily locked. Try again later.' });
    }
  }

  // Fix 2: constant-time bcrypt compare (dummy hash if no user)
  const DUMMY_HASH = await bcrypt.hash('dummy-prevent-timing', 12); // pre-computed at startup
  const hashToCompare = user ? user.passwordHash : DUMMY_HASH;
  const valid = await bcrypt.compare(password, hashToCompare);

  if (!user || !valid) {
    // Fix 3: increment failure counter AFTER bcrypt (can't be gamed for timing)
    if (user) await db.incrementLoginFailures(user.id);
    return res.status(401).json({ error: 'Invalid credentials' });
  }

  await db.resetLoginFailures(user.id);
  res.json({ token: generateJwt(user) });
});

The correct order is: lockout check → bcrypt compare → failure increment → token issue. Lockout before bcrypt prevents the timing oracle. Failure increment after bcrypt ensures the counter is only incremented when a real attempt was made (not on the lockout shortcut path). Token issue only after both checks pass. For how session management relates to these login vulnerabilities, see SA-SKL-AUTH12 (session fixation and cookie security) and SA-SKL-AUTH13 (JWT algorithm confusion).

How SkillAudit detects SA-SKL-AUTH14

SkillAudit's authentication scanner combines static analysis and active probing:

PatternRoot causeFixSeverity
AUTH14-001Different status codes/messages + timing difference leak account existenceUniform 401 + same message; always run bcrypt with dummy hashHIGH
AUTH14-002Password reset endpoint returns distinct message for unknown emailAlways return "if registered, we sent a link" regardless of email existenceMEDIUM
AUTH14-003Rate limit keyed on IP only; distributed attack bypasses itPer-IP limiter + per-account limiter with exponential backoffHIGH
AUTH14-004Lockout check after bcrypt — timing oracle fires before protectionLockout check before bcrypt; failure increment after compareHIGH