Deutsch
Fix libraryHighAuth · Password reset

Password reset link that redirects to any URL

A broad Supabase redirect allow list or a reset link built from untrusted input can send reset links to sites you don’t own. Pin them to exact URLs.

By Tim GeithnerPublished 4 min read

ShipRely's Security audit checks for this today.

Short answer

A password reset link is a key to the account for a short time. If your Supabase redirect allow list contains broad wildcards such as https://*.vercel.app/** or **, or your code builds the reset URL from input it doesn’t control, the link can lead to a site that isn’t yours. List only exact production URLs, keep the reset link on your own Site URL with a fixed next path, and check what the email really contains.

Ask an AI about this page:ChatGPTClaude

On this page

A password reset link that can redirect to any URL is a reset flow whose final destination isn’t pinned to your own site. In Supabase apps it usually comes from a redirect allow list with broad wildcards, or from an email template that sends users to whatever redirectTo was requested. The reset link carries what’s needed to sign in and set a new password, so if it can end on a host you don’t control, the account can end there too. That’s why it is rated high: it attacks the one flow meant to rescue an account.

Why it matters

Every Supabase auth email (password reset, magic link, sign-up confirmation) takes the user to a redirect URL. The client sends one as redirectTo, and Supabase’s docs say it “should match” the Redirect URLs list in your project’s URL Configuration. That list is the real control: anyone can ask Supabase for a reset email with their own redirectTo, so the only thing that matters is which URLs the list accepts.

The list supports wildcards. In Supabase’s patterns, * matches anything except . and /, and ** matches anything at all. That’s handy for preview deployments, and the docs show scoped examples such as https://*-<team-or-account-slug>.vercel.app/**. The defect is a pattern that is wider than your own hosts:

  • ** or https://** matches every website.
  • https://*.vercel.app/**, https://*.netlify.app/** or https://*.lovable.app/** match every project on that platform, including ones other people create.
  • http://localhost:3000/** left in production is a smaller issue, but it has no business there either.

Supabase’s own advice is to set the exact redirect URL for your site in production. The email templates matter too: the redirect docs show how to replace {{ .SiteURL }} with {{ .RedirectTo }} in a template. With a broad allow list, that makes the link in the email point straight at whatever host matched.

OWASP’s Forgot Password Cheat Sheet makes the same point for apps that build reset URLs on the server: don’t rely on the Host header, and either hard-code the URL or validate it against trusted domains.

How to find it in your app

  1. In the Supabase dashboard, open Authentication → URL Configuration. Check the Site URL is your production URL and read every entry under Redirect URLs. Any pattern that could match a host you don’t own is the defect.
  2. Open the email templates in the Auth settings, especially Reset password. Note where the link points: {{ .ConfirmationURL }}, {{ .SiteURL }}/… or {{ .RedirectTo }}/….
  3. Search your code for how the reset is requested:
Search your repository
grep -rn "resetPasswordForEmail\|redirectTo\|emailRedirectTo" src app supabase 2>/dev/null
grep -n "site_url\|additional_redirect_urls" supabase/config.toml 2>/dev/null

Look for a redirectTo taken from a URL parameter, a form field or a request header rather than a fixed value.

How to fix it

Pin the allow list. Keep the Site URL on your production domain and list the exact pages auth emails may lead to, for example https://your-app.example/update-password and https://your-app.example/auth/confirm. If you need preview URLs, scope them to your own team or project slug the way Supabase’s Vercel and Netlify examples do, never to the whole platform. The CLI config describes additional_redirect_urls as a list of exact URLs:

Safesupabase/config.toml
[auth]
site_url = "https://your-app.example"
additional_redirect_urls = [
  "https://your-app.example/update-password",
  "https://your-app.example/auth/confirm",
]

Supabase’s docs point to this file for local development and self-hosted projects; for your hosted project, change the list in the dashboard as well.

Fix the reset target in code. Request the reset with a fixed URL, not one built from input:

Safesrc/pages/ForgotPassword.tsx
await supabase.auth.resetPasswordForEmail(email, {
  // Fixed value, listed exactly in Redirect URLs.
  redirectTo: "https://your-app.example/update-password",
});

Keep the email link on your own site. For server-side apps, Supabase’s password guide uses a reset template whose link points to {{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash }}&type=recovery&next=/account/update-password. The token goes to your own Site URL, and next is a fixed path. If your confirm route reads next, keep the same-host check from that guide or use the helper from open redirect after login.

Pin password reset redirects

Find every call to supabase.auth.resetPasswordForEmail, signInWithOtp, signUp (emailRedirectTo) and signInWithOAuth. Make each redirectTo a fixed URL on our production domain (or built from a single configured site URL constant), never from a URL parameter, form field or request header. If there is an /auth/confirm or callback route that reads a next parameter, only accept paths on our own origin and fall back to “/“.

Update supabase/config.toml so site_url is our production URL and additional_redirect_urls lists only exact URLs we use, without ** or platform-wide wildcards. Then list the exact URLs I must enter under Authentication → URL Configuration in the Supabase dashboard, and tell me what the reset password email template should link to.

Check that the fix works

  1. Request a reset for your own test account with a redirectTo that isn’t yours, using your project’s public publishable key:
Request a test reset with a foreign redirect
curl -X POST "https://your-project.supabase.co/auth/v1/recover?redirect_to=https://example.com/" \
  -H "apikey: <your publishable key>" -H "Content-Type: application/json" \
  -d '{"email":"test-account@your-app.example"}'
  1. Open the email. Neither the link nor the address it ends on may mention example.com; it must lead to your own Site URL.
  2. Use the normal Forgot password form for the same account. The link must open your update-password page, and setting a new password must work.
  3. Read the Redirect URLs list once more: every entry must be a host you own.

Frequently asked questions

Are wildcards in the redirect list always wrong?

No. Supabase documents them for local development and preview deployments. The problem is a pattern that also matches hosts you don’t own, such as every subdomain of a shared hosting domain. Supabase recommends the exact URL for your site in production.

My app passes window.location.origin as redirectTo. Is that the bug?

Not by itself: in the browser that’s the address the user is really on. The allow list is the control that matters, because anyone can call the reset endpoint with their own redirectTo. Server code that builds the URL from the Host header is riskier; OWASP says to hard-code the URL or validate it against trusted domains.

Does this also affect magic links and sign-up confirmations?

Yes. They use the same redirect allow list and the same email templates, so the same fix covers them.

Sources

  1. 1.Redirect URLs — Supabase Docs
  2. 2.Password-based Auth — Supabase Docs
  3. 3.CLI configuration reference — Supabase Docs
  4. 4.Forgot Password Cheat Sheet — OWASP Cheat Sheet Series
  5. 5.CWE-640: Weak Password Recovery Mechanism for Forgotten Password — MITRE

Find this in your own app

ShipRely reads your repository (read-only), proves each finding with file and line, and gives you a fix prompt to paste into your AI builder.

Run a demo audit
  • Read-only access to your repository
  • Every finding with file and line
  • Fix prompts for Lovable, Cursor, Claude Code and Bolt