Account lockout is implemented after failed attempts
Why it matters
IP-based rate limiting alone does not stop a targeted attack on a specific account from a botnet that uses one password attempt per IP address. CWE-307 and NIST 800-63B §5.2.2 require per-account throttling in addition to per-IP limits. PCI-DSS Req-8.3.4 requires temporary lockout after no more than 10 consecutive failures. OWASP A07 lists credential stuffing and brute-force susceptibility as named failure modes. Supabase Auth provides endpoint rate limiting but does not implement configurable per-account lockout — custom lockout logic is required unless you use Clerk or Auth0 with Attack Protection enabled.
Severity rationale
High because per-account lockout is the only control that stops a distributed brute-force attack targeting a single user account from many IP addresses simultaneously.
Remediation
Track failed attempts on the user record and lock the account temporarily after exceeding the threshold:
async function recordFailedAttempt(userId: string) {
const user = await db.user.update({
where: { id: userId },
data: {
failedLoginAttempts: { increment: 1 },
lastFailedLoginAt: new Date()
}
})
if (user.failedLoginAttempts >= 5) {
await db.user.update({
where: { id: userId },
data: { lockedUntil: new Date(Date.now() + 15 * 60 * 1000) }
})
await sendLockoutEmail(user.email)
}
}
Check lockedUntil at the start of the login handler, before the password comparison. Reset the counter to zero on a successful login.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Authentication Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-307 — Improper Restriction of Excessive Authentication Attempts
- owasp:2021 · A07
- nist:rev4 · SP-800-63B §5.2.2 — Rate Limiting (Throttling)
- pci-dss:4.0 · Req 8.3.4
- soc2:2017 · CC6.1 — Logical access security software, infrastructure, and architectures
Taxons
History
- 2026-04-18·v1.0.0·Initial import from saas-authentication·automated
- 2026-07-06·v1.0.1·Add SOC 2 TSC mapping (CC6.1) from the verified compliance crosswalk register (docs/compliance/).·by soc2-mapping-enrichment-ship-2