Home / patterns

Password reset flows that leak accounts or trust the Host header

Quick answer: Home-made "forgot password" flows in AI-built apps often reveal which emails have accounts, use reset links that never expire or can be reused, build the reset link from the request's Host header, or redirect to any URL after the reset. Each one can help someone take over an account.

Last updated November 17, 2026

Steps

  1. Ask for a reset with a real email and a fake one. The message and the response time should be the same for both.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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

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 StorenTech

Vibe 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.