Redirect Validation Bypasses

Defeating the check that decides whether a redirect target is “local” or “allowed”, by exploiting the gap between the string the validator inspects and the URL the browser (or HTTP client) actually navigates to.

How it works

Every redirect guard is a parser differential waiting to happen: the server inspects a string with startsWith, a regex, contains, or a homemade “is relative” check, then emits it into Location (or window.location), where a WHATWG browser parser re-reads it. Anything the two disagree on (backslash vs slash, userinfo @, fragment/query boundaries, Unicode, leading-slash counts, schemes) is a bypass. The same payload families serve SSRF allowlists, CORS origin checks and open redirects; PortSwigger built one cheat sheet for all three because “URL validation bypasses are the root cause” of each (PortSwigger). For the server-side fetcher view of the same quirks see URL Parser Differentials.

Three recurring failure shapes:

  1. “Relative path only” checks that block //host but miss browser-equivalent forms (/\host, ///host).
  2. Host allowlists done with string ops: prefix, suffix, substring or unanchored regex.
  3. Normalization after validation: the value is transformed (prefix strip, decode, path resolution) after the check passes.

Techniques / payloads

Protocol-relative and slash/backslash confusion (browsers treat /\ like //):

//attacker.com          /\attacker.com          \/\/attacker.com/
https:attacker.com      https:/\attacker.com    http:/\/\attacker.com
///attacker.com         %0D%0A/attacker.com     #attacker.com   @attacker.com

(HackTricks)

  • Grafana’s ValidateRedirectTo forbade a leading // but not /\, so /user/auth-tokens/rotate?redirectTo=/\example.com returned Location: /\example.com (CVE-2025-6023) (OPSWAT).
  • Angular SSR stripped only one leading slash from X-Forwarded-Prefix; ///evil.com survived as //evil.com, giving an open redirect and cache poisoning behind proxies that pass the header (GHSA-xh43-g2fq-wjrj). The workaround collapses all of them: prefix.replace(/^[/\\]+/, '/') (Angular advisory).

Host allowlist confusion ({domain} = allowed host):

https://{domain}@attacker.com        https://{domain}.attacker.com
https://attacker.com#@{domain}       https://attacker.com%23@{domain}
https://attacker.com\.{domain}       https://attacker.com?{domain}
https://attacker.com;https://{domain}
next={domain}&next=attacker.com      # parameter pollution

(HackTricks). Encoded-delimiter variants against suffix checks: example.com%2f%2f.victim.com, example.com%5c%5c.victim.com, example.com%3F.victim.com, example.com%23.victim.com, victim.com:80%40example.com, victim.com%2eexample.com (Cobalt).

  • Prefix match: startsWith('https://trusted.example.com') passes https://trusted.example.com@evil.attacker-site.com/; ChatGPT-Next-Web’s prefix allowlist passed https://webdav.yandex.com.attacker.tld/ (windshock).
  • Suffix/prefix without delimiter: Slack accepted redirect_uri=http://www.google.com.mx and http://www.google.com.attacker.com for a client registered as http://www.google.com (H1 #2575) (Slack report).
  • Backslash before an allowed suffix: http://attacker.com\.target.com/callback in an OAuth TARGET parameter sent the code to attacker.com (flex0geek).
  • IDN homograph: Semrush’s backend normalized oauth.šemrush.com to its own host, while browsers resolved the punycode xn--emrush-9jb.com the attacker registered (H1 #861940, medium) (Semrush report).
  • Scheme-agnostic suffix check: Casdoor’s IsValidOrigin used strings.HasSuffix(host, ".chromiumapp.org") and ignored the scheme, so web+slonser://z.chromiumapp.org (a PWA protocol handler) passed and received the auth code (slonser).
  • Dev leftovers: allowlists that accept anything beginning with localhost admit localhost.evil-user.net (OAuth Part II).

Normalization after validation

  • WordPress Openverse: str_replace() was given 1 as the fourth argument, believing it limited replacements (it is an output count). Every /openverse was stripped, so a crafted path became https://openverse.wordpress.net@evil.example/; because the link’s host was wordpress.org, it also passed the SSO login-redirect allowlist (H1 #3933198, CVSS 6.1) (yaamlabs).
  • Grafana CVE-2025-4123: the static handler resolves ../ for the file-system check but http.Redirect treats ? as the start of the query, so /public/../\attacker.com/%3f/../../../../../.. yields Location: /\attacker.com/?/../../..., even though the code explicitly regex-rewrote ^(?:/\\|/+) to / (Balada).

OAuth redirect_uri specifics: path traversal (/oauth/callback/../../any/path), appended params/fragments, https://default-host.com &@foo.evil-user.net#@bar.evil-user.net/, duplicate redirect_uri parameters (OAuth Part II). The ACSAC ‘23 study found 6/16 major IdPs vulnerable to path confusion and 10/16 to parameter pollution (ACM). See Open Redirect to OAuth Token Theft.

Generating variants: PortSwigger’s URL validation bypass cheat sheet generates Intruder-ready wordlists (domain-allowlist bypass, “fake relative URLs”, loopback) for absolute-URL, host-only and CORS-origin contexts, with selectable encodings (cheat sheet, intro). recollapse mutates an input to fuzz regex validators (HackTricks).

Notable cases

TargetFlawPayload shape
Grafana CVE-2025-6023// blocked, /\ notredirectTo=/\attacker.com
Grafana CVE-2025-4123path resolution differs between file open and redirect/public/../\attacker.com/%3f/../..
Angular SSRsingle-slash strip on X-Forwarded-Prefix///evil.com
WordPress Openversestr_replace count misuse plus userinfo…wordpress.net@evil.example/
Slack H1 #2575suffix-less prefix matchgoogle.com.attacker.com
Semrush H1 #861940IDN normalizationoauth.šemrush.com
Casdoorscheme-blind suffix matchweb+x://z.chromiumapp.org

Defenses

  • Compare whole values: exact string equality for registered redirect URIs, equal length and identical bytes, and no sanitization or decoding of untrusted redirect_uri before the check (ACM).
  • For “local only” redirects, a startswith("/") and not startswith("//") test (as in a published remediation pattern, masimshahzad) is exactly what Grafana shipped and what /\ defeats; also reject backslashes, or better, map an opaque key to a server-side path.
  • Use the framework’s safe helper (wp_safe_redirect()) and true prefix operations (str_starts_with() + substr()) (yaamlabs).
  • Parse once, check the parsed host with a delimiter-anchored exact match, and check the scheme too (Casdoor).

Sources