# Open Redirect to OAuth Token Theft
> Why an open redirect on an origin the authorization server trusts escalates to account takeover: the redirect acts as a proxy that forwards the authorization code or access token off the client origin, defeating exact-match `redirect_uri` validation.
## How it works
OAuth's security rests on the code/token reaching only the registered client. Exact-match `redirect_uri` validation protects the IdP-to-client hop, but not a redirect that fires **afterward** on the client's own trusted origin ([[raw/masimshahzad.medium.com/the-referer-header-that-redirected-oauth-tokens-14095|masimshahzad]]). Two placements are distinguished in the notes ([[raw/flex0geek.blogspot.com/what-can-i-do-with-open-redirect-with-oauth-7033|flex0geek]]):
1. **In the authorization server** — the `redirect_uri` check itself accepts a foreign host (see [[Redirect Validation Bypasses]]), so the credential leaves directly.
2. **In the client** — `redirect_uri` is pinned to an allowed host, but that host contains an open redirect, so the browser is bounced onward with the credential still attached to the URL.
With the authorization-code flow a leaked code can be replayed at the legitimate callback and the client completes the login, so the client secret is never needed ([[raw/medium.com/oauth-vulnerabilities-part-ii-bug-bounty-2k25-4540|OAuth Part II]]). With the implicit flow the token arrives in the URL fragment and is usable directly against the provider's APIs, not just for client login ([[raw/portswigger.net/portswigger-oauth-2-0-authentication-vulnerabilities-3899|PortSwigger]]). This is the canonical weaponization of a "low severity" open redirect, and the reason programs that exclude standalone open redirects still pay when one sits on an OAuth origin ([[raw/tib3rius.com/web-appsec-interview-questions-5906|Tib3rius]]).
## Escalation surface
- **Registered callback is clean, elsewhere isn't.** The callback path (`/oauth/callback`) rarely redirects, so **path confusion** moves the landing page to a vulnerable path on the same origin while still satisfying the host allowlist ([[raw/medium.com/top-10-oauth-2-0-hacking-techniques-part-2-4538|Top 10 OAuth Pt 2]]). ACSAC '23 showed this empirically: 6 of 16 major IdPs (Atlassian, Facebook, GitHub, Microsoft, NAVER, VK) accepted path-confusion redirect URIs, and because the victim lands on a page that never consumes the code, the normal single-use race disappears. Any data-leaking bug on *any* path of the client becomes OAuth ATO ([[raw/dl.acm.org/oauth-2-0-redirect-uri-validation-falls-short-acm-4081|ACM]]).
- **Referer / fragment leakage.** Where the callback embeds third-party scripts or reflects into HTML, the code/token leaks via the `Referer` header or an injected resource; ACSAC measured code leakage to ad networks (Real-Time Bidding) on real sites ([[raw/dl.acm.org/oauth-2-0-redirect-uri-validation-falls-short-acm-4081|ACM]], [[raw/medium.com/top-10-oauth-2-0-hacking-techniques-part-2-4538|Top 10 OAuth Pt 2]]).
- **Open redirect to arbitrary provider redirector.** Chaining through a provider logout/continue endpoint (`accounts.google.com/...?continue=`) reaches any destination from a trusted host ([[raw/cobalt.io/cobalt-oauth-vulnerabilities-part-2-3889|Cobalt]]).
- **Missing/weak `state`** makes the login-CSRF setup step possible, which is what plants the attacker-controlled return path (below).
## Notable cases
- **Airbnb, 2016 ($5,000).** Redirect URIs were an exact list, yet a post-login redirect derived from the `Referer` header plus a cross-site-GET login-CSRF on the OAuth start endpoint delivered Facebook and Google tokens to an attacker page; the mobile app accepted the bare provider token as login ([[raw/masimshahzad.medium.com/the-referer-header-that-redirected-oauth-tokens-14095|masimshahzad]]).
- **Zee Entertainment, P1 CVSS 9.0.** An open redirect on `signin?callback=` sent the browser to the attacker with a one-time OTP auth code in the query; it was redeemable once for a session valid ~55 days, chained onward to full ATO ([[raw/medium.com/chaining-an-open-redirect-into-account-takeover-p1-cvss-9-0-13937|Josekutty Binu]]).
- **Stale CNAME + wildcard `redirect_uri` ($6,000).** A `*.target.com` callback rule plus a subdomain takeover gave zero-interaction code theft ([[raw/medium.com/how-i-chained-a-stale-cname-record-with-oauth-2-0-wildcards-for-a-6-00-14401|writeup]]).
- **Covert Redirect (2014).** The original disclosure that a poorly validated `redirect_uri` plus an open redirector on a trusted domain intercepts the code/token; many providers moved to exact match afterward ([[raw/guptadeepak.com/sso-protocol-security-critical-vulnerabilities-in-saml-oauth-oidc-jwt-4718|Gupta]]).
- **CVE-2019-9837 (Doorkeeper OIDC)** — open redirect via `redirect_uri` ([[raw/guptadeepak.com/sso-protocol-security-critical-vulnerabilities-in-saml-oauth-oidc-jwt-4718|Gupta]]); **CVE-2020-5233 / CVE-2021-21291 (OAuth2-Proxy)** — open redirect via crafted redirect URLs / whitelist-domain feature ([[raw/zeropath.com/oauth2-proxy-authentication-bypass-cve-2025-54576-4720|ZeroPath]]).
## Defenses
- Exact-match, per-client `redirect_uri` allowlists with no wildcards, and re-validate at the token endpoint; GitHub and NAVER allowed ATO partly because the Redeem-Process check was lax or optional ([[raw/dl.acm.org/oauth-2-0-redirect-uri-validation-falls-short-acm-4081|ACM]], [[raw/blog.doyensec.com/doyensec-common-oauth-vulnerabilities-3891|Doyensec]]).
- Treat `redirect_uri` with strict byte-equality; never sanitize it, and treat `code`/`state` appearing inside it as an attack indicator ([[raw/dl.acm.org/oauth-2-0-redirect-uri-validation-falls-short-acm-4081|ACM]]).
- Never derive post-login redirects from `Referer`; store an internal return path server-side and accept only allowlisted relative paths. Bind `state` and the PKCE verifier to a pre-session cookie so a planted return path or an injected code cannot be reused ([[raw/masimshahzad.medium.com/the-referer-header-that-redirected-oauth-tokens-14095|masimshahzad]]).
- `Referrer-Policy: no-referrer` on OAuth endpoints; keep third-party scripts off callback pages (RFC 6749 §3.1.2.5) ([[raw/medium.com/top-10-oauth-2-0-hacking-techniques-part-2-4538|Top 10 OAuth Pt 2]]).
- Kill open redirects on every origin in the OAuth allowlist, not only the callback path.
## Related
- [[Open Redirect]] (main guide)
- [[Redirect Validation Bypasses]] · [[Open Redirect to SSRF]] · [[DOM-Based Open Redirect]]
- [[OAuth 2.0 Vulnerabilities]] · [[OpenID Connect Security]] · [[Account Takeover]] · [[Vulnerability Chaining]] · [[Login CSRF]] · [[Mobile OAuth and Deep Link Attacks]]
## Sources
- [[raw/dl.acm.org/oauth-2-0-redirect-uri-validation-falls-short-acm-4081|OAuth 2.0 Redirect URI Validation Falls Short (ACM)]]
- [[raw/flex0geek.blogspot.com/what-can-i-do-with-open-redirect-with-oauth-7033|What can I do with Open Redirect with OAuth?]]
- [[raw/masimshahzad.medium.com/the-referer-header-that-redirected-oauth-tokens-14095|The Referer Header That Redirected OAuth Tokens]]
- [[raw/medium.com/chaining-an-open-redirect-into-account-takeover-p1-cvss-9-0-13937|Chaining an Open Redirect Into Account Takeover (P1 · CVSS 9.0)]]
- [[raw/medium.com/how-i-chained-a-stale-cname-record-with-oauth-2-0-wildcards-for-a-6-00-14401|How I Chained a Stale CNAME Record with OAuth 2.0 Wildcards for a $6,000 ATO]]
- [[raw/portswigger.net/portswigger-oauth-2-0-authentication-vulnerabilities-3899|PortSwigger: OAuth 2.0 authentication vulnerabilities]]
- [[raw/medium.com/top-10-oauth-2-0-hacking-techniques-part-2-4538|Top 10 OAuth 2.0 Hacking Techniques Part 2]]
- [[raw/medium.com/oauth-vulnerabilities-part-ii-bug-bounty-2k25-4540|OAuth Vulnerabilities Part II (Bug Bounty 2k25)]]
- [[raw/cobalt.io/cobalt-oauth-vulnerabilities-part-2-3889|Cobalt: OAuth Vulnerabilities Part 2]]
- [[raw/blog.doyensec.com/doyensec-common-oauth-vulnerabilities-3891|Doyensec: Common OAuth Vulnerabilities]]
- [[raw/guptadeepak.com/sso-protocol-security-critical-vulnerabilities-in-saml-oauth-oidc-jwt-4718|SSO Protocol Security: Critical Vulnerabilities in SAML, OAuth, OIDC, JWT]]
- [[raw/zeropath.com/oauth2-proxy-authentication-bypass-cve-2025-54576-4720|OAuth2-Proxy Authentication Bypass (CVE-2025-54576)]]
- [[raw/tib3rius.com/web-appsec-interview-questions-5906|Web AppSec Interview Questions]]
- [[raw/0xn3va.gitbook.io/0xn3va-oauth-2-0-vulnerabilities-cheat-sheet-3888|0xn3va: OAuth 2.0 Vulnerabilities cheat sheet]]
- [[raw/infosecwriteups.com/the-art-of-breaking-oauth-real-world-exploits-and-misuses-4719|The Art of Breaking OAuth: Real-World Exploits and Misuses]]
- [[raw/opswat.com/grafana-cve-2025-6023-full-account-takeover-4097|Grafana CVE-2025-6023: Full Account Takeover]]