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:
- “Relative path only” checks that block
//hostbut miss browser-equivalent forms (/\host,///host). - Host allowlists done with string ops: prefix, suffix, substring or unanchored regex.
- 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
- Grafana’s
ValidateRedirectToforbade a leading//but not/\, so/user/auth-tokens/rotate?redirectTo=/\example.comreturnedLocation: /\example.com(CVE-2025-6023) (OPSWAT). - Angular SSR stripped only one leading slash from
X-Forwarded-Prefix;///evil.comsurvived 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')passeshttps://trusted.example.com@evil.attacker-site.com/; ChatGPT-Next-Web’s prefix allowlist passedhttps://webdav.yandex.com.attacker.tld/(windshock). - Suffix/prefix without delimiter: Slack accepted
redirect_uri=http://www.google.com.mxandhttp://www.google.com.attacker.comfor a client registered ashttp://www.google.com(H1 #2575) (Slack report). - Backslash before an allowed suffix:
http://attacker.com\.target.com/callbackin an OAuthTARGETparameter sent the code toattacker.com(flex0geek). - IDN homograph: Semrush’s backend normalized
oauth.šemrush.comto its own host, while browsers resolved the punycodexn--emrush-9jb.comthe attacker registered (H1 #861940, medium) (Semrush report). - Scheme-agnostic suffix check: Casdoor’s
IsValidOriginusedstrings.HasSuffix(host, ".chromiumapp.org")and ignored the scheme, soweb+slonser://z.chromiumapp.org(a PWA protocol handler) passed and received the auth code (slonser). - Dev leftovers: allowlists that accept anything beginning with
localhostadmitlocalhost.evil-user.net(OAuth Part II).
Normalization after validation
- WordPress Openverse:
str_replace()was given1as the fourth argument, believing it limited replacements (it is an output count). Every/openversewas stripped, so a crafted path becamehttps://openverse.wordpress.net@evil.example/; because the link’s host waswordpress.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 buthttp.Redirecttreats?as the start of the query, so/public/../\attacker.com/%3f/../../../../../..yieldsLocation: /\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
| Target | Flaw | Payload shape |
|---|---|---|
| Grafana CVE-2025-6023 | // blocked, /\ not | redirectTo=/\attacker.com |
| Grafana CVE-2025-4123 | path resolution differs between file open and redirect | /public/../\attacker.com/%3f/../.. |
| Angular SSR | single-slash strip on X-Forwarded-Prefix | ///evil.com |
| WordPress Openverse | str_replace count misuse plus userinfo | …wordpress.net@evil.example/ |
| Slack H1 #2575 | suffix-less prefix match | google.com.attacker.com |
| Semrush H1 #861940 | IDN normalization | oauth.šemrush.com |
| Casdoor | scheme-blind suffix match | web+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_uribefore 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).
Related
- Open Redirect (main guide)
- Open Redirect to OAuth Token Theft · DOM-Based Open Redirect
- URL Parser Differentials · IP Address Encoding Bypasses · Open Redirect to SSRF
- OAuth 2.0 Vulnerabilities · Referer and Origin Validation Bypasses
Sources
- Introducing the URL validation bypass cheat sheet · original
- URL validation bypass cheat sheet · original
- URL Format Bypass - HackTricks · original
- Grafana CVE-2025-6023: Full Account Takeover · original
- Grafana CVE-2025–4123: Full Read SSRF & Account Takeover · original
- Security Advisory: Addressing Recent Vulnerabilities in Angular · original
- Cobalt: OAuth Vulnerabilities Part 2 · original
- The Limitations of 'Secure' SSRF Patches: Advanced Bypasses and Defense-in-Depth · original
- Slack OAuth2 redirect_uri bypass — HackerOne #2575 · original
- What can I do with Open Redirect with OAuth? · original
- Semrush OAuth redirect_uri bypass via IDN homograph — HackerOne #861940 · original
- Why Protocol Matters: Evil PWA Attack on Casdoor · original
- OAuth Vulnerabilities Part II (Bug Bounty 2k25) · original
- Bug bounty roundup: 15 disclosed HackerOne reports (incl. Basecamp CSP-bypassing XSS) · original
- OAuth 2.0 Redirect URI Validation Falls Short (ACM) · original
- The Referer Header That Redirected OAuth Tokens · original