The greeter who walks you anywhere
Watch it happen
Alice follows a link that starts at the real bank. The greeter walks her to the fake branch named on the slip.
Alice walks up to the real bank’s front door, where the greeter takes people where they need to go.
In bank terms and app terms
| In the bank | In your app |
|---|---|
?next= or ?redirect_to= | |
Are you exposed?
You redirect to a value from the URL, like ?next=,?redirect=,?return_url=or?callback=.You “validate” by checking that the value starts with /, or only that it contains your domain.Your login or OAuth callback sends people back to whatever URL they came from without checking it.
Redirect only to relative paths on your own site, or to a fixed allowlist of known URLs. Resolve the value with new URL(value, yourOrigin)and check the result’s origin equals yours. A simple starts-with check can be fooled.If it fails the check, fall back to /and never to the supplied address.
It has happened to real companies
Google (ongoing) — Google's redirect endpoints (google.com/url?q=...) have been repeatedly abused in phishing campaigns to make malicious links appear to originate from google.com.
What it looks like in code
// GOOD: Resolve against your own origin, then compare origins.
// A starts-with check on "http" or "//" is not enough: browsers treat a
// backslash as a slash, so "/\/evil.com" slips past it.
const redirectTo = searchParams.get("redirect_to") || "/"
const target = new URL(redirectTo, request.url)
if (target.origin !== new URL(request.url).origin) {
return NextResponse.redirect(new URL("/", request.url))
}
return NextResponse.redirect(target)
Ask your AI tool to fix it
Paste this into Cursor, Claude, Lovable, Bolt or whatever you build with.
Find every place this app redirects using a value from the request (next, redirect, redirect_to, return_url, callback). For each one, resolve the value against our own origin with new URL(value, origin) and only redirect if the resulting origin equals ours. Otherwise redirect to "/". Do not rely on startsWith checks, because backslashes and protocol-relative URLs can bypass them. List what you changed.Where this comes from
The facts, figures and fixes on this page were checked against these sources on 25 Oct 2026. They are linked so you can check for yourself.
- Unvalidated Redirects and Forwards Cheat SheetOWASPAllowlist parsed URLs; prefix or contains checks get bypassed
- CWE-601: URL Redirection to Untrusted Site (Open Redirect)MITREOpen redirect lets a trusted domain send users to phishing pages; allowlist fix
- Open redirection (reflected)PortSwiggerTrusted-domain link looks authentic; use relative paths or a server-side allowlist
- Adobe and Google Open Redirects Abused by Phishing CampaignsBleepingComputer2019 phishing via google.com/url?q= redirect to a fake Office 365 login
- Another day, another phishing campaign abusing google.com open redirectsSANS Internet Storm Center2025 phishing again abusing a google.com redirect (/travel/clk), so abuse is ongoing
Spot a mistake or something out of date? Report a correction · How these guides are made and checked
The free, open-source scanner checks for most of the problems in these guides.