OAuth 2.0 Redirect URI Validation Falls Short, Literally
The OAuth 2.0 specification's redirect URI validation guidance is underspecified, allowing path confusion and parameter pollution attacks. An attacker could exploit these to leak sensitive OAuth parameters and potentially achieve account takeover when combined with other vulnerabilities.
Published on innotommy.com
multiple interactions between a Client application requesting access to external data and an Identity Provider (IdP)1 , where sensitive parameters need to be securely transferred and processed by each party. As a result, security analysis of OAuth 2.0 flows is an active research area, with a steady stream of practical…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
OAuth 2.0 is a delegated access protocol that lets a user grant a web application (the Client) access to data held by a third party (the Identity Provider, or IdP). The most widely used mechanism is the Authorization Code Grant flow. In that flow the Client registers a callback endpoint, the redirect URI, with the IdP during setup, and the IdP issues a client ID and client secret. When a user wants to sign in, the Client sends the browser to the IdP with an Authorization Request containing response_type=code, client_id, state and redirect_uri. The IdP authenticates the user, validates the parameters, and redirects the browser back to the redirect URI with an Authorization Response carrying a fresh code and the earlier state. The Client then redeems the code at the token endpoint with an Access Token Request containing grant_type=authorization_code, client_id, client_secret, the code and the same redirect_uri. The IdP checks that the code was issued to this Client, has not been used, and that the redirect URI is identical to the one in the Authorization Request, then returns an access token.
Because the Authorization Response carries security tokens, the integrity of the redirect URI matters. The OAuth 2.0 specification and its threat model RFCs require the IdP to validate that the supplied redirect URI matches the registered one. This work revisits that validation guidance in light of systems-centric web attacks, where vulnerabilities come from discrepancies between how different components parse the same URI. The authors' hypothesis is that the RFC guidance protects only the domain name in the redirect URI and leaves the path and query string under-specified, which exposes IdPs to path confusion and parameter pollution.
Setup
The experiment was seeded with the Top 15K sites of the Tranco list generated on 15 February 2022. A crawler used regular expressions and heuristics to detect login pages (keywords such as login, sign-in, join, and password input tags), then a second layer of heuristics to find HTML elements that start an OAuth 2.0 flow. Of the seeded sites, 728 had an authentication page supporting at least one IdP. The authors kept only IdPs used by at least 3 Client sites, giving 28 IdPs, then removed those that required valid personal information to register, enforced geo-restrictions, or mandated two-factor authentication, leaving 22 in scope. Bot management and CAPTCHAs on some sites blocked automated logins, and the final dataset was 464 successful OAuth 2.0 flows between 378 Client sites and 16 IdPs.
Test accounts were created manually with unique values (email address, user name) so that the authors could later identify them reflected on a Client callback page as proof that the flow completed. The OAuth 2.0 Player was implemented in Node.js with puppeteer driving Chrome, and mitmproxy was used to intercept traffic and inject payloads. The tool starts the flow from the Client site, authenticates to the IdP with the test account, and lands back on the callback endpoint. It verifies that the identified HTML elements start the flow, that the IdP landing page is the login page, and that the URL contains the necessary OAuth 2.0 parameters. Flows that fail this verification are discarded. The tools are published at https://github.com/innotommy/OAuthpaper-code.
The threat model is a typical web attacker with the same privileges as a regular user: they can use the Client and the IdP normally, participate in OAuth 2.0 flows on their own user agent, and use social engineering to make a victim click a link. They have no man-in-the-middle capability and cannot interfere with secure channels. The authors stress that the techniques are building blocks, not end-to-end exploits on their own, and that the targeted Clients and IdPs may have other well-known web application vulnerabilities that the attacker combines with them.
Finding it
The starting point is the text of the specification. RFC 6749 Section [redacted] says:
The authorization server MUST compare the two URIs using simple string comparison as defined in RFC 3986 Section 6.2.1.
RFC 3986 Section 6.2.1 describes comparison as a pair comparison of characters from the first until both strings are exhausted, a pair compares unequal, or one string is exhausted before the other. That describes three stopping conditions but does not mandate a success or failure outcome for them. In particular, the case where two URIs share a matching prefix but have different lengths is not expressly disallowed. If an IdP reads that ambiguity as flexibility (for example, to support dynamic path components or query parameters) or otherwise allows a non-exact match, the check still prevents tampering with the host or domain name but does not detect additions, deletions or modifications to the path and query string that follow.
RFC 6749 Section 3.1 also allows a query component in the redirect URI and requires it to be retained:
The endpoint URI MAY include an "application/x-www-form-urlencoded" formatted (per Appendix B) query component (RFC 3986 Section 3.4), which MUST be retained when adding additional query parameters.
RFC 6749 Section 10.14 acknowledges injection into redirect URI parameters and requires sanitisation and validation, but gives no prescriptive instructions:
The authorization server and Client MUST sanitize (and validate when possible) any value received–in particular, the value of the "state" and "redirect_uri" parameters.
Combined with the requirement to retain additional query parameters, this leaves the redirect URI open to parameter pollution. The authors note that two researchers, Lauritz Holtmann and Youssef Sammouda, independently found specific evidence of parameter pollution in OAuth 2.0. Both hypotheses hold under the assumption that Clients and IdPs follow the RFCs correctly: the work does not rely on implementation bugs but on under-specified requirements.
Exploitation
Step 1: Path confusion payloads
Path confusion means appending crafted path components to a URL to confuse URL parsers or to induce discrepancies between parsers. The authors replaced the legitimate redirect URI with 20 payloads compiled from the literature. Client.com/callback/ is the legitimate endpoint and the rest is the malicious modification; the goal is to land the victim on a FAKEPATH endpoint on the Client site.
The payloads combine path traversal tricks, encoded special characters and multiple encoding layers. Each flow was tested separately with all 20 payloads, with a proxy injecting them into the redirect URI in flight. An IdP was flagged as vulnerable if it did not terminate the protocol and did not sanitise the FAKEPATH marker, but redirected the browser to a callback endpoint containing FAKEPATH. Inspecting the raw traffic for that final redirect was sufficient to identify a vulnerable IdP; screenshots, proxy logs and the presence of the test account identifiers on the callback page were used as complementary signals.
6 of the 16 IdPs were vulnerable to path confusion: Atlassian, Facebook, GitHub, Microsoft, NAVER and VK.
Step 2: OAuth 2.0 parameter pollution (OPP)
The goal of OPP is to make the victim land on the Client callback endpoint with two distinct code parameters, one legitimate and one injected by the attacker. The attacker builds a URL for the IdP authorization endpoint with valid response_type=code, client_id, state and redirect_uri, then appends a code parameter to the redirect URI. The value can be arbitrary, or a valid code obtained by starting another flow and stopping it after the Authorization Process. The ? and = of the appended query string are encoded to reduce the chance of a parsing error at the IdP.
- The attacker tricks the victim into visiting the URL, which starts a normal flow and takes the browser to the IdP's legitimate authorization page.
- The victim logs in and authorizes the Client. The IdP validates the redirect URI as prescribed, but the prefix matches the registered value, so the unexpected
codeparameter does not cause a failure. - The IdP keeps the redirect URI intact as required by RFC 6749 Section 3.1 and appends a second, freshly generated
code. - The victim lands on the callback endpoint with two
codeparameters. If the Client processes the attacker-injected one, the victim's valid code remains unused and can be leaked through another vulnerability for an account takeover.
10 of the 16 IdPs were impacted: GitHub, LINE, LinkedIn, Microsoft, NAVER, OK, ORCID, Slack, VK and Yahoo. They did not terminate the flow or strip the superfluous parameter, and the browser landed on the callback endpoint with both code parameters intact.
Step 3: Redeem Process validation
The attacker must also redeem the stolen code, and the Access Token Request carries a second redirect_uri that the Client builds, not the attacker. RFC 6749 Section 4.1.3 requires it to be identical to the one in the Authorization Request:
The Client makes a request to the token endpoint by sending the following parameters [...] redirect_uri REQUIRED, if the "redirect_uri" parameter was included in the authorization request as described in Section 4.1.1, and their values MUST be identical.
In the first experiment the authors ran a path confusion attack in the Authorization Request but sent the original, unmodified redirect URI in the Access Token Request. If the flow completed despite the mismatch, the IdP was judged to validate incorrectly. In the second experiment the same was done with an OPP attack. GitHub and NAVER performed insufficient validation in the Redeem Process and allowed an end-to-end account takeover.
GitHub's documentation references the parameter but defines it incompletely ("The URL in your application where users are sent after authorization.") and marks it optional even when a redirect URI was supplied in the Authorization Request. The authors verified that omitting the value entirely still produced a successful flow. NAVER's documentation and examples did not include a redirect URI in the Access Token Request at all, and a complete flow was possible with no redirect URI from the Client. It was not clear whether the string matching was flawed when a value was provided or whether validation was omitted entirely; both IdPs were exploitable in practice.
Step 4: Influencing the Access Token Request
A typical Client parses the Authorization Response into code, state and a monolithic block of everything else, checks state, then rebuilds the redirect URI by appending the custom block to the callback endpoint, as RFC 6749 Section 4.1.3 requires. Under OPP, the injected code becomes part of that custom block and is copied into the new redirect URI, which then matches the attack payload exactly. The authors tested this with the 10 OPP-vulnerable IdPs: only 6 (GitHub, LinkedIn, NAVER, OK, Slack and VK) completed the protocol. The other 4 refused to validate matching redirect URI values, contrary to expectation, which suggests arbitrary validation routines or custom state about observed redirect URIs rather than a straightforward string comparison.
Step 5: Leaking the code
Path confusion and OPP remove the race condition that normally makes code leakage uninteresting: the victim's code stays unused. Path confusion sends the user to an endpoint that does not expect an OAuth 2.0 flow and does not consume the code; OPP makes the Client proceed with the attacker's code. Path confusion also lets the attacker choose the callback path, so a data exfiltration issue on any path of the Client can be used. The authors list XSS, style or HTML injection that extracts query parameters, open redirects, multi-tenant sites where the attacker can register as a tenant on the same domain, and leaky third-party code inclusion across the whole site.
Step 6: Case study, weaponising an open redirect
The authors searched the Open Bug Bounty program for sites in their dataset with known, unresolved issues. The chosen issue was reported in 2018, assessed as very low risk and presumably not fixed. The site integrates with NAVER as an IdP, which escalates the low-risk open redirect to a complete OAuth 2.0 account takeover. The site is redacted because the vulnerability remained exploitable at the time of writing.
- The attacker tricks the victim into clicking the link.
- The victim lands on the legitimate NAVER login page and enters credentials.
- NAVER redirects back to the redacted site, to the page with the open redirect, because of the path confusion payload.
- The open redirect forwards the request to the attacker's domain, leaking the code.
- The attacker starts a new flow, intercepts it in the browser before the Authorization Response, injects the stolen code and forwards it to the redacted site.
- The site performs the Redeem Process, and because NAVER does not validate the redirect URI correctly, the flow succeeds and the attacker controls the victim's resources.
Step 7: Case study, Real-Time Bidding
RFC 6749 Section [redacted] says Clients should not include third-party scripts in the redirection endpoint response, and if they do, their own scripts must execute first. In the recorded flows, the authors found leaks to third-party domains in 46 of 464 measurements (10%), involving 11 of 16 IdPs (68%) and 30 sites (8%), with 76 distinct destination domains, the largest category being ad networks at 30%. Referral headers reach advertisers in Real-Time Bidding requests, so anyone can sign up as an advertiser and receive OAuth 2.0 parameters in real time. Normally the race condition makes this harmless, but OPP leaves the victim's code unused, and with an IdP that does not validate the Redeem Process correctly the situation escalates to a complete account takeover. The authors verified this with real websites. It can also be combined with path confusion when ad services are elsewhere on the site.
Root cause
The problem is in the specification, not in a single implementation. The prescribed comparison is a simple string comparison whose outcome for URIs of different lengths is not defined, so path and query string additions can pass. The requirement to retain query parameters, combined with the absence of prescriptive sanitisation rules, allows duplicate security-sensitive parameters. The Redeem Process requirement of an identical value has no concrete guidance on how the comparison is performed. IdPs that follow the RFCs flawlessly can still be vulnerable, and a passing score from a compliance check framework such as OAuch does not necessarily reflect good security. The authors also note that non-standard validation routines, while sometimes blocking an attack, are error-prone and a common cause of hazardous interactions.
Impact
The result of the two techniques is that the authorization code is delivered to a maliciously modified callback endpoint. On its own this does not compromise the victim: the attacker must obtain the code and redeem it. With path confusion or OPP the victim's code stays unused, removing the race condition, and a leak on any path of the Client becomes usable. Combined with an IdP that validates the Redeem Process incorrectly, the outcome is a complete account takeover. The authors stress that not all findings translate to exploitable scenarios, because OAuth 2.0 is mature and IdPs and Clients may fill the gaps with custom design decisions, but end-to-end exploits against real applications were demonstrated. The full results are in Table 1 of the paper.
| IdP | Path Confusion | OPP | Redeem Validation |
|---|---|---|---|
| Atlassian | Vulnerable | Not Vulnerable | Correct |
| Dropbox | Not Vulnerable | Not Vulnerable | Correct |
| Vulnerable | Not Vulnerable | Correct | |
| GitHub | Vulnerable | Vulnerable | Incorrect |
| Kakao | Not Vulnerable | Not Vulnerable | Correct |
| LINE | Not Vulnerable | Vulnerable | Correct |
| Not Vulnerable | Vulnerable | Correct | |
| Microsoft | Vulnerable | Vulnerable | Correct |
| NAVER | Vulnerable | Vulnerable | Incorrect |
| OK | Not Vulnerable | Vulnerable | Correct |
| ORCID | Not Vulnerable | Vulnerable | Correct |
| Slack | Not Vulnerable | Vulnerable | Correct |
| Not Vulnerable | Not Vulnerable | Correct | |
| VK | Vulnerable | Vulnerable | Correct |
| Yahoo | Not Vulnerable | Vulnerable | Correct |
| Yandex | Not Vulnerable | Not Vulnerable | Correct |
Fix
The authors identified the parts of the specification where validation is under-specified and made recommendations to the OAuth Working Group. Their recommendations apply to both the Authorization Process and the Redeem Process and must be implemented consistently in both:
- Redirect URI validation must be a strict string equality check, stated clearly in the specification: equal size and an identical byte sequence, so that all components of the URI are covered.
- OAuth 2.0 parameters such as
codeandstatemust be reserved names. Servers must check the redirect URI for them and fail validation if present. Seeing them is either an attack indication or a Client namespacing issue. Doing the check on the server moves the responsibility from the Client to the IdP. - Servers must not sanitise the redirect URI. Any transformation or encoding/decoding of untrusted input can be weaponised to create parsing discrepancies. Redirect URI must always be validated, never sanitised.
One foreseeable hurdle is compatibility with existing Clients that reorder query parameters between the two steps or front OAuth 2.0 endpoints with transforming proxies. The authors suggest opt-in non-secure configuration options for Clients that need permissive validation.
Variants to test
- Send the 20 path confusion payloads above as the redirect URI and watch the final redirect. A positive result is an Authorization Response URL containing
FAKEPATH. - Append an encoded
codeparameter to the redirect URI and complete the flow. A positive result is a callback URL with twocodeparameters. - Run a path confusion or OPP attack in the Authorization Request but send the original redirect URI in the Access Token Request. A positive result is a completed flow despite the mismatch.
- Omit the redirect URI from the Access Token Request entirely. A positive result is a successful token response, as seen with GitHub and NAVER.
- Rebuild the redirect URI from the parsed custom parameter block as in the typical Client implementation. A positive result is a rebuilt value identical to the attack payload that the IdP accepts.
- Look for an open redirect, XSS or HTML injection on any path of a Client that uses a vulnerable IdP, and redirect the victim there. A positive result is the code arriving at a domain the attacker controls.
- Check whether callback endpoints load third-party ad or analytics scripts and inspect RTB bid requests for OAuth 2.0 parameters. A positive result is a
codevisible to an advertiser account.
What happened, in plain words
Many websites let you sign in with an account you already have somewhere else, for example "Sign in with Google" or "Sign in with Facebook". The button does not send your password to the website you are visiting. Instead, the website sends your browser to the company that holds your account, you log in there, and that company sends your browser back to the website with a short-lived secret slip of paper called a code. The website then swaps that code for a longer-lived key called an access token, which it uses to read your data.
This whole dance is called OAuth 2.0. The company that holds your account (Google, Facebook, GitHub and so on) is called the Identity Provider, or IdP. The website you are signing in to is called the Client. The code is handed back to the Client by sending your browser to a specific address on the Client site, called the redirect URI. Because that address receives a secret, the IdP must be sure it is sending the code to the right place, so the Client registers the address with the IdP in advance and the IdP checks every request against it.
This paper looks at that check. The authors read the official rulebook for OAuth 2.0 (a set of documents called RFCs) and noticed that the rule for comparing the registered address with the requested one is vague. It says to compare the two strings character by character, but it does not clearly say what to do when one string is longer than the other. In practice an IdP can end up checking only the beginning of the address, the part with the domain name, and ignoring whatever comes after it in the path and the query string.
The authors then built two tricks that exploit this. The first, path confusion, adds extra pieces to the end of the address so that the browser ends up somewhere else on the Client site. The second, OAuth 2.0 parameter pollution (OPP), sneaks a second code parameter into the address so the Client sees two codes, one real and one fake. They tested 16 popular IdPs and found that 6 were fooled by the first trick and 10 by the second. They then showed how, combined with ordinary bugs on a website, these tricks can lead to a full account takeover, meaning an attacker ends up in control of your account.
The sign-in dance, step by step
Before the tricks make sense, it helps to see the normal flow. The authors describe the Authorization Code Grant, the most common version of OAuth 2.0.
- You are on a website (the Client) and click a button to sign in with an IdP.
- The Client sends your browser to the IdP's login page. This outgoing request is the Authorization Request. It carries four important values:
response_type=code(meaning "I want a code back"),client_id(a public name for the Client),state(a random value the Client makes up to recognise its own request later) andredirect_uri(where the IdP should send you back). - You type your username and password on the IdP's page. The IdP checks the request, including whether the
redirect_urimatches the one the Client registered earlier. - If everything checks out, the IdP sends your browser back to the
redirect_uriwith a response called the Authorization Response. It contains a freshcodeand the samestateyou sent. - The Client checks that the
statematches what it made up, which proves the response belongs to the request it started. This is a defence against CSRF, a trick where an attacker makes your browser send a request you did not intend. - The Client now makes a second request, the Access Token Request, directly to the IdP (not through your browser). It includes
grant_type=authorization_code, itsclient_id, itsclient_secret(a private password for the Client), thecodeand the sameredirect_uriagain. - The IdP checks that the code was issued to this Client, that it has not been used before, and that the
redirect_urimatches the one from step 2. If so, it returns an access token. - The Client uses the access token to read your data.
A useful comparison: the code is like a cloakroom ticket. You hand it over once and get your coat (the access token). The ticket is only good once, and only at the right cloakroom. The redirect URI is the address of that cloakroom, and the IdP's job is to make sure it is not handing your coat to a stranger's address.
Setting up the experiment
The authors wanted to test many real IdPs, so they needed a large list of real websites that offer sign-in with an IdP. They started from the Tranco list, a public ranking of popular websites, taking the top 15,000 as generated on 15 February 2022.
A crawler is a program that visits web pages automatically, like a very fast reader. The authors' crawler looked for login pages using simple pattern matching (regular expressions) and clues such as the words login, sign-in or join, and password input boxes. A second pass looked for the buttons and links that actually start an OAuth 2.0 flow. Of the seeded sites, 728 had a login page supporting at least one IdP.
Many of those sites used small, niche IdPs, which would be too much work to study deeply. So the authors kept only IdPs used by at least 3 Client sites, giving 28. They then removed IdPs that required real personal information to register, blocked certain countries, or forced two-factor authentication (a second login step such as a code from a phone). That left 22 IdPs in scope.
Some sites used bot management or CAPTCHAs (the puzzles that ask you to prove you are human) and blocked the automated logins. In the end the authors completed 464 successful OAuth 2.0 flows between 378 Client sites and 16 IdPs.
They created test accounts by hand, giving each one unique details such as an email address and user name. Later, if those unique values appeared on the Client's callback page, it proved the flow had really completed. This is like writing your name on a test letter and checking it arrives at the other end.
To drive the flows automatically they built a tool they call the OAuth 2.0 Player, written in Node.js (a way to run JavaScript outside a browser) and using puppeteer to control a real Chrome browser. They used mitmproxy, a program that sits between the browser and the internet and can read and change traffic, to intercept the flows and inject their payloads. The tool starts the flow from the Client site, logs in to the IdP with the test account, and lands back on the callback endpoint. It checks that the buttons it found really start the flow, that the IdP page really is a login page, and that the URL contains the expected OAuth 2.0 parameters. Flows that fail these checks are thrown away. The tools are published at https://github.com/innotommy/OAuthpaper-code.
The threat model is the description of who the attacker is and what they can do. Here it is an ordinary web attacker with the same powers as any normal user: they can use the Client and the IdP normally, run OAuth 2.0 flows on their own browser, and use social engineering (tricking people into clicking links) to lure a victim. They cannot sit in the middle of the network connection and read or change traffic, and they cannot break secure channels. The authors stress that their techniques are building blocks, not complete attacks on their own, and that the targeted Clients and IdPs may have other ordinary bugs that the attacker combines with them.
Finding the gap in the rulebook
The authors started by reading the specification itself. RFC 6749 is the main OAuth 2.0 document, and Section [redacted] says:
The authorization server MUST compare the two URIs using simple string comparison as defined in RFC 3986 Section 6.2.1.
Line by line: the authorization server is the part of the IdP that hands out codes and tokens. MUST is rulebook language for "this is mandatory". A URI is a web address. Simple string comparison means comparing the two addresses character by character, and RFC 3986 Section 6.2.1 is the document that defines how that comparison works.
RFC 3986 Section 6.2.1 describes the comparison as going through the characters from the first one until one of three things happens: both strings run out at the same time, a pair of characters does not match, or one string runs out before the other. That is three stopping conditions, but the rulebook does not say what the result should be in each case. In particular, the case where two addresses share the same beginning but have different lengths is not expressly forbidden. If an IdP reads that as permission to be flexible, for example to allow dynamic parts in the address, or simply allows a non-exact match, then the check still stops someone tampering with the domain name but does not notice additions, deletions or changes to the path and query string that follow.
A comparison: checking that a parcel is addressed to your street but not checking the house number. The street is right, so it passes, even though the parcel is going somewhere else on that street.
RFC 6749 Section 3.1 also allows a query component in the redirect URI and requires it to be kept:
The endpoint URI MAY include an "application/x-www-form-urlencoded" formatted (per Appendix B) query component (RFC 3986 Section 3.4), which MUST be retained when adding additional query parameters.
Line by line: the endpoint URI is the callback address. MAY means "is allowed to". A query component is the part of a web address after the ? sign, made of name=value pairs. application/x-www-form-urlencoded is the standard way of writing those pairs. MUST be retained means the IdP has to keep that part intact when it adds its own parameters, such as the code.
RFC 6749 Section 10.14 acknowledges that attackers can inject things into redirect URI parameters and requires sanitisation and validation, but gives no precise instructions:
The authorization server and Client MUST sanitize (and validate when possible) any value received–in particular, the value of the "state" and "redirect_uri" parameters.
Line by line: both the IdP and the Client must clean up (sanitise) and check (validate) any value they receive, especially state and redirect_uri. But the rulebook does not say how. Combined with the requirement to keep extra query parameters, this leaves the redirect URI open to parameter pollution, where an attacker adds duplicate parameters and different parts of the system disagree about which one counts. The authors note that two researchers, Lauritz Holtmann and Youssef Sammouda, independently found specific evidence of parameter pollution in OAuth 2.0.
Both hypotheses hold even if Clients and IdPs follow the RFCs perfectly. The work does not rely on implementation bugs but on requirements that are under-specified, meaning the rulebook leaves too much open to interpretation.
Trick 1: path confusion
Path confusion means adding crafted pieces to the end of a web address to confuse the programs that read addresses, or to make two programs read the same address differently. It has been used before in other attacks, such as Web Cache Deception and Relative Path Overwrite.
The authors replaced the legitimate redirect URI with 20 payloads taken from earlier research. Client.com/callback/ is the legitimate endpoint and the rest is the malicious modification. The goal is to land the victim on a FAKEPATH endpoint on the Client site.
Line by line, the pieces to understand are:
FAKEPATHis a made-up marker the authors use to see where the browser ends up. If it appears in the final address, the trick worked.%2Fis the encoded form of a forward slash/. Web addresses cannot always contain certain characters directly, so they are written as a percent sign and two hex digits. This is called percent encoding or URL encoding.%2eis an encoded dot.. Two dots..mean "go up one folder" in a path, the same as in a file browser. Attackers use this to climb out of the intended folder.%25is an encoded percent sign. So%252eis a double-encoded dot: the first decoding turns%25into%, giving%2e, and a second decoding turns that into.. This is called layered encoding, and it catches programs that decode once but not twice.%3Bis an encoded semicolon;, a character some servers treat specially in paths.%0Aand%0Dare encoded line feed and carriage return characters, the ones used to end lines in text files. Some programs mishandle them.
The payloads combine path traversal tricks, encoded special characters and multiple encoding layers. Each flow was tested separately with all 20 payloads, with the proxy injecting them into the redirect URI while the request was in flight. An IdP was flagged as vulnerable if it did not stop the flow and did not clean the FAKEPATH marker, but instead sent the browser to a callback address containing FAKEPATH. Looking at the raw traffic for that final redirect was enough to identify a vulnerable IdP. Screenshots, proxy logs and the appearance of the test account details on the callback page were used as extra confirmation.
6 of the 16 IdPs were vulnerable to path confusion: Atlassian, Facebook, GitHub, Microsoft, NAVER and VK.
Trick 2: OAuth 2.0 parameter pollution (OPP)
The goal of OPP is to make the victim land on the Client callback endpoint with two different code parameters, one legitimate and one injected by the attacker. The attacker builds a URL for the IdP authorization endpoint with valid response_type=code, client_id, state and redirect_uri, then appends a code parameter to the redirect URI. The value can be anything, or a valid code obtained by starting another flow and stopping it after the Authorization Process. The ? and = of the appended query string are encoded to reduce the chance of a parsing error at the IdP.
Line by line: https://idp.example.com/oauth/authorize is the IdP's authorization endpoint, the page that starts the flow. response_type=code asks for a code. client_id=<valid ID> identifies the Client. state=<value> is the random value the Client will check later. redirect_uri= is where the browser should be sent back. Inside that value, %3F is an encoded ? and %3D is an encoded =, so the redirect URI secretly contains ?code=<value>, a second code parameter hidden inside the address. The angle brackets mark placeholders, not literal text.
- The attacker tricks the victim into visiting the URL, which starts a normal flow and takes the browser to the IdP's legitimate authorization page.
- The victim logs in and authorizes the Client. The IdP validates the redirect URI as prescribed, but the beginning matches the registered value, so the unexpected
codeparameter does not cause a failure. - The IdP keeps the redirect URI intact as required by RFC 6749 Section 3.1 and appends a second, freshly generated
code. - The victim lands on the callback endpoint with two
codeparameters. If the Client processes the attacker-injected one, the victim's valid code remains unused and can be leaked through another vulnerability for an account takeover.
10 of the 16 IdPs were impacted: GitHub, LINE, LinkedIn, Microsoft, NAVER, OK, ORCID, Slack, VK and Yahoo. They did not stop the flow or remove the extra parameter, and the browser landed on the callback endpoint with both code parameters intact.
Trick 3: the second check, when the code is swapped for a token
The attacker must also redeem the stolen code, and the Access Token Request carries a second redirect_uri that the Client builds, not the attacker. RFC 6749 Section 4.1.3 requires it to be identical to the one in the Authorization Request:
The Client makes a request to the token endpoint by sending the following parameters [...] redirect_uri REQUIRED, if the "redirect_uri" parameter was included in the authorization request as described in Section 4.1.1, and their values MUST be identical.
Line by line: the token endpoint is the IdP address where codes are swapped for tokens. REQUIRED means the parameter must be present in this situation. MUST be identical means the two addresses have to match exactly. The [...] marks text the authors left out.
In the first experiment the authors ran a path confusion attack in the Authorization Request but sent the original, unmodified redirect URI in the Access Token Request. If the flow completed despite the mismatch, the IdP was judged to validate incorrectly. In the second experiment the same was done with an OPP attack. GitHub and NAVER performed insufficient validation in the Redeem Process and allowed an end-to-end account takeover.
GitHub's documentation mentions the parameter but defines it incompletely ("The URL in your application where users are sent after authorization.") and marks it optional even when a redirect URI was supplied in the Authorization Request. The authors verified that leaving the value out entirely still produced a successful flow. NAVER's documentation and examples did not include a redirect URI in the Access Token Request at all, and a complete flow was possible with no redirect URI from the Client. It was not clear whether the string matching was flawed when a value was provided or whether validation was skipped entirely; both IdPs were exploitable in practice.
Trick 4: making the Client rebuild the attacker's address
A typical Client reads the Authorization Response and splits it into code, state and one block containing everything else. It checks state, then rebuilds the redirect URI by appending that block to the callback endpoint, as RFC 6749 Section 4.1.3 requires. Under OPP, the injected code becomes part of that block and is copied into the new redirect URI, which then matches the attack payload exactly. The authors tested this with the 10 OPP-vulnerable IdPs: only 6 (GitHub, LinkedIn, NAVER, OK, Slack and VK) completed the protocol. The other 4 refused to accept matching redirect URI values, contrary to expectation, which suggests arbitrary validation routines or custom memory of observed redirect URIs rather than a straightforward string comparison.
Trick 5: getting hold of the code
Path confusion and OPP remove the race condition that normally makes code leakage uninteresting. A race condition is when two parties compete to do something first, and here the legitimate flow would normally use the code before an attacker could. With these tricks the victim's code stays unused. Path confusion sends the user to an endpoint that does not expect an OAuth 2.0 flow and does not consume the code; OPP makes the Client proceed with the attacker's code. Path confusion also lets the attacker choose the callback path, so a data leak on any path of the Client can be used. The authors list XSS (cross-site scripting, where an attacker gets their own code to run in a page), style or HTML injection that extracts query parameters, open redirects (a link on a site that will forward you to any address an attacker chooses), multi-tenant sites where the attacker can register as a tenant on the same domain, and leaky third-party code inclusion across the whole site.
Case study: turning a low-risk open redirect into an account takeover
The authors searched the Open Bug Bounty program, a public list of reported website issues, for sites in their dataset with known, unresolved issues. The chosen issue was reported in 2018, assessed as very low risk and presumably not fixed. The site integrates with NAVER as an IdP, which escalates the low-risk open redirect to a complete OAuth 2.0 account takeover. The site is redacted because the vulnerability remained exploitable at the time of writing.
Line by line: https://nid.naver.com/oauth2.0/authorize is NAVER's authorization endpoint. client_id=<REDACTED> identifies the Client, hidden here. response_type=code asks for a code. redirect_uri= holds the attack. https%3A%2F%2F<REDACTED> is the encoded https:// plus the hidden site name. %2Fopenapi%2Fsocial%2Flogin.php is the path to a page on that site. Then /%252e%252e/%252e%252e/%252e%252e/redirect.php uses double-encoded .. to climb up three folders and land on redirect.php. %3Ftarget%3Dhttps%3a%2f%2f<attacker-domain>%2F is an encoded ?target=https://<attacker-domain>/, telling that redirect page where to send the visitor. state=random-state is a placeholder state value.
- The attacker tricks the victim into clicking the link.
- The victim lands on the legitimate NAVER login page and enters credentials.
- NAVER redirects back to the redacted site, to the page with the open redirect, because of the path confusion payload.
- The open redirect forwards the request to the attacker's domain, leaking the code.
- The attacker starts a new flow, intercepts it in the browser before the Authorization Response, injects the stolen code and forwards it to the redacted site.
- The site performs the Redeem Process, and because NAVER does not validate the redirect URI correctly, the flow succeeds and the attacker controls the victim's resources.
Case study: leaking codes through advertising
RFC 6749 Section [redacted] says Clients should not include third-party scripts in the redirection endpoint response, and if they do, their own scripts must run first. In the recorded flows, the authors found leaks to third-party domains in 46 of 464 measurements (10%), involving 11 of 16 IdPs (68%) and 30 sites (8%), with 76 distinct destination domains, the largest category being ad networks at 30%.
Real-Time Bidding (RTB) is how online ads are sold: when you load a page, advertisers bid in real time for the space, and they receive information about the visit, including the referral header, which tells them which page you came from. If the callback endpoint loads an ad service, advertisers receive bid requests that contain OAuth 2.0 parameters, and anyone can sign up as an advertiser and see them in real time. Normally the race condition makes this harmless, but OPP leaves the victim's code unused, and with an IdP that does not validate the Redeem Process correctly the situation escalates to a complete account takeover. The authors verified this with real websites. It can also be combined with path confusion when ad services are elsewhere on the site.
Why it works
The problem is in the specification, not in a single implementation. The prescribed comparison is a simple string comparison whose outcome for addresses of different lengths is not defined, so path and query string additions can pass. The requirement to keep query parameters, combined with the absence of precise sanitisation rules, allows duplicate security-sensitive parameters. The Redeem Process requirement of an identical value has no concrete guidance on how the comparison is performed. IdPs that follow the RFCs flawlessly can still be vulnerable, and a passing score from a compliance check framework such as OAuch does not necessarily reflect good security. The authors also note that non-standard validation routines, while sometimes blocking an attack, are error-prone and a common cause of hazardous interactions.
What it means for you
The result of the two techniques is that the authorization code is delivered to a maliciously modified callback endpoint. On its own this does not compromise the victim: the attacker must obtain the code and redeem it. With path confusion or OPP the victim's code stays unused, removing the race condition, and a leak on any path of the Client becomes usable. Combined with an IdP that validates the Redeem Process incorrectly, the outcome is a complete account takeover. The authors stress that not all findings translate to exploitable scenarios, because OAuth 2.0 is mature and IdPs and Clients may fill the gaps with custom design decisions, but end-to-end exploits against real applications were demonstrated. The full results are in Table 1 of the paper.
| IdP | Path Confusion | OPP | Redeem Validation |
|---|---|---|---|
| Atlassian | Vulnerable | Not Vulnerable | Correct |
| Dropbox | Not Vulnerable | Not Vulnerable | Correct |
| Vulnerable | Not Vulnerable | Correct | |
| GitHub | Vulnerable | Vulnerable | Incorrect |
| Kakao | Not Vulnerable | Not Vulnerable | Correct |
| LINE | Not Vulnerable | Vulnerable | Correct |
| Not Vulnerable | Vulnerable | Correct | |
| Microsoft | Vulnerable | Vulnerable | Correct |
| NAVER | Vulnerable | Vulnerable | Incorrect |
| OK | Not Vulnerable | Vulnerable | Correct |
| ORCID | Not Vulnerable | Vulnerable | Correct |
| Slack | Not Vulnerable | Vulnerable | Correct |
| Not Vulnerable | Not Vulnerable | Correct | |
| VK | Vulnerable | Vulnerable | Correct |
| Yahoo | Not Vulnerable | Vulnerable | Correct |
| Yandex | Not Vulnerable | Not Vulnerable | Correct |
How to fix it
The authors identified the parts where validation is under-specified and made recommendations to the OAuth Working Group. Their recommendations apply to both the Authorization Process and the Redeem Process and must be implemented consistently in both:
- Redirect URI validation must be a strict string equality check, stated clearly in the specification: equal size and an identical byte sequence, so that all components of the URI are covered.
- OAuth 2.0 parameters such as
codeandstatemust be reserved names. Servers must check the redirect URI for them and fail validation if present. Seeing them is either an attack indication or a Client namespacing issue. Doing the check on the server moves the responsibility from the Client to the IdP. - Servers must not sanitise the redirect URI. Any transformation or encoding/decoding of untrusted input can be weaponised to create parsing discrepancies. Redirect URI must always be validated, never sanitised.
One foreseeable hurdle is compatibility with existing Clients that reorder query parameters between the two steps or front OAuth 2.0 endpoints with transforming proxies. The authors suggest opt-in non-secure configuration options for Clients that need permissive validation.
Things you can try yourself
- Send the 20 path confusion payloads above as the redirect URI and watch the final redirect. A positive result is an Authorization Response URL containing
FAKEPATH. - Append an encoded
codeparameter to the redirect URI and complete the flow. A positive result is a callback URL with twocodeparameters. - Run a path confusion or OPP attack in the Authorization Request but send the original redirect URI in the Access Token Request. A positive result is a completed flow despite the mismatch.
- Leave the redirect URI out of the Access Token Request entirely. A positive result is a successful token response, as seen with GitHub and NAVER.
- Rebuild the redirect URI from the parsed custom parameter block as in the typical Client implementation. A positive result is a rebuilt value identical to the attack payload that the IdP accepts.
- Look for an open redirect, XSS or HTML injection on any path of a Client that uses a vulnerable IdP, and redirect the victim there. A positive result is the code arriving at a domain the attacker controls.
- Check whether callback endpoints load third-party ad or analytics scripts and inspect RTB bid requests for OAuth 2.0 parameters. A positive result is a
codevisible to an advertiser account.
Glossary
- Access token: a key the Client uses to read your data after you approve access.
- Account takeover: an attacker gaining control of your account.
- Authorization Code Grant: the common OAuth 2.0 flow where a short-lived code is swapped for an access token.
- Authorization Request: the request the Client sends to the IdP to start the flow.
- Authorization Response: the IdP's reply that carries the code back to the Client.
- Authorization server: the part of the IdP that issues codes and tokens.
- Bot management: software that detects and blocks automated programs.
- CAPTCHA: a puzzle used to prove a visitor is human.
- Chrome: Google's web browser.
- Client: the website you are signing in to.
- Client ID: a public name for the Client.
- Client secret: a private password for the Client.
- Code: a short-lived, single-use secret slip the Client swaps for an access token.
- Crawler: a program that visits web pages automatically.
- CSRF: cross-site request forgery, a trick that makes your browser send a request you did not intend.
- Endpoint: a specific web address that a program talks to.
- FAKEPATH: the made-up marker the authors use to see where the browser ends up.
- HPP: HTTP parameter pollution, sending duplicate parameters with different values.
- IdP (Identity Provider): the company that holds your account and signs you in.
- Layered encoding: encoding something that is already encoded, so it takes two decodings to reveal the real character.
- MAY / MUST / SHOULD / REQUIRED: rulebook words meaning allowed, mandatory, recommended and mandatory respectively.
- mitmproxy: a program that sits between the browser and the internet and can read and change traffic.
- Node.js: a way to run JavaScript outside a browser.
- OAuch: a framework that checks whether an IdP implements OAuth 2.0 correctly.
- OAuth 2.0: the standard that lets a website access your data on another site without your password.
- OAuth Working Group: the group that maintains the OAuth 2.0 specification.
- Open Bug Bounty: a public list of reported website issues.
- Open redirect: a link on a site that will forward you to any address an attacker chooses.
- OPP (OAuth 2.0 parameter pollution): sneaking a duplicate
codeparameter into the redirect URI. - Parameter pollution: adding duplicate parameters so different parts of a system disagree about which one counts.
- Path confusion: adding crafted pieces to a web address to confuse the programs that read addresses.
- Payload: the crafted piece of data an attacker sends.
- Percent encoding (URL encoding): writing special characters as a percent sign and two hex digits.
- Puppeteer: a tool that controls a Chrome browser automatically.
- Query component: the part of a web address after the
?, made of name=value pairs. - Race condition: two parties competing to do something first.
- Real-Time Bidding (RTB): how online ads are sold, with advertisers bidding in real time as a page loads.
- Redirect URI: the callback address on the Client where the IdP sends the code.
- Referral header: information sent with a request saying which page you came from.
- Regular expression: a pattern used to find text.
- RFC: an official document that defines an internet standard.
- Sanitise: clean up input to remove dangerous parts.
- Social engineering: tricking people into doing something, such as clicking a link.
- State: a random value the Client makes up to recognise its own request later.
- Threat model: a description of who the attacker is and what they can do.
- Token endpoint: the IdP address where codes are swapped for tokens.
- Tranco list: a public ranking of popular websites.
- URI: a web address.
- Validate: check that a value is correct.
- XSS (cross-site scripting): an attacker getting their own code to run in a page.