← Blog

Claude skill brute force and account lockout bypass security — SA-SKL-BRUTEFORCE

Brute force protection requires a lockout mechanism that correctly identifies the attacking party (not just the username), is keyed on a normalized form of the identifier, responds in constant time regardless of lockout state, and uses a lockout window that is long enough to deter automation but short enough not to lock out legitimate users indefinitely. MCP skills that miss any of these properties are vulnerable to credential stuffing, password spraying, or account enumeration. SA-SKL-BRUTEFORCE-001 through BRUTEFORCE-004 cover the four most common gaps: no lockout at all, lockout bypass via IP rotation, lockout bypass via email case variation, and timing oracle via inconsistent error response latency.

By SkillAudit  |  5 Nov 2026

Why brute force protection must be layered

A single lockout counter on the username alone is not sufficient. Credential stuffing attacks use large lists of breached email/password pairs; they typically try each pair once per IP, rotating through thousands of IPs to avoid per-IP rate limits. Password spraying tries one common password against many accounts; it deliberately stays below per-account lockout thresholds. The correct defense uses multiple layers: a per-account lockout after N consecutive failures (catching targeted attacks), a per-IP rate limit (catching credential stuffing from a single IP), a CAPTCHA challenge after the first suspicious signal (raising the cost of automation), and normalized identifiers to prevent case-variation bypasses. Each layer catches attacks that slip through the others.

SA-SKL-BRUTEFORCE in scope: BRUTEFORCE-001 (no lockout on login endpoint), BRUTEFORCE-002 (IP rotation bypasses username-only lockout), BRUTEFORCE-003 (email case variation bypasses lockout key), BRUTEFORCE-004 (timing oracle via lockout vs invalid-credential response latency). All four are detected by SkillAudit's static analysis of authentication route handlers and Redis/session lockout logic.

BRUTEFORCE-001 — No lockout on login endpoint

The most common brute force vulnerability is a login endpoint with no failed-attempt counter at all. With no lockout, an attacker can attempt unlimited password guesses against any account — the only constraint is network bandwidth and the speed of bcrypt comparison on the server. For MCP skills that use bcrypt with a cost factor of 12, bcrypt comparison takes roughly 300ms per attempt on a typical VPS. At 300ms per attempt, a single attacker thread can try ~3 passwords per second; a botnet of 100 threads tries ~300 per second, exhausting a typical 8-character lowercase-alphabetic password space in under 10 hours. Redis-based lockout stops this in a few attempts: after 5 consecutive failures, the account is locked for 15 minutes, forcing the attacker to wait or move to another target.

// VULNERABLE: login endpoint with no failed-attempt counter or lockout
app.post('/auth/login', async (req, res) => {
  const { email, password } = req.body;
  const user = await db.users.findOne({ email });

  if (!user) {
    return res.status(401).json({ error: 'Invalid credentials' });
  }

  const valid = await bcrypt.compare(password, user.passwordHash);
  if (!valid) {
    // VULNERABLE: no failed-attempt counter — unlimited guesses
    return res.status(401).json({ error: 'Invalid credentials' });
  }

  req.session.userId = user.id;
  res.json({ ok: true });
});
// FIXED: Redis-based lockout — 5 failures triggers 15-minute lock
const redis = require('ioredis');
const client = new redis(process.env.REDIS_URL);

const MAX_ATTEMPTS = 5;
const LOCKOUT_WINDOW_SECONDS = 900; // 15 minutes

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

  // Check lockout before touching DB
  const lockKey = `lockout:${email.toLowerCase()}`;
  const attempts = await client.get(lockKey);
  if (parseInt(attempts || '0', 10) >= MAX_ATTEMPTS) {
    return res.status(429).json({ error: 'Account temporarily locked. Try again later.' });
  }

  const user = await db.users.findOne({ email: email.toLowerCase() });
  if (!user) {
    // Increment attempt counter even for non-existent accounts (prevent enumeration via lockout timing)
    await client.multi()
      .incr(lockKey)
      .expire(lockKey, LOCKOUT_WINDOW_SECONDS)
      .exec();
    return res.status(401).json({ error: 'Invalid credentials' });
  }

  const valid = await bcrypt.compare(password, user.passwordHash);
  if (!valid) {
    await client.multi()
      .incr(lockKey)
      .expire(lockKey, LOCKOUT_WINDOW_SECONDS)
      .exec();
    return res.status(401).json({ error: 'Invalid credentials' });
  }

  // Successful login — clear the lockout counter
  await client.del(lockKey);
  req.session.userId = user.id;
  res.json({ ok: true });
});
CRITICAL
SA-SKL-BRUTEFORCE-001 — MCP skill login endpoint has no failed-attempt counter or account lockout; an attacker can send unlimited password guesses against any account with no throttling, lockout, or CAPTCHA. Fix: use Redis INCR + EXPIRE to count failed attempts per normalized email; return HTTP 429 and block further attempts for 15 minutes after 5 consecutive failures; clear the counter on successful login. Detection: SkillAudit flags POST /auth/login and equivalent handlers that call bcrypt.compare() or equivalent without a preceding Redis or DB-based attempt counter check.

BRUTEFORCE-002 — Lockout bypass via IP rotation

Many brute force protections are implemented as a per-IP rate limit rather than a per-account lockout — or as a per-account lockout only, without an IP-level layer. Per-IP rate limits are bypassed by rotating through a pool of IP addresses (a botnet or residential proxy service); per-account-only lockouts are bypassed by trying one password per account across millions of accounts (password spraying). The correct approach combines both: a per-account lockout (catches targeted attacks against a single account) paired with a per-IP rate limit (catches credential stuffing from a single IP or botnet). For MCP skills where the user base is small (indie developers), a simple per-account lockout is usually sufficient, but it must be paired with a CAPTCHA after the first few failures to raise the cost of automation regardless of IP rotation.

// VULNERABLE: lockout keyed on username only — attacker rotates IPs to reset counter
// (or uses per-IP rate limit only — attacker rotates IPs to get fresh limits)
const lockKey = `lockout:${email}`; // ← Only email, no IP component

// IP rotation attack:
// Attempt 1 from 1.2.3.4: fail → lockout:user@ex.com = 1
// Attempt 2 from 1.2.3.5: fail → lockout:user@ex.com = 2
// ...
// Attempt 5 from 1.2.3.8: fail → lockout:user@ex.com = 5 → account locked
// Rotate to new IP pool, create new account alias: lockout:user@ex.com = 0
// (Note: email case variation also resets — see BRUTEFORCE-003)
// FIXED: dual-key lockout — per-account AND per-IP; CAPTCHA challenge after threshold
const accountLockKey = `lockout:account:${email.toLowerCase()}`;
const ipLockKey = `lockout:ip:${req.ip}`;

// Check both keys
const [accountAttempts, ipAttempts] = await Promise.all([
  client.get(accountLockKey),
  client.get(ipLockKey),
]);

if (parseInt(accountAttempts || '0', 10) >= MAX_ATTEMPTS) {
  return res.status(429).json({ error: 'Account temporarily locked. Try again later.' });
}

// Per-IP rate limit: 20 attempts per minute per IP across all accounts
if (parseInt(ipAttempts || '0', 10) >= 20) {
  return res.status(429).json({ error: 'Too many requests. Try again later.' });
}

// On failure: increment both keys
await client.multi()
  .incr(accountLockKey).expire(accountLockKey, LOCKOUT_WINDOW_SECONDS)
  .incr(ipLockKey).expire(ipLockKey, 60) // Per-IP: 1-minute window
  .exec();
HIGH
SA-SKL-BRUTEFORCE-002 — MCP skill brute force protection uses a per-account lockout without a per-IP rate limit layer; an attacker with access to a residential proxy pool can rotate IP addresses after each failed attempt, resetting the per-IP counter while the per-account counter never reaches the lockout threshold because each attempt comes from a different IP; or the protection uses only per-IP rate limiting which is entirely bypassed by IP rotation. Fix: implement both per-account lockout (keyed on normalized email) and per-IP rate limit (keyed on req.ip), with separate thresholds and windows; add CAPTCHA challenge after the first suspicious signal. Detection: SkillAudit flags login handlers with a lockout key that contains only the email and no IP component, and flags handlers with only an IP-based rate limit and no per-account counter.

BRUTEFORCE-003 — Email case normalization gap in lockout key

Email addresses are case-insensitive by standard (RFC 5321 section 2.4), but most databases and Redis keys are case-sensitive string comparisons. If the lockout key is built from the email string as supplied in the request body — without normalizing to lowercase — then user@example.com and USER@EXAMPLE.COM are different lockout keys even though they refer to the same account. An attacker who exhausts the attempt counter for user@example.com (5 failures, account locked) can immediately bypass the lockout by switching to User@Example.Com — a fresh Redis key with zero attempts. The fix is a one-liner: normalize the email to lowercase before constructing any lockout key, before any DB query, and before any comparison.

// VULNERABLE: lockout key uses email as-supplied (not normalized)
app.post('/auth/login', async (req, res) => {
  const { email, password } = req.body;

  // VULNERABLE: lockout key is case-sensitive
  const lockKey = `lockout:${email}`; // ← 'user@ex.com' != 'USER@EX.COM'

  const attempts = await client.get(lockKey);
  if (parseInt(attempts || '0', 10) >= MAX_ATTEMPTS) {
    return res.status(429).json({ error: 'Account temporarily locked.' });
  }

  // Case normalization only happens at DB query — lockout key already set above
  const user = await db.users.findOne({ email: email.toLowerCase() });
  // ...
  // Attack: exhaust lockout:user@ex.com with 5 failures,
  //         then continue with lockout:USER@EX.COM (fresh counter)
});
// FIXED: normalize email before any lockout key or DB operation
app.post('/auth/login', async (req, res) => {
  const { email, password } = req.body;

  // FIXED: normalize first, before constructing any keys
  const normalizedEmail = email.toLowerCase().trim();
  const lockKey = `lockout:${normalizedEmail}`; // ← case-invariant key

  const attempts = await client.get(lockKey);
  if (parseInt(attempts || '0', 10) >= MAX_ATTEMPTS) {
    return res.status(429).json({ error: 'Account temporarily locked.' });
  }

  // DB query also uses normalized email (consistent with registration normalization)
  const user = await db.users.findOne({ email: normalizedEmail });
  // ...
});
HIGH
SA-SKL-BRUTEFORCE-003 — MCP skill lockout key is constructed from the email address as supplied in the request body without normalizing to lowercase; since Redis keys are case-sensitive, an attacker who exhausts the lockout counter for user@example.com can immediately continue guessing by switching the email to USER@EXAMPLE.COM, User@Example.Com, or any other case variant — each is a distinct Redis key with a fresh attempt counter pointing to the same underlying account. Fix: call email.toLowerCase().trim() as the first operation in the login handler, before constructing any lockout key, DB query, or comparison; ensure the same normalization is applied at registration so the stored email matches the normalized form. Detection: SkillAudit flags lockout key constructions of the form lockout:${email} or lockout:${req.body.email} without a preceding .toLowerCase() call.

BRUTEFORCE-004 — Timing oracle via lockout vs invalid-credential response latency

Even a correct lockout implementation can leak information through response timing. If the lockout check returns HTTP 429 immediately (a Redis GET takes ~1ms) but the invalid-credential path runs a bcrypt comparison (takes ~300ms) before returning HTTP 401, an attacker can distinguish the two states by measuring response latency. This is a timing oracle: response time under 5ms means the account is locked (revealing the account exists and has been attacked), response time around 300ms means the credentials were checked but were wrong. The oracle reveals account existence — an attacker can enumerate which email addresses have accounts by triggering lockout and observing the timing switch. The fix is to perform a dummy bcrypt comparison on the lockout path to equalize response time regardless of lockout state.

// VULNERABLE: lockout path returns immediately (1ms), invalid-credential path takes 300ms
app.post('/auth/login', async (req, res) => {
  const normalizedEmail = req.body.email.toLowerCase().trim();
  const lockKey = `lockout:${normalizedEmail}`;
  const attempts = await client.get(lockKey);

  if (parseInt(attempts || '0', 10) >= MAX_ATTEMPTS) {
    // VULNERABLE: returns in ~1ms — timing reveals account is locked / exists
    return res.status(429).json({ error: 'Account temporarily locked.' });
  }

  const user = await db.users.findOne({ email: normalizedEmail });
  if (!user) {
    // VULNERABLE: bcrypt compare skipped for non-existent accounts — returns faster
    return res.status(401).json({ error: 'Invalid credentials' });
  }

  const valid = await bcrypt.compare(req.body.password, user.passwordHash); // ~300ms
  if (!valid) {
    await client.multi().incr(lockKey).expire(lockKey, 900).exec();
    return res.status(401).json({ error: 'Invalid credentials' });
  }
  // ...
});
// FIXED: uniform response time regardless of lockout state via dummy bcrypt compare
// A fixed bcrypt hash to compare against for non-existent or locked accounts
const DUMMY_HASH = '$2b$12$LRw.KMxMNhWJZ1mBFXqN8.DQg4P1fqjuSNKsJ5OqBEVFKSPj9R9gO';

app.post('/auth/login', async (req, res) => {
  const normalizedEmail = req.body.email.toLowerCase().trim();
  const lockKey = `lockout:${normalizedEmail}`;

  const [attempts, user] = await Promise.all([
    client.get(lockKey),
    db.users.findOne({ email: normalizedEmail }),
  ]);

  const isLocked = parseInt(attempts || '0', 10) >= MAX_ATTEMPTS;

  // Always run bcrypt compare — against real hash or dummy hash
  // This equalizes response time regardless of lockout or account existence
  const hashToCompare = (user && !isLocked) ? user.passwordHash : DUMMY_HASH;
  const valid = await bcrypt.compare(req.body.password, hashToCompare);

  if (isLocked) {
    return res.status(429).json({ error: 'Account temporarily locked. Try again later.' });
  }

  if (!user || !valid) {
    if (user) { // Only increment for existing accounts — prevent lockout DoS on enumeration
      await client.multi().incr(lockKey).expire(lockKey, 900).exec();
    }
    return res.status(401).json({ error: 'Invalid credentials' });
  }

  await client.del(lockKey);
  req.session.regenerate(() => {
    req.session.userId = user.id;
    res.json({ ok: true });
  });
});
MEDIUM
SA-SKL-BRUTEFORCE-004 — MCP skill login handler returns the lockout error response (HTTP 429) in ~1ms (Redis GET only) while returning the invalid-credential response (HTTP 401) in ~300ms (after bcrypt comparison); an attacker measuring response latency can distinguish the two states and determine (a) whether an account with that email exists, and (b) whether it is currently locked — a timing oracle enabling account enumeration without a successful login. Fix: always run a bcrypt comparison regardless of lockout state by comparing against a pre-computed dummy hash when the account does not exist or is locked; pair with Promise.all() for the lockout check and DB lookup so the bcrypt comparison starts immediately. Detection: SkillAudit flags login handlers where the lockout branch returns before any bcrypt.compare() call and the credential-check branch runs bcrypt.compare().

SkillAudit detection summary — SA-SKL-BRUTEFORCE

Pattern IDSeverityWhat SkillAudit flagsFix
BRUTEFORCE-001CRITICALbcrypt.compare() in login handler with no preceding Redis or DB-based attempt counter checkRedis INCR + EXPIRE lockout: 5 failures → 15-min lock; clear on success
BRUTEFORCE-002HIGHLockout key contains only the email (no IP component) or only an IP rate limit (no per-account counter)Dual-key lockout: per-account (email) + per-IP (req.ip); CAPTCHA after threshold
BRUTEFORCE-003HIGHLockout key built from ${email} or ${req.body.email} without a preceding .toLowerCase() callemail.toLowerCase().trim() as first operation; apply same normalization at registration
BRUTEFORCE-004MEDIUMLockout branch returns before any bcrypt.compare() while credential-check branch runs bcrypt.compare()Always run bcrypt against real or dummy hash; use Promise.all() for lockout + DB lookup

Related patterns: For magic link / passwordless token security gaps, see SA-SKL-MAGICLINK. For session fixation and session regeneration gaps in auth flows, see SA-SKL-SESSFIX. For credential exposure via environment variable logging, see SA-SKL-CREDEXP.