# 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 ([[raw/portswigger.net/introducing-the-url-validation-bypass-cheat-sheet-197|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 ``` ([[raw/book.hacktricks.xyz/url-format-bypass-hacktricks-43|HackTricks]]) - Grafana's `ValidateRedirectTo` forbade a leading `//` but not `/\`, so `/user/auth-tokens/rotate?redirectTo=/\example.com` returned `Location: /\example.com` (CVE-2025-6023) ([[raw/opswat.com/grafana-cve-2025-6023-full-account-takeover-4097|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(/^[/\\]+/, '/')` ([[raw/blog.angular.dev/security-advisory-addressing-recent-vulnerabilities-in-angular-2627|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 ``` ([[raw/book.hacktricks.xyz/url-format-bypass-hacktricks-43|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` ([[raw/cobalt.io/cobalt-oauth-vulnerabilities-part-2-3889|Cobalt]]). - **Prefix match**: `startsWith('https://trusted.example.com')` passes `https://[email protected]/`; ChatGPT-Next-Web's prefix allowlist passed `https://webdav.yandex.com.attacker.tld/` ([[raw/windshock.github.io/the-limitations-of-secure-ssrf-patches-advanced-bypasses-4199|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) ([[raw/hackerone.com/slack-oauth2-redirect-uri-bypass-hackerone-2575-3876|Slack report]]). - **Backslash before an allowed suffix**: `http://attacker.com\.target.com/callback` in an OAuth `TARGET` parameter sent the code to `attacker.com` ([[raw/flex0geek.blogspot.com/what-can-i-do-with-open-redirect-with-oauth-7033|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) ([[raw/hackerone.com/semrush-oauth-redirect-uri-bypass-via-idn-homograph-hackerone-861940-3875|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 ([[raw/blog.slonser.info/why-protocol-matters-evil-pwa-attack-on-casdoor-11449|slonser]]). - **Dev leftovers**: allowlists that accept anything beginning with `localhost` admit `localhost.evil-user.net` ([[raw/medium.com/oauth-vulnerabilities-part-ii-bug-bounty-2k25-4540|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://[email protected]/`; because the link's host was `wordpress.org`, it also passed the SSO login-redirect allowlist (H1 #3933198, CVSS 6.1) ([[raw/yaamlabs.com/bug-bounty-roundup-15-disclosed-hackerone-reports-incl-basecamp-csp-by-13721|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 `/` ([[raw/medium.com/grafana-cve-2025-4123-full-read-ssrf-account-takeover-3235|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 ([[raw/medium.com/oauth-vulnerabilities-part-ii-bug-bounty-2k25-4540|OAuth Part II]]). The ACSAC '23 study found 6/16 major IdPs vulnerable to path confusion and 10/16 to parameter pollution ([[raw/dl.acm.org/oauth-2-0-redirect-uri-validation-falls-short-acm-4081|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 ([[raw/portswigger.net/url-validation-bypass-cheat-sheet-2024-edition-web-security-academy-5105|cheat sheet]], [[raw/portswigger.net/introducing-the-url-validation-bypass-cheat-sheet-197|intro]]). `recollapse` mutates an input to fuzz regex validators ([[raw/book.hacktricks.xyz/url-format-bypass-hacktricks-43|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 | `…[email protected]/` | | 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_uri` before the check ([[raw/dl.acm.org/oauth-2-0-redirect-uri-validation-falls-short-acm-4081|ACM]]). - For "local only" redirects, a `startswith("/") and not startswith("//")` test (as in a published remediation pattern, [[raw/masimshahzad.medium.com/the-referer-header-that-redirected-oauth-tokens-14095|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()`) ([[raw/yaamlabs.com/bug-bounty-roundup-15-disclosed-hackerone-reports-incl-basecamp-csp-by-13721|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 - [[raw/portswigger.net/introducing-the-url-validation-bypass-cheat-sheet-197|Introducing the URL validation bypass cheat sheet]] - [[raw/portswigger.net/url-validation-bypass-cheat-sheet-2024-edition-web-security-academy-5105|URL validation bypass cheat sheet]] - [[raw/book.hacktricks.xyz/url-format-bypass-hacktricks-43|URL Format Bypass - HackTricks]] - [[raw/opswat.com/grafana-cve-2025-6023-full-account-takeover-4097|Grafana CVE-2025-6023: Full Account Takeover]] - [[raw/medium.com/grafana-cve-2025-4123-full-read-ssrf-account-takeover-3235|Grafana CVE-2025–4123: Full Read SSRF & Account Takeover]] - [[raw/blog.angular.dev/security-advisory-addressing-recent-vulnerabilities-in-angular-2627|Security Advisory: Addressing Recent Vulnerabilities in Angular]] - [[raw/cobalt.io/cobalt-oauth-vulnerabilities-part-2-3889|Cobalt: OAuth Vulnerabilities Part 2]] - [[raw/windshock.github.io/the-limitations-of-secure-ssrf-patches-advanced-bypasses-4199|The Limitations of 'Secure' SSRF Patches: Advanced Bypasses and Defense-in-Depth]] - [[raw/hackerone.com/slack-oauth2-redirect-uri-bypass-hackerone-2575-3876|Slack OAuth2 redirect_uri bypass — HackerOne #2575]] - [[raw/flex0geek.blogspot.com/what-can-i-do-with-open-redirect-with-oauth-7033|What can I do with Open Redirect with OAuth?]] - [[raw/hackerone.com/semrush-oauth-redirect-uri-bypass-via-idn-homograph-hackerone-861940-3875|Semrush OAuth redirect_uri bypass via IDN homograph — HackerOne #861940]] - [[raw/blog.slonser.info/why-protocol-matters-evil-pwa-attack-on-casdoor-11449|Why Protocol Matters: Evil PWA Attack on Casdoor]] - [[raw/medium.com/oauth-vulnerabilities-part-ii-bug-bounty-2k25-4540|OAuth Vulnerabilities Part II (Bug Bounty 2k25)]] - [[raw/yaamlabs.com/bug-bounty-roundup-15-disclosed-hackerone-reports-incl-basecamp-csp-by-13721|Bug bounty roundup: 15 disclosed HackerOne reports (incl. Basecamp CSP-bypassing XSS)]] - [[raw/dl.acm.org/oauth-2-0-redirect-uri-validation-falls-short-acm-4081|OAuth 2.0 Redirect URI Validation Falls Short (ACM)]] - [[raw/masimshahzad.medium.com/the-referer-header-that-redirected-oauth-tokens-14095|The Referer Header That Redirected OAuth Tokens]]