Password reset flows that leak accounts or trust the Host header
Last updated November 17, 2026
Steps
- Ask for a reset with a real email and a fake one. The message and the response time should be the same for both.
- Reset tokens must come from a secure random generator, be long, be stored safely (hashed), work only once, and expire. Request two resets and check the first link stops working.
- Build the reset link from a fixed site URL in your config, never from the incoming Host header. OWASP warns this enables Host header injection.
- On Supabase, call resetPasswordForEmail with a redirectTo that's on your project's Redirect URLs allow list, and use the exact production path rather than a broad wildcard.
- Add rate limits per account and per IP to the reset request, and add Referrer-Policy: no-referrer on the reset page so the token doesn't leak to other sites.
- After a reset, send a "your password was changed" email, don't log the user in automatically, and offer to sign out other sessions.
Why it matters
OWASP's Forgot Password Cheat Sheet calls password reset a common source of vulnerabilities, such as user enumeration. It recommends a consistent message and response time for existing and non-existing accounts, random, long, single-use tokens that expire, reset URLs that are hard-coded or checked against trusted domains, rate limiting, and asking whether to invalidate existing sessions.
Supabase's docs say redirect URLs must be on your allow list, and recommend setting the exact redirect path for your site URL in production even though wildcards are handy for local development and preview URLs.
Sources
OWASP Forgot Password Cheat Sheet — https://cheatsheetseries.owasp.org/cheatsheets/Forgot_Password_Cheat_Sheet.html
Supabase Docs: Redirect URLs — https://supabase.com/docs/guides/auth/redirect-urls
Supabase Docs: resetPasswordForEmail (JavaScript) — https://supabase.com/docs/reference/javascript/auth-resetpasswordforemail
Related patterns
- Open redirects after login or OAuth callbacks
- No rate limiting on login, signup or AI endpoints
- JWTs or session tokens stored in localStorage
- Passwords stored in plain text or with fast hashes
- Tokens and IDs generated with Math.random()
- Login and signup messages that reveal which accounts exist (account enumeration)
- Sessions that stay valid after logout, password change or timeout
- Race conditions let one coupon, gift card or credit be used twice
- Secrets compared with === (timing-unsafe token and signature checks)
- “Sign in with Google” that logs people into any account with the same email (unsafe account linking)
Found a problem you'd rather not fix yourself?
Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.
Get it fixed by StorenTechVibe Security Weekly
One email a week with new failure patterns and how to fix them.
By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.