Login lockout keyed only on email? Rate-limit by IP and account without locking users out
Updated · Applies to: Supabase, Lovable, Bolt, Cursor, v0, Replit, Claude Code, Next.js
TL;DR fix: A lockout counted only per email is a lock anyone can turn: in our test, 5 wrong passwords from an attacker locked the real user out, even with the right password from her own IP. It also misses password spraying (one guess per account), case variants of the email, and parallel requests. IP-only limits fail the other way: a forged X-Forwarded-For or a login to the attacker's own account resets them. Fix: if you use Supabase Auth from the browser, delete any homemade lockout (it's bypassed by calling the Auth API directly), keep Supabase's per-IP limits, and turn on CAPTCHA (plus leaked-password protection on Pro and MFA where you can). If you run your own login route, count every attempt atomically before checking the password on three keys: per IP, per IP + normalized email (short block), and per account (switch to CAPTCHA, never a hard lock). Take the IP only from your host's trusted header.
Steps
- Find where the lockout lives. Search the code for failed_attempts, login_attempts, lockout, locked_until, attempts and localStorage counters. Note what each one is keyed on (email, IP, both), whether it runs in the browser or on a server, and whether the browser can write to the table it uses.
- If you use Supabase Auth from the browser, remove the homemade lockout. A counter in React state, localStorage or a table the browser updates doesn't stop anyone: the attacker calls Supabase's /auth/v1/token endpoint directly with your public key. Rely on Supabase's built-in per-IP limits and add the protections that run on Supabase's side.
- Turn on Supabase's protections. Enable CAPTCHA (Turnstile or hCaptcha) under Authentication > Bot and Abuse Protection and pass captchaToken to signInWithPassword, signUp and resetPasswordForEmail. On Pro and above, turn on leaked password protection. Offer MFA. Check Authentication > Rate Limits instead of raising them.
- On your own login route, count three keys atomically before the password check. Per IP (all attempts, never reset by a success), per IP + normalized email (short block after about 5 failures), and per account (after about 10 failures from anywhere, require a CAPTCHA instead of locking). Use one atomic increment per key (Redis INCR or a Postgres upsert ... returning), not read-then-write.
- Get the IP from a header your host sets. Use the header your platform overwrites (Vercel's x-forwarded-for / x-real-ip, Cloudflare's CF-Connecting-IP), or the right-most X-Forwarded-For entry added by your own proxy. Never the left-most entry, which the client controls. If your server calls Supabase Auth for users, forward that IP with Sb-Forwarded-For.
- Test it. Five wrong passwords for a test user from one IP, then the right password from another IP must still work. A request with a fake X-Forwarded-For must not reset anything. Thirty parallel wrong attempts must still get only about five password checks.
What it looks like
An AI agent added “brute-force protection” to your login, and it looks something like this:
- A
login_attempts(orfailed_logins) table with anemailcolumn, afailurescount andlocked_until. - After 5 wrong passwords: “Account locked. Try again in 15 minutes.”
- Sometimes the counter lives in
localStorageor React state, or the browser writes to that table with your public key.
It feels safe. Then one of these happens:
- A user writes in: “I can’t log in, it says my account is locked, and I haven’t tried in days.”
- Your logs show thousands of failed logins, each against a different email, and nothing was ever locked.
- Or you went the other way, limited by IP, and a tester gets through with a header that changes on every request.
Why it happens
There are two different attacks, and each single key only stops one of them:
| Attack | What the attacker does | Email-only lockout | IP-only limit |
|---|---|---|---|
| Guessing one account | Many passwords against one email | Stops it | Stops it from one machine; bypassed with many IPs or a forged header |
| Spraying / credential stuffing | One or a few passwords against many emails | Never trips (1 try per account) | Stops it from one machine only |
| Lockout denial of service | Types wrong passwords for your user on purpose | Locks the real user out | Not affected |
In our test (details in What we verified):
- Email-only lockout (5 failures, 15 min): 5 wrong passwords from an attacker locked Alice out. She then got
423 Account lockedwith the correct password from her own IP. Five case/space variants of her email (Alice@,ALICE@," alice@"…) got 25 password checks instead of 5, because the user lookup ignored case and the counter didn’t. 30 parallel wrong passwords got 30 checks: the code read the count, checked the password, then wrote count + 1, so every request saw “0 failures”. A spray of one common password across 50 accounts found the one that used it and locked nothing. - IP-only limit (10 failures), IP from the left-most
X-Forwarded-For: with honest headers it blocked after 10. With a made-upX-Forwarded-Foron each request: 40 of 40 guesses checked. Resetting the counter on any successful login from that IP: the attacker logged into their own account every 9 guesses, and 40 of 40 guesses were checked.
OWASP’s Authentication Cheat Sheet says the failure counter should be tied to the account, not only the IP, and also warns that the lockout must not become a way to lock out other users. Its credential stuffing guidance says IP blocking shouldn’t be the main defense. You need both keys, and a soft response (CAPTCHA, delay) instead of a hard lock on the account.
What Supabase Auth already does
If your app signs in with supabase.auth.signInWithPassword() from the browser (most Lovable and Bolt apps do), the password check happens on Supabase’s servers, and Supabase already rate-limits it. From Supabase’s rate limits page (checked Nov 27, 2026):
| Endpoint | Limited by | Default |
|---|---|---|
/auth/v1/token (password, refresh token, ID token and PKCE grants) | IP address | 150 requests per 5 minutes, bursts up to 30 |
Sign-ups and sign-ins (signup, recover, resend, magiclink, otp, user) | IP address | 30 requests per 5 minutes, bursts up to 30 |
/auth/v1/verify | IP address | 30 requests per 5 minutes, bursts up to 30 |
| MFA challenge / verify | IP address | 15 per minute, bursts up to 30 (not customizable) |
| OTP / magic link, signup confirmation, password reset | User | one request per 60 seconds |
Past a limit Supabase returns 429 with the error code over_request_rate_limit (“Too many requests have been sent by this client (IP address)”). Note what isn’t there: the page lists no per-account limit on failed passwords. Supabase’s per-user option is the Password Verification hook, and the hooks page lists it for Teams and Enterprise plans only.
What that means for you:
- A lockout in the browser does nothing. The attacker never uses your login form. They call
/auth/v1/tokendirectly with your public key (it’s in your JS bundle, and that’s fine). A counter inlocalStorage, React state or a table the browser can write to only inconveniences real users. If the browser can update that table, an attacker can also lock any email or clear their own row. Same lesson as rules enforced only in the frontend. - Turn on CAPTCHA. Supabase supports hCaptcha and Cloudflare Turnstile for sign-in, sign-up and password reset: Authentication > Bot and Abuse Protection > Enable CAPTCHA protection, then pass the token:
const { data, error } = await supabase.auth.signInWithPassword({
email,
password,
options: { captchaToken }, // from the Turnstile / hCaptcha widget
})
- Leaked password protection (checks new passwords against Have I Been Pwned) is Pro plan and above. It is the main defense against the spray that rate limits can’t stop.
- Offer MFA, at least for admins.
- If your login goes through your own server (a Next.js route or Edge Function that calls
signInWithPasswordfor the user), Supabase sees your server’s IP for everyone, so all your users share one bucket and one attacker can get everyone 429s. The docs’ fix: enable IP Address Forwarding under Authentication > Rate Limits, and send the user’s IP in theSb-Forwarded-Forheader on a client made with a secret key (publishable and legacyanon/service_rolekeys aren’t supported). Use the trusted IP (see Step 3), and don’t reuse that secret-key client for user data queries: it bypasses RLS.
Step 1: the 2-minute check
# Where is the lockout, and what is it keyed on?
rg -n -i "login_attempts|failed_login|failedAttempts|lockout|locked_until|attempts" --glob '!node_modules'
# Is it in the browser?
rg -n -i "localStorage.*(attempt|lock)|useState.*(attempt|lock)" src
# Which IP does the server trust? (leftmost X-Forwarded-For is client-controlled)
rg -n -i "x-forwarded-for|x-real-ip|cf-connecting-ip|remoteAddress|request\.ip" --glob '!node_modules'
Then answer four questions for each counter you find:
- Key: email only, IP only, or both? Is the email trimmed and lowercased before it’s used as a key?
- Where: browser (useless), or server?
- Atomic? Does the code read the count, check the password, then write count + 1? That’s a race.
- Response: hard lock of the account (DoS), or a block on that IP + account and a CAPTCHA/delay for the account?
And one test anyone can run: five wrong passwords for a test account in one browser, then the right password in another network (phone on mobile data). If the second login is refused, you have the DoS.
Step 2: the combined limit (your own login route)
Only needed if your server checks passwords (custom auth with a users table), or wraps Supabase Auth in a server route. Three counters, each incremented before the password check so parallel requests can’t slip past:
| Key | Counts | Limit (our example) | When over |
|---|---|---|---|
ip:<ip> | every attempt, success or not; never reset by a success | 30 per 15 min | 429 for that IP |
pair:<ip>:<email> | attempts on this account from this IP; reset on success | 5 per 15 min | 429 for that IP on that account only |
acct:<email> | attempts on this account from anywhere; reset on success | 10 per hour | require CAPTCHA, don’t lock |
The email key is email.normalize('NFKC').trim().toLowerCase(). Unknown emails go through the same counters and a dummy hash, so the response (and timing) doesn’t reveal which accounts exist. Return the same “Invalid email or password” for both.
A Postgres counter that’s atomic under concurrency (one statement, no read-then-write). On Supabase, put it behind your server and keep it away from the browser:
create table public.rate_limits (
key text primary key,
window_start timestamptz not null,
hits int not null
);
alter table public.rate_limits enable row level security; -- no policies: browser roles see nothing
revoke all on public.rate_limits from anon, authenticated;
create function public.rl_hit(p_key text, p_window_seconds int) returns int
language sql as $$
insert into public.rate_limits as r (key, window_start, hits) values (p_key, now(), 1)
on conflict (key) do update set
hits = case when r.window_start < now() - make_interval(secs => p_window_seconds)
then 1 else r.hits + 1 end,
window_start = case when r.window_start < now() - make_interval(secs => p_window_seconds)
then now() else r.window_start end
returning hits;
$$;
create function public.rl_reset(p_key text) returns void
language sql as $$ delete from public.rate_limits where key = p_key $$;
revoke execute on function public.rl_hit(text, int), public.rl_reset(text) from public, anon, authenticated;
grant execute on function public.rl_hit(text, int), public.rl_reset(text) to service_role;
The revoke matters: Supabase grants EXECUTE on new functions to anon by default, and a callable rl_reset would let anyone wipe their own counter (more on that). Old rows can be deleted by a daily cron job. With Redis, the same idea is INCR + EXPIRE (Supabase has an Upstash example).
The login route (Next.js shown; same logic anywhere):
import { createClient } from '@supabase/supabase-js'
import 'server-only'
const admin = createClient(process.env.SUPABASE_URL!, process.env.SUPABASE_SECRET_KEY!) // server only, counters only
const LIM = { ip: 30, ipWin: 900, pair: 5, pairWin: 900, acct: 10, acctWin: 3600 }
const hit = async (key: string, win: number) => {
const { data, error } = await admin.rpc('rl_hit', { p_key: key, p_window_seconds: win })
if (error) throw error // fail closed
return data as number
}
export async function POST(req: Request) {
const { email, password, captchaToken } = await req.json()
const ip = clientIp(req) // Step 3
const acct = String(email).normalize('NFKC').trim().toLowerCase()
const tooMany = () => Response.json({ error: 'Too many attempts. Try again later.' }, { status: 429 })
if ((await hit(`ip:${ip}`, LIM.ipWin)) > LIM.ip) return tooMany()
if ((await hit(`pair:${ip}:${acct}`, LIM.pairWin)) > LIM.pair) return tooMany()
if ((await hit(`acct:${acct}`, LIM.acctWin)) > LIM.acct && !(await captchaValid(captchaToken, ip)))
return Response.json({ error: 'challenge_required' }, { status: 401 }) // show the CAPTCHA, don't lock
const ok = await checkPassword(acct, password) // your hash check; run a dummy hash for unknown emails
if (!ok) return Response.json({ error: 'Invalid email or password' }, { status: 401 })
await admin.rpc('rl_reset', { p_key: `pair:${ip}:${acct}` })
await admin.rpc('rl_reset', { p_key: `acct:${acct}` })
// ...create the session
return Response.json({ ok: true })
}
captchaValid verifies the Turnstile or hCaptcha token on the server with your CAPTCHA provider. Also email the user when their account hits the CAPTCHA step (Supabase’s hook docs suggest notifying rather than blocking), and log every 429.
Step 3: get the real client IP
The IP key is only as good as the IP. X-Forwarded-For is a list, and the left-most entry is whatever the client typed. MDN says security uses like rate limiting must only use addresses added by a proxy you trust. Pick the one source that matches where you deploy:
function clientIp(req: Request): string {
// Pick ONE line for your host. Don't chain fallbacks: a header your host doesn't set
// (e.g. cf-connecting-ip when you're not behind Cloudflare) can be sent by the attacker.
return req.headers.get('x-real-ip') ?? 'unknown' // Vercel (Vercel overwrites x-forwarded-for / x-real-ip)
// return req.headers.get('cf-connecting-ip') ?? 'unknown' // behind Cloudflare (origin only reachable via Cloudflare)
// return xff.split(',').at(-1)!.trim() // your own single reverse proxy appends the client IP
}
- Vercel says it overwrites
X-Forwarded-Forto prevent spoofing, andx-real-ipis identical. - Cloudflare sends the visitor IP in
CF-Connecting-IP. That’s only trustworthy if your origin can’t be reached directly. - Many people share an IP (offices, schools, mobile carriers), so keep the per-IP limit generous and the per-IP + account limit tight. An IPv6 user often controls a whole block of addresses; keying IPv6 by its /64 prefix is our suggestion, not something we tested.
- A coarse per-IP rule at the edge is a cheap backstop: Cloudflare’s Free plan includes 1 rate limiting rule counted by IP, with a 10-second period and 10-second timeout. It doesn’t replace the per-account logic.
On Supabase Teams or Enterprise: the Password Verification hook
The Password Verification hook runs after Supabase checks a password and gets user_id and valid. It can return continue, reject, or an error with an HTTP code. It’s keyed by user, so it has the same DoS risk as an email-only lockout, and Supabase’s own page warns that you “can unintentionally block legitimate users” and suggests notifying instead of blocking. Use it for a short delay or an email, not a lock.
Heads-up: the “Limit failed password verification attempts” SQL example on that page did not run in our Postgres 17 test (copied Nov 27, 2026). Every call, including valid: true, failed with argument of IS TRUE must be type boolean, not type jsonb. With only that line fixed, the first failed attempt failed with column reference "last_failed_at" is ambiguous. This version ran (not tested inside Supabase Auth itself):
create table public.password_failed_verification_attempts (
user_id uuid primary key,
last_failed_at timestamptz not null default now()
);
create function public.hook_password_verification_attempt(event jsonb)
returns jsonb language plpgsql as $$
declare
v_user_id uuid := (event->>'user_id')::uuid;
v_last timestamptz;
begin
if (event->>'valid')::boolean then
return jsonb_build_object('decision', 'continue');
end if;
select f.last_failed_at into v_last
from public.password_failed_verification_attempts f
where f.user_id = v_user_id;
if v_last is not null and now() - v_last < interval '10 seconds' then
return jsonb_build_object('error', jsonb_build_object(
'http_code', 429, 'message', 'Please wait a moment before trying again.'));
end if;
insert into public.password_failed_verification_attempts (user_id, last_failed_at)
values (v_user_id, now())
on conflict (user_id) do update set last_failed_at = now();
return jsonb_build_object('decision', 'continue');
end;
$$;
grant execute on function public.hook_password_verification_attempt(jsonb) to supabase_auth_admin;
revoke execute on function public.hook_password_verification_attempt(jsonb) from authenticated, anon, public;
grant all on table public.password_failed_verification_attempts to supabase_auth_admin;
revoke all on table public.password_failed_verification_attempts from authenticated, anon, public;
In our test it returned continue for a valid password and for the first failure, the 429 error for a second failure right after, continue again after 11 seconds, and anon got permission denied calling it.
But know what it does and doesn’t do. It also returned continue for a correct password sent right after a failure, during the 10-second wait. That’s the design (the hook runs after the password check and lets valid passwords through), so it changes the error a guesser sees but doesn’t slow a script that ignores the 429s. Making it also refuse valid passwords during the wait would slow guessing, but then anyone could keep a user locked out by sending one wrong password every 10 seconds, and the hook only gets user_id and valid, no IP, so it can’t do the per-IP + account split. Our take: use the hook to notify the user (as Supabase suggests) and rely on CAPTCHA and Supabase’s per-IP limits for throttling.
What the combined approach did in our test
Same harness, same attacks, with the three counters above (all numbers from run.out.txt):
- Attacker’s 8 wrong passwords for Alice: 5 checked, then 429. Alice from her own IP with the right password: 200.
- 5 email case variants × 5: 5 password checks in total (was 25).
- 30 parallel wrong passwords: 5 password checks (was 30).
- 40 guesses with a fake
X-Forwarded-Foreach time: 5 checks (was 40). Logging into the attacker’s own account in between: 5 checks (was 40). - 12 wrong passwords for Alice from 12 different IPs: then Alice with the right password but no CAPTCHA got
challenge_required; with the CAPTCHA, 200. The attacker with a CAPTCHA and a wrong password: still 401. - Spray, one common password × 50 accounts from one IP: stopped at 30 attempts (the weak account was #40, so not found). From 50 different IPs, one try each: all 50 checked, and the weak account was found. Rate limits don’t stop a distributed spray: that’s what CAPTCHA, leaked-password protection and MFA are for.
Paste this into Lovable, Bolt, Cursor or Claude Code
Our login has brute-force "protection" that locks an account after N failed attempts keyed
only on the email (or only on IP). That lets anyone lock out any user and is bypassable.
Fix it like this, and show me the diff before applying:
1. Find every lockout/attempt counter (login_attempts, failed logins, lockout, locked_until,
localStorage/React state counters) and tell me what it's keyed on and where it runs.
2. If login uses supabase.auth.signInWithPassword from the browser: delete the browser-side
lockout and any table the browser writes attempts to. Add Cloudflare Turnstile (or
hCaptcha) and pass options: { captchaToken } to signInWithPassword, signUp and
resetPasswordForEmail. Tell me to enable CAPTCHA under Authentication > Bot and Abuse
Protection. Don't change Supabase's rate limits.
3. If login goes through our own server route: count three keys with ONE atomic increment
each, BEFORE checking the password: ip (30/15 min, all attempts, never reset on success),
ip+normalized email (5/15 min -> 429), normalized email (10/hour -> require CAPTCHA, never
a hard lock). Normalize email with normalize('NFKC').trim().toLowerCase(). Reset only the
pair and account counters on success. Use a Postgres function (revoke execute from public,
anon, authenticated) or Redis INCR, never read-then-write.
4. Get the client IP from the one header our host sets (Vercel: x-real-ip; Cloudflare:
cf-connecting-ip). Never the left-most X-Forwarded-For value. If the server calls Supabase
Auth for users, send that IP as Sb-Forwarded-For with the secret key, server-only.
5. Same error text for unknown email and wrong password. Log every 429 and email the user
when their account reaches the CAPTCHA step.
6. Give me tests: 5 wrong passwords from IP A, then the right password from IP B succeeds;
a fake X-Forwarded-For doesn't reset anything; 30 parallel wrong attempts run at most 5
password checks.
What we verified
- Tested locally (Nov 27, 2026; Node 22.23.3 HTTP login server + throwaway PostgreSQL 17.12 cluster, node-postgres 8.23.1; scrypt password hashes; each “IP” is a real loopback source address (127.0.0.x); the CAPTCHA is a stand-in header;
research/login-lockout-test/run.sh, outputrun.out.txt). This is a custom-auth stand-in, not Supabase Auth:- Email-only lockout (5 failures): 5 attacker failures, then the real user with the correct password from another IP got 423. Five case/space variants × 5: 25 password checks. 30 concurrent wrong passwords: 30 checks. Spray of 1 password × 50 accounts: found the weak one, 0 accounts locked.
- IP-only (10 failures, left-most
X-Forwarded-For, reset on success): honest headers 10 checks then 429; fake header each request 40/40 checks; own-account login every 9 guesses 40/40 checks. - Combined (30/IP/15 min, 5/IP+account/15 min, 10/account/h → CAPTCHA; atomic
rl_hitbefore the check): the numbers in the section above. Counter table and functions:anonandauthenticatedgot permission denied on both;service_roleallowed. - Supabase’s password verification hook example, copied verbatim: failed on every call with
argument of IS TRUE must be type boolean, not type jsonb; with that line fixed, the first failure hitcolumn reference "last_failed_at" is ambiguous. Our corrected version: continue / continue / 429 / continue after 11 s, andcontinuefor a correct password sent during the 10-second wait;anondenied. Run on plain Postgres with a stand-insupabase_auth_adminrole, not inside Supabase Auth.
- Docs-based, not tested on a real Supabase project (sources below, fetched Nov 27, 2026, all HTTP 200; list in
research/login-lockout-2026-11-27.md, copies inresearch/login-rate-limit-docs/): Supabase’s per-IP limits and defaults, 429 /over_request_rate_limit, no per-account lockout on the rate limits page,Sb-Forwarded-For(secret key, must be enabled), CAPTCHA providers and setting location, leaked password protection on Pro+, Password Verification hook on Teams/Enterprise.options.captchaTokenonsignInWithPasswordwe also read in the supabase-js 2.119.2 type definitions. Vercel and Cloudflare header behaviour, Cloudflare plan limits, OWASP and NIST guidance are from their pages. We did not send any traffic to Supabase, Vercel or Cloudflare. The Next.js route above mirrors the tested logic but wasn’t itself run. - Our reading, not documented: that AI builders often generate email-keyed or browser-side lockouts; the example limits (30 / 5 / 10); keying IPv6 by /64.
Related: your AI bill spiked: rate limits and spend caps, rules enforced only in the frontend, RLS not working because the server uses the service_role key, Sign in with Google lets anyone in, and Lovable security findings, explained.
When to get help
Get help if users are getting locked out or 429s at login and you can't tell whether it's an attack, if your login runs through a server route and you're not sure which IP Supabase sees, or if an agent built its own auth with a users table and password hashes and you want a second pair of eyes before launch.
Want us to look at your app?
VibeCPR Rescue Reports are launching soon: we scan your repo and live app, and a human verifies every critical finding. Join the waitlist for early access and founder pricing. You'll also get Patch Notes, our weekly fixes newsletter.
FAQ
Why is locking an account after 5 failed logins a problem?
Because anyone who knows or guesses a user's email can do it on purpose. In our test, 5 wrong passwords from an attacker's IP locked the account, and the real user then got "Account locked" with the correct password from her own IP. OWASP's Authentication Cheat Sheet warns that a lockout must not let attackers lock out other users. Use a short block per IP + account and a CAPTCHA or growing delay per account instead of a hard lock.
Does Supabase Auth lock accounts after failed password attempts?
Supabase's rate limits page (checked Nov 27, 2026) lists limits by IP address for password sign-in: the /auth/v1/token endpoint allows 150 requests per 5 minutes with bursts up to 30, and returns 429 past that. It lists no per-account lockout. For per-user rules there is the Password Verification hook, on Teams and Enterprise plans. On any plan you can add CAPTCHA to sign-in, sign-up and password reset.
Is rate limiting login by IP address enough?
No. OWASP's credential stuffing guidance says IP blocking shouldn't be the main defense because it's easy to get around with proxy networks. In our test, a spray of one common password across 50 accounts from 50 different IPs found the account that used it, even with every per-IP and per-account limit on. Per-IP limits slow single-machine attacks; CAPTCHA, breached-password checks and MFA handle the distributed ones.
Can attackers fake their IP with X-Forwarded-For to dodge my rate limit?
Yes, if your code reads the left-most entry. MDN says only addresses added by a proxy you trust are safe for rate limiting. In our test a login that took the left-most X-Forwarded-For value let 40 out of 40 guesses through with a new fake IP each time. Use the header your host overwrites (Vercel's x-forwarded-for, Cloudflare's CF-Connecting-IP) or your own proxy's right-most entry.
Why do all my users get "Too many requests" when my server calls Supabase Auth?
If your login runs through a server route or proxy, Supabase sees your server's IP for every user, so everyone shares one per-IP bucket. Supabase's docs say to send the end user's IP in the Sb-Forwarded-For header, using a secret API key (publishable and legacy keys aren't supported), after enabling IP Address Forwarding under Authentication > Rate Limits.
Should I add a CAPTCHA to my Supabase login?
For a public app, yes. Supabase supports hCaptcha and Cloudflare Turnstile for sign-in, sign-up and password reset: enable it under Authentication > Bot and Abuse Protection and pass options: { captchaToken } in the auth call. OWASP treats CAPTCHA as defense in depth, not a cure, and suggests it can be shown only after a few failed attempts if you run your own login.
How many failed login attempts should I allow?
There is no single number. NIST SP 800-63B-4 sets an upper bound of 100 consecutive failures on one account and suggests bot challenges and growing waits (for example 30 seconds up to an hour) to avoid locking the real user out. Our tested example uses 30 attempts per IP per 15 minutes, 5 per IP + account per 15 minutes, and a CAPTCHA after 10 failures per account per hour. Tune to your traffic and tell users how long to wait.
Sources
- Supabase docs: Auth rate limits (per-IP token bucket, /auth/v1/token 150 per 5 min, Sb-Forwarded-For)
- Supabase docs: Enable CAPTCHA protection (hCaptcha, Turnstile)
- Supabase docs: Password security (leaked password protection, Pro and above)
- Supabase docs: Auth hooks (Password Verification Attempt: Teams and Enterprise)
- Supabase docs: Password verification hook
- Supabase docs: Auth error codes (over_request_rate_limit)
- Supabase docs: Multi-factor authentication
- Supabase docs: Rate limiting Edge Functions (Upstash Redis)
- OWASP Authentication Cheat Sheet (login throttling, account lockout)
- OWASP Credential Stuffing Prevention Cheat Sheet (IP mitigation)
- NIST SP 800-63B-4: rate limiting (throttling)
- MDN: X-Forwarded-For (security and privacy concerns)
- Vercel docs: Request headers (x-forwarded-for, x-real-ip)
- Cloudflare docs: HTTP headers (CF-Connecting-IP)
- Cloudflare docs: Rate limiting rules (plan availability)
Related fixes
- AI agent pushed API keys to GitHub? git commit --no-verify skipped your pre-commit hook
- Fix a surprise AI API bill: rate limits and spend caps
- Your app is public to anyone with the link: a share link is not a login
- Triage Bolt's "RLS Policy Always True" warning: when it's fine and how to fix it
- Fix secrets leaked via Claude Code .claude/settings.local.json
- Fix "Your Cloud Firestore database has insecure rules" (Firebase email)
- Fix Lovable "Invalid API key" after rotating Supabase keys (anon, publishable, secret)
- Lovable won't publish because of security findings? What each finding means and how to fix it
- "Sign in with Google" lets anyone in: restrict who can use your app (allowlist, domain check, RLS)
- Fix Stripe sk_live keys left in MCP or agent config
- Fix Stripe webhook "No signatures found matching the expected signature for payload"
- Fix Supabase auth redirecting to localhost after deploy
- Fix Supabase Edge Function "blocked by CORS policy" (preflight)
- Fix Supabase "infinite recursion detected in policy for relation" (42P17) in RLS
- Form says success but no row in Supabase (or Stripe webhook returns 200 but writes nothing)
- Fix "new row violates row-level security policy for table" (Supabase)
- Supabase only returns 1,000 rows? Fix the silent max rows limit in Lovable and Bolt apps
- Fix Supabase "permission denied for table" (42501) on new tables after Oct 30, 2026
- Fix a Supabase public Storage bucket that lets anyone list or download your files
- Supabase Realtime leaking rows or not receiving changes: fix RLS and the publication
- Supabase RLS not working on the server? Your API uses the service_role or secret key
- Fix Supabase RLS policy USING (true) that makes a table publicly readable
- Your app's rules only live in the frontend: move them into Supabase
- Fix a Supabase SECURITY DEFINER function anyone can call through /rest/v1/rpc
- Fix Supabase .single() "JSON object requested, multiple (or no) rows returned" (PGRST116)
- Stop Supabase users from upgrading their own plan or making themselves admin
- Fix a Supabase view that bypasses RLS: security_invoker and revoking anon write grants
- Fix "404: NOT_FOUND" on refresh in a React/Vite app on Vercel (vercel.json rewrite)
- Fix "Module not found: Can't resolve" on Vercel (works locally)
- Is my Vite dev server exposed? Check --host / server.host and patch the RCE (GHSA-p4f5-76q4-ffq7)