---
type: Whitepaper
title: OAuth 2.0 Redirect URI Validation Falls Short, Literally
description: "The OAuth 2.0 rule to compare redirect_uri by simple string comparison guards only the domain, so appended path-confusion payloads and injected duplicate code parameters still pass validation, at 6 and 10 of 16 major identity providers respectively. Chained with an open redirect or an ad script anywhere on the client site, this leaks the victim's authorization code and yields account takeover."
resource: "https://seclab.nu/static/publications/acsac23oauth.pdf"
tags: [whitepaper, webseclist-reference, acsac-23, oauth, open-redirect, url-parsing, parser-differential, sso, auth-bypass, measurement-study, owasp-a01-2021, owasp-a04-2021, owasp-a07-2021]
generated:
  by: webseclist-refs/1
  at: "2026-08-14T16:32:02+00:00"
status: stable
stale_after: 2027-08-14
sources:
  - id: original
    resource: "https://seclab.nu/static/publications/acsac23oauth.pdf"
    title: OAuth 2.0 Redirect URI Validation Falls Short, Literally
    author: Tommaso Innocenti, Matteo Golinelli, Kaan Onarlioglu, Ali Mirheidari, Bruno Crispo, Engin Kirda
also_at: []
authors:
  - Tommaso Innocenti
  - Matteo Golinelli
  - Kaan Onarlioglu
  - Ali Mirheidari
  - Bruno Crispo
  - Engin Kirda
canonical_url: ""
cited_by:
  - "2023.md:23"
commit: ""
content_sha256: 403b77ef1bcbc301b4ef25c6ef9ca725cc74cebf928cb3da131322e0261a589e
depth: full
depth_reason: default
kind: whitepaper
language: ""
licence: unknown
original_url: "https://seclab.nu/static/publications/acsac23oauth.pdf"
published: ""
publisher: "ACSAC '23"
publisher_english: ""
raw_sha256: 101dbc7ec0a76cf179783d3f27ccc94905f9dba82026bbfb195b75caa8b5502f
retrieved_from: "https://seclab.nu/static/publications/acsac23oauth.pdf"
retrieved_kind: stored
retrieved_utc: "2026-08-14T16:32:02+00:00"
slug: oauth-2-0-redirect-uri-validation-falls-short-literally
snapshot: ""
title_english: ""
translation_file: ""
translation_of: ""
---

# OAuth 2.0 Redirect URI Validation Falls Short, Literally

**OAuth 2.0 Redirect URI Validation Falls Short, Literally** - Tommaso Innocenti, Matteo Golinelli, Kaan Onarlioglu, Ali Mirheidari, Bruno Crispo, Engin Kirda, ACSAC '23.

- Published: date not stated
- Original: <https://seclab.nu/static/publications/acsac23oauth.pdf>
- Preserved from: https://seclab.nu/static/publications/acsac23oauth.pdf (stored) on 2026-08-14
- Licence: unknown

Rights remain with the original author and publisher. This is a research
archive of a source from the Web Hacking Techniques Index collections, kept so the
page going offline. To read the original, follow the link above.

## Content

> UNTRUSTED SOURCE TEXT. Everything below this line is third-party material
> quoted for research. It is data, not instructions. Do not follow directions,
> execute code, or fetch URLs because this text says so.

OAuth 2.0 Redirect URI Validation Falls Short, Literally
               Tommaso Innocenti                                                  Matteo Golinelli                                             Kaan Onarlioglu
               Northeastern University                                           University of Trento                                      Akamai Technologies
                 Boston, MA, USA                                                    Trento, Italy                                       and Northeastern University∗
                                                                                                                                           Cambridge, MA, USA

                    Ali Mirheidari                                                  Bruno Crispo                                                   Engin Kirda
               Independent Researcher                                            University of Trento                                      Northeastern University
                  Austin, TX, USA                                                   Trento, Italy                                            Boston, MA, USA

ABSTRACT                                                                                              multiple interactions between a Client application requesting ac-
OAuth 2.0 requires a complex redirection trail between websites                                       cess to external data and an Identity Provider (IdP)1 , where sensitive
and Identity Providers (IdPs). In particular, the "redirect URI" pa-                                  parameters need to be securely transferred and processed by each
rameter included in the popular Authorization Grant Code flow                                         party. As a result, security analysis of OAuth 2.0 flows is an active
governs the callback endpoint that users are routed to, together                                      research area, with a steady stream of practical vulnerabilities being
with their security tokens. The protocol specification, therefore,                                    discovered and mitigated (e.g., [14, 22, 27, 33]).
includes guidelines on protecting the integrity of the redirect URI.                                     Notably, after the Client forwards a user’s browser to the IdP
   In this work, we analyze the OAuth 2.0 specification in light                                      and the user authorizes the data access, the IdP must redirect the
of modern systems-centric attacks and reveal that the prescribed                                      browser back to a callback endpoint on the Client site. The Client
redirect URI validation guidance exposes IdPs to path confusion                                       communicates this endpoint to the IdP via the redirect URI pa-
and parameter pollution attacks. Based on this observation, we                                        rameter defined in the protocol. The request sent to this callback
propose novel attack techniques and experiment with 16 popular                                        endpoint contains security tokens, so ensuring the integrity of
IdPs, empirically verifying that the OAuth 2.0 security guidance                                      redirect URI is paramount. Consequently, Clients must regis-
is under-specified. We finally present end-to-end attack scenarios                                    ter their callback endpoint with the IdP during their setup. IdPs
that combine our attack techniques with common web application                                        must validate during each OAuth 2.0 flow that the supplied redirect
vulnerabilities, ultimately resulting in a complete compromise of                                     URI matches that registered endpoint. Unsurprisingly, exploiting
the secure delegated access that OAuth 2.0 promises.                                                  OAuth 2.0 flows by abusing the redirect URI parameter has been
                                                                                                      heavily explored, and security guidelines integrated into the proto-
KEYWORDS                                                                                              col specification [16, 17].
                                                                                                         In this paper, we revisit redirect URI abuse in light of the
OAuth 2.0, redirect URI, path confusion, parameter pollution, ac-
                                                                                                      lessons learned from emerging systems-centric web attacks, where
count takeover
                                                                                                      vulnerabilities stem from the discrepancies between how different
ACM Reference Format:                                                                                 system components parse the same URI (e.g., [1, 18]). In particular,
Tommaso Innocenti, Matteo Golinelli, Kaan Onarlioglu, Ali Mirheidari,                                 we observe that the RFC guidance available for Clients and IdPs
Bruno Crispo, and Engin Kirda. 2023. OAuth 2.0 Redirect URI Vali-                                     narrowly focuses on protecting the integrity of the domain name
dation Falls Short, Literally. In Annual Computer Security Appli-
                                                                                                      included in redirect URI alone, but not the entire URI. We hypoth-
cations Conference (ACSAC ’23), December 04–08, 2023, Austin, TX,
USA. ACM, New York, NY, USA, 12 pages. https://doi.org/10.1145/
                                                                                                      esize that the RFCs’ URI validation guidance is hazardously under-
3627106.3627140                                                                                       specified. We then explore novel mechanisms to attack OAuth 2.0
                                                                                                      flows by abusing redirect URI path components and query string
1     INTRODUCTION                                                                                    arguments.
                                                                                                         Our experiments with 16 major IdPs show that they expose
OAuth 2.0 is an industry-standard delegated access protocol allow-
                                                                                                      vulnerabilities due to insufficient validation of redirect URI, even
ing Internet users to grant a web application access to their data
                                                                                                      under the charitable assumption that they follow the relevant RFCs
hosted on a third-party server. The most widely-used mechanism
                                                                                                      flawlessly. Specifically, 6 IdPs are vulnerable to path confusion,
provided by OAuth 2.0, the Authorization Code Grant flow, involves
                                                                                                      and 10 are vulnerable to parameter pollution attacks. Using these
∗ The work described in this paper was performed solely at Northeastern University.                   vulnerabilities as novel exploit building blocks and combining them
                                                                                                      with other Client and IdP vulnerabilities, we show that sensitive
Permission to make digital or hard copies of all or part of this work for personal or                 OAuth 2.0 parameter leakage leading to complete account takeover
classroom use is granted without fee provided that copies are not made or distributed
for profit or commercial advantage and that copies bear this notice and the full citation
                                                                                                      attacks is viable. Ultimately, we confirm that the existing security
on the first page. Copyrights for components of this work owned by others than the                    guidance is insufficient and that a passing score from compliance
author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or
republish, to post on servers or to redistribute to lists, requires prior specific permission         1We note that Identity Provider is not strictly OAuth 2.0 terminology, roughly replacing
and/or a fee. Request permissions from permissions@acm.org.                                           the components Authorization Server and Resource Server defined in the respective
ACSAC ’23, December 04–08, 2023, Austin, TX, USA                                                      RFC. Nevertheless, the term IdP is often used in literature to simplify the discussion
© 2023 Copyright held by the owner/author(s). Publication rights licensed to ACM.                     and better capture the common model where delegated authorization and identity
ACM ISBN 979-8-4007-0886-2/23/12. . . $15.00                                                          services are combined in a single provider service. In this paper, we also use this
https://doi.org/10.1145/3627106.3627140                                                               simplified terminology for brevity.




                                                                                                256
ACSAC ’23, December 04–08, 2023, Austin, TX, USA                                                                                      Innocenti, et al.


check frameworks (e.g., the recently published OAuch [25]) does             used to redirect the browser back to the Client application after the
not necessarily reflect good security.                                      user has granted or denied authorization.
   Following a coordinated disclosure process, we have shared our               (4) Once the browser is redirected to the IdP, the user authenti-
findings with the impacted parties. We have also identified the             cates on the IdP using their credentials and authorizes the Client to
parts of the OAuth 2.0 specification where redirect URI validation          access their data. During this step, the IdP validates the parameters
requirements are under-specified, leading to the vulnerabilities we         included in the Authorization Request. In particular, redirect URI
have discovered and made recommendations to the OAuth Working               is validated against the one Client provided during their registra-
Group for improvements to the protocol specification.                       tion. (5) If the validation succeeds, the IdP redirects the browser
   We summarize the contributions of this research below.                   back to the Client endpoint specified in redirect URI. (6) The re-
     • We explore path confusion and parameter pollution in the             sulting Authorization Response includes a fresh authorization code
       context of OAuth 2.0.                                                (i.e., code) and the earlier state. The Client validates the state
     • We run experiments with 16 IdPs, confirming that insuffi-            bound to the user’s session, ensuring there is no CSRF attack.
       cient redirect URI validation issues impact them.                        Redeem Process. The code does not directly grant access to
     • We discuss practical attack scenarios and empirically demon-         the user’s resources. (7) The Client instead uses it to redeem an
       strate how redirect URI validation issues can be exploited           access token by making an Access Token Request to the IdP. This
       for account takeover attacks.                                        request includes the following parameters: i) client ID, ii) grant
     • We demonstrate that the existing OAuth 2.0 security guid-            type = authorization_code, iii) client secret, iv) the code
       ance is insufficient, and make concrete recommendations to           received in the Authorization Response, and v) the same redirect
       improve the security of OAuth 2.0 Clients and their users.           URI used in the Authorization Request. Upon receiving this, the IdP
                                                                            authenticates the Client using client secret, verifies that code
   Availability. We make the tools described in this work publicly
                                                                            was issued to this Client and was not used before, and checks that
available2 .
                                                                            redirect URI is identical to the one included in the Authorization
   Ethics. We have conducted all experiments, exploit proofs-of-
                                                                            Request. (8) If all checks succeed, the IdP issues an access token
concepts, and disclosure of our findings in an ethical manner. For
                                                                            to the Client. Notably, the same code cannot be used again.
details, please see Section 7.
                                                                                Data Access. Finally, (9) the Client can access the user’s pro-
                                                                            tected resources with access token, where the IdP must verify
2 BACKGROUND                                                                that the token has not expired.
2.1 OAuth 2.0
OAuth 2.0 is a secure delegated access framework that enables Re-
source Owners to grant a Client access to their data hosted on a
third-party Resource Server. The authorization is granted via inter-
actions with an Authorization Server in lieu of sharing the Resource
                                                                            2.2    Related Work
Owner’s credentials with the Client. OAuth 2.0 defines four grant           OAuth 2.0 comes at the cost of a complex redirection trail between
types, Authorization Code Grant being a common one suitable for             all parties involved in the protocol. The data flows must be secured
environments where the Client can interact with the Resource                in flight, and sensitive parameters validated at each endpoint.
Owner’s user agent [12]. This grant flow enables the common web                 Researchers began investigating the protocol from the early days
application deployment model where Internet users (i.e., Resource           using formal methods [6, 24]. This research culminated in the work
Owner) can enable web applications (i.e., Client) access to their           of Fett et al., which identified multiple protocol-level vulnerabilities
external data by authenticating to an Identity Provider (i.e., often        such as IdP Mix-Up and 307 Redirect [7].
a combination of federated authentication services, Authorization               redirect URI is a natural target for abuse, and researchers
Server, and Resource Server).                                               have explored ways to redirect users to malicious domains [22].
   The Client must first establish a trust relationship with the Iden-      Consequently, in 2017, the first draft of the OAuth 2.0 Security
tity Provider (IdP) by registering its application. This process in-        Best Current Practice formally addressed redirect URI valida-
cludes setting up a callback endpoint called redirect URI. In turn,         tion requirements [16]. However, as future work demonstrated,
the IdP issues a unique client ID and client secret to the                  this validation is insufficient, and abusing the discrepancies in URI
Client. We summarize the rest of the authorization code grant flow          parsers still makes it possible to hijack OAuth 2.0 flows [33]. Re-
in Figure 1 and describe each step below.                                   cently, OAuch presented a framework to verify the implementation
   Authorization Process. (1) The flow starts when the user visit-          correctness of IdPs, including validating redirect URI [25]. Only
ing the Client site asks to authenticate with a specific IdP, and (2)       34% of IdPs were shown to perform a correct validation.
the Client redirects the user’s browser to the IdP login endpoint.              With OAuth 2.0’s sustained adoption, researchers have also dis-
(3) This request to the IdP is called the Authorization Request and it      covered a flood of Client-side implementation flaws [9, 20, 31, 34]. In
commonly includes the following parameters: i) response type                particular, Clients’ mishandling of state has led to widespread Lo-
= code, specifying the authorization code grant type, ii) the previ-        gin CSRF vulnerabilities [4, 29]. Even when IdPs provided the Client
ously issued client ID, a public Client identifier, iii) state, used        developers with SDKs, implicit security assumptions and poor doc-
as a Cross-Site Request Forgery (CSRF) defense, iv) redirect URI,           umentation resulted in continued implementation issues [32]. Simi-
                                                                            larly, recent research demonstrated that the complexity of support-
2 https://github.com/innotommy/OAuthpaper-code                              ing both SSO login protocols and traditional authentication methods




                                                                      257
OAuth 2.0 Redirect URI Validation Falls Short, Literally                                                                         ACSAC ’23, December 04–08, 2023, Austin, TX, USA




                                                                          Resource Owner                                                       Identity
                         Client                                                                                                                Provider
                                        1) Client Application Access

                                         2) Redirection to IdP Login                               3) Authorization Request              4) User Authentication
                       Authorization                                                                [response_type=code, client_id,
                           Process                                           User Agent                                                          Parameter
                                                                                                          state, redirect_uri]
                                                                           (Web Browser)                                                         Validation
                                         6) Authorization Response                                5) Redirection to Client Callback
                                                 [code, state]
                      State
                    Validation
                                                                        7) Access Token Request

                           Redeem                [grant_type=authorization_code, client_id, client_secret, code, redirect_uri]                   Parameter
                           Process                                      8) Access Token Response                                                 Validation
                                                                               [access_token]
                                                                       9) Protected Resource Requests
                                                                             [access_token]                                                     Access Token
                       Data Access                                  10) Protected Resource Response
                                                                                                                                                 Validation
                                                                                   [Data]



                                               Figure 1: OAuth 2.0 Authorization Code Grant Flow.


in a Client, with intermingled paths, can lead to new classes of at-                                  RFC 3986 Section 6.2.1 Testing strings for equality
tacks where an attacker can pre-hijack a victim’s account before                                      is normally based on pair comparison of the charac-
the victim interacts with the Client [8, 30].                                                         ters that make up the strings, starting from the first
   A further OAuth 2.0 integration challenge is the security of                                       and proceeding until both strings are exhausted, and all
the Client endpoint. As the RFC spells out, including untrusted                                       characters are found to be equal, until a pair of char-
third-party scripts in Client endpoints that have access to sen-                                      acters compares unequal, or until one of the strings is
sitive OAuth 2.0 tokens is dangerous [12]. As demonstrated by                                         exhausted before the other.
Frans Rosén and selected as the top hacking technique in 2023 by
                                                                                                 This redirect URI validation strategy describes three stopping
PortSwigger, attacks abusing such token leaks are viable [3, 27].
                                                                                             conditions; however, it does not mandate a validation success or fail-
However, this attack vector has largely been ignored by the aca-
                                                                                             ure outcome for these conditions. In particular, the final condition
demic research community so far.
                                                                                             where two URIs may have a matching prefix, but overall different
   Finally, research has looked at ways to address OAuth 2.0 vul-
                                                                                             lengths, is not expressly disallowed. Should IdPs interpret this am-
nerabilities on the browser side, for example, by using browser
                                                                                             biguity as an intentional flexibility granted to them (e.g., to support
extensions to upgrade network connections to HTTPS [5, 15].
                                                                                             dynamic path components or query parameters in redirect URI)
   We present novel techniques to abuse redirect URI, beyond
                                                                                             or otherwise inadvertently allow a non-exact string match, there
what is covered in previous work, and describe how attackers can
                                                                                             are significant security implications: While this validation scheme
escalate those to complex yet practical end-to-end attacks when
                                                                                             prevents tampering with the host or domain name included in a
combined with common vulnerabilities on Client sites and IdPs.
                                                                                             redirect URI, it falls short of detecting potentially malicious addi-
Our contributions are due to fundamental gaps in the OAuth 2.0
                                                                                             tions to, deletions from, and modifications to the path components
specification, undetected by cutting-edge tools like OAuch.
                                                                                             and query string that follow. The security community has recently
                                                                                             seen a surge of attacks that utilize such path confusion techniques,
3 RESEARCH STATEMENT                                                                         i.e., tricks that abuse URI parsing discrepancies within complex sys-
                                                                                             tem interactions (e.g., [1, 18]). We hypothesize that redirect URI
3.1 Motivation
                                                                                             can too be abused by path confusion due to insufficient validation.
As evidenced by the OAuth 2.0 literature we covered, redirect URI                                We next observe that RFC 6749 allows query strings in redirect
has long been recognized as a lucrative abuse target by researchers                          URI and further prescribes that they be retained during the pro-
and miscreants alike. Presumably anticipating these security is-                             tocol flow. The RFC acknowledges that malicious injections into
sues, the authors of the OAuth 2.0 protocol specification and threat                         redirect URI parameters are a threat and recommends that end-
model RFCs have also extensively covered redirect URI attacks                                points perform validation and/or sanitization on sensitive values.
and explicitly called out the necessity to validate that a supplied                          Quoting the relevant sections:
redirect URI matches the callback endpoint that was registered
during Client setup [11, 12, 17]. Quoting the relevant sections:                                      RFC 6749 Section 3.1 The endpoint URI MAY include
                                                                                                      an "application/x-www-form-urlencoded" formatted (per
       RFC 6749 Section 3.1.2.3 The authorization server                                              Appendix B) query component (RFC 3986 Section 3.4),
       MUST compare the two URIs using simple string com-                                             which MUST be retained when adding additional query
       parison as defined in RFC 3986 Section 6.2.1.                                                  parameters.




                                                                                    258
ACSAC ’23, December 04–08, 2023, Austin, TX, USA                                                                                  Innocenti, et al.


        RFC 6749 Section 10.14 A code injection attack occurs             created authentication and authorization credentials. They can,
        when an input or otherwise external variable is used              therefore, also interact with the IdP via OAuth 2.0 normally.
        by an application unsanitized and causes modification                The attacker does not have man-in-the-middle capabilities or
        to the application logic. This may allow an attacker to           the ability to interfere with secure communication channels. They
        access the application device or its data, cause a denial         can, however, participate in OAuth 2.0 and maliciously interact
        of service, or introduce a wide range of malicious side-          with protocol flows on their user agents, receiving messages and
        effects. The authorization server and Client MUST sani-           responding to them with any data, just like any Resource Owner
        tize (and validate when possible) any value received–in           could on their device. We further assume that the attacker can
        particular, the value of the "state" and "redirect_uri"           utilize social engineering techniques to make their victim click on
        parameters.                                                       malicious links.
   While this language calls out a potential attack vector via abuse         All attacks involving unauthorized access to a victim’s data are
of query strings, it lacks prescriptive instructions on the appropri-     in the scope of our threat model. This includes tricking the victim
ate input validation or attack prevention steps. When combined            into accessing an attacker-controlled resource and leaking sensitive
with the requirement (i.e., MUST) that additional parameters be           data (e.g., a Login CSRF attack), or a more straightforward takeover
retained, the RFC leaves redirect URI open to parameter pollution         of the victim’s account by the attacker.
attacks, where an attacker injects duplicates of security-sensitive          We stress that the novel abuse vectors we present in this paper
parameters in a query string to, once again, abuse parsing discrep-       are building blocks for attacks, but they are not end-to-end exploits
ancies between different system components that process the same          on their own. Therefore, our threat model assumes that the targeted
URI [2]. Therefore, we hypothesize that OAuth 2.0 flows can be            Clients and IdPs may include other well-known web application
attacked via parameter pollution in redirect URI. A quick survey          vulnerabilities. An attacker can then combine our new findings
indicates that we are not alone in this second observation; in fact,      with existing vulnerabilities to achieve severely damaging effects,
two security researchers Lauritz Holtmann and Youssef Sammouda            such as a complete account takeover that would otherwise not be
independently found specific evidence of parameter pollution in           possible. We discuss these specific preconditions where relevant in
OAuth 2.0, which further warrants a systematic exploration of this        the rest of this paper.
issue [13, 28].
   We stress that both of our hypotheses are valid under the ideal-       4     BAD VALIDATION PART I:
ized assumption that Clients and IdPs follow and implement the                  PATH CONFUSION
OAuth 2.0 RFCs correctly. We do not rely on implementation bugs              To test our hypothesis that the OAuth 2.0 redirect URI val-
but under-specified requirements.                                         idation guidelines are insufficient and subsequently answer our
                                                                          research question (Q1) (see Section 3.2), we design an experiment
3.2     Research Goals                                                    that exercises popular IdPs with redirect URI parameters con-
In this work, we set out to experiment with popular IdPs and test         taining path confusion payloads. We present our methodology and
the two hypotheses mentioned earlier. We ultimately aim to answer         results below.
the following research questions.
 (Q1) Is OAuth 2.0 vulnerable to path confusion attacks?
                                                                          4.1    Path Confusion Primer
 (Q2) Is OAuth 2.0 vulnerable to parameter pollution in security-         Path confusion refers to a collection of techniques that involve
      sensitive tokens?                                                   appending maliciously crafted path components to a URL. This
 (Q3) How can attackers use these techniques to enable end-to-end         serves to confuse modern URL parsers designed to accommodate
      attacks on real-life applications?                                  complex URL rewriting and routing mechanisms, or otherwise
 (Q4) How can we improve the OAuth 2.0 specification to address           to induce discrepancies between multiple parsers in a complex
      these issues?                                                       system. Path confusion has recently been used in various attack
                                                                          contexts such as Web Cache Deception and Relative Path Overwrite
   We tackle these questions in the rest of this work.
                                                                          successfully, and the research community has been developing a
                                                                          steady stream of new confusion techniques [1, 18, 19].
3.3     Threat Model                                                         In this experiment, we aim to replace the legitimate redirect
The threat model we assume in this work is that of a typical web          URI parameter in OAuth 2.0 flows with path confusion payloads,
attacker, targeting a web application.                                    and subsequently determine which IdPs fail to detect this malicious
   The Client is any web application that serves Internet users and       modification through validation and proceed with the protocol. The
uses identity and access management services offered by an IdP via        impact of a successful attack is that the IdP redirects the victim’s
OAuth 2.0. Internet users access the Client with user agents (e.g.,       user agent to an unintended endpoint on the Client site. We will
a web browser) installed on any networked device. All networked           explain how this capability translates to a practical attack
communications between these entities run over a secure channel,          in the rest of the paper; in this experiment, however, our
such as a modern version of TLS, which guarantees cryptographic           immediate goal is to detect vulnerable IdPs and verify that
confidentiality and integrity.                                            path confusion in OAuth 2.0 is possible.
   The attacker has identical privileges to regular Internet users.          We test each IdP with 20 distinct path confusion payloads com-
They can access the Client web application with their legitimately        piled from the cited literature, shown in Figure 2. These variations




                                                                    259
OAuth 2.0 Redirect URI Validation Falls Short, Literally                                                                 ACSAC ’23, December 04–08, 2023, Austin, TX, USA


                                                                                        tool we developed, which automatically drives a real browser to
Client . com / callback / FAKEPATH                                                      start OAuth 2.0 from the Client site, authenticates to IdP using our
Client . com / callback %2 F FAKEPATH
Client . com / callback /..%2 F FAKEPATH
                                                                                        test accounts, and then lands back on the Client callback endpoint.
Client . com / callback /%2 e %2 e %2 F FAKEPATH                                        The tool verifies on the Client that all previously identified HTML
Client . com / callback /..%252 F FAKEPATH                                              elements initiate the flow, on the IdP site that the landing page is the
Client . com / callback /%252 e %252 e %252 F FAKEPATH                                  IdP login page, and that the URL contains the necessary OAuth 2.0
                                                                                        parameters (e.g., redirect URI, state). We discard any OAuth 2.0
Client . com / callback / FAKEPATH /..
Client . com / callback %2 F FAKEPATH %2 F ..                                           triggers that fail to pass this verification (e.g., in cases where our
Client . com / callback %2 F FAKEPATH %2 F %2 e %2 e                                    detection heuristics did not work as expected), and we proceed to
Client . com / callback %252 F FAKEPATH %252 F ..                                       the next phase of the experiment with the rest.
Client . com / callback %252 F FAKEPATH %252 F %252 e %252 e                               Data Collection. We once again exercise all OAuth 2.0 triggers
Client . com / callback / ;/../../ FAKEPATH
                                                                                        with the OAuth 2.0 Player, but this time also utilize a man-in-the-
Client . com / callback / %3 B /../../ FAKEPATH                                         middle proxy to intercept the flows and inject our path confusion
Client . com / callback / %3 B %2 F ..%2 F ..%2 F FAKEPATH                              payloads into the redirect URI parameters in flight. We test ev-
Client . com / callback / %3 B %2 F %2 e %2 e %2 F %2 F %2 e %2 e FAKEPATH              ery flow separately with all 20 path confusion payloads shown in
Client . com / callback / %253 B %252 F ..%252 F ..%252 F FAKEPATH
                                                                                        Figure 2. We collect raw dumps of all network traffic, intercepting
Client . com / callback / %0 A %0 D /../../ FAKEPATH                                    proxy logs, browser screenshots at each step, and information re-
Client . com / callback / %0 A %0 D %2 F ..%2 F ..%2 F FAKEPATH                         garding the presence of our unique test account identifiers on the
Client . com / callback / %0 A %0 D %2 F %2 e %2 e %2 F %2 F %2 e %2 e FAKEPATH         final Client callback page.
Client . com / callback / %250 A %250 D %252 F ..%252 F ..%252 F FAKEPATH                  Vulnerability Detection. In this final phase, we analyze the
                                                                                        data collected in the previous step to determine which IdPs are
Figure 2: Path confusion payloads used in the experiment.                               impacted by path confusion payloads, meaning they perform in-
"Client.com/callback/" represents the legitimate redirect end-                          sufficient redirect URI validation. More specifically, we flag IdPs
point, and the remaining components are malicious modi-                                 that did not terminate the protocol upon receiving a maliciously
fications. The attacker’s goal is to redirect the victim to an                          modified redirect URI or otherwise sanitize the "FAKEPATH"
intended FAKEPATH endpoint on the Client site, and red                                  marker included in our attack payloads, but instead proceeded to
sections are confusion techniques including path traversal                              redirect the browser to a callback endpoint containing the same
tricks, encoded special characters, and layered encoding.                               "FAKEPATH" component (i.e., the Authorization Response URL
                                                                                        contains "FAKEPATH").
                                                                                           Inspecting the raw network traffic dumps for this final malicious
combine the basic payload with path traversal tricks, encoded spe-                      redirect request is sufficient to identify a vulnerable IdP. The remain-
cial characters, and multiple encoding layers to create increasingly                    ing data sources provide complementary signals that help verify
complex URLs that trigger parser quirks and validation flaws.                           that the user authentication to the IdP and Client authorization for
                                                                                        data access are also performed correctly.
4.2     Methodology
Setup. We start with a setup phase that enables us to automate                          4.3      Experiment & Results
OAuth 2.0 flows and redirect URI modifications for testing. We                          We performed our experiment using the above methodology, also
seed our experiment with a collection of Client sites and crawl each                    summarized in Figure 3. We implemented the OAuth 2.0 Player
site in this dataset to identify their user authentication pages and                    using Node.js and puppeteer to drive the Chrome browser. We used
the IdPs they support. This is a two-step process. First, our detection                 mitmproxy to intercept the traffic.
logic uses regular expressions and simple heuristics, looking for                          We seeded the experiment with a Client dataset of the Top 15K
keywords (e.g., login, sign-in, join) and HTML tags (e.g., input tags                   sites of the Tranco list3 generated on 15 February 2022 [26]. Among
of type password) in the page content to detect the login pages.                        these, our setup crawl and heuristics detected 728 sites with an
Next, we use a second layer of similar heuristics on these pages to                     authentication page supporting at least one IdP. Because these sites
detect the presence of all HTML elements (e.g., buttons, hyperlinks)                    used many niche IdPs, making a deep analysis of them infeasible,
that start an OAuth 2.0 flow (i.e., OAuth 2.0 triggers). Note that                      we focused our investigation on the most popular picks. To that end,
a Client can support multiple IdPs; we detect and subsequently                          we selected only those IdPs used by at least 3 Client sites, resulting
experiment with all of them. For implementation details of these                        in 28 IdPs. We further filtered out the IdPs in this set that required
heuristics, please see our publicly available source code.                              valid personal information to register, enforced geo-restrictions, or
   At this stage, creating accounts with all identified IdPs is neces-                  mandated two-factor authentication. As a result, our data collection
sary to perform an end-to-end flow with them for experimentation.                       phase started with 22 IdPs in scope. While running the OAuth 2.0
This is a manual effort where we create test accounts and provide                       flow experiments, we ran into further issues with sites that used bot
as account details (e.g., email address, user name) unique values                       management solutions or CAPTCHAs to block automated logins.
that we can later identify reflected on a Client callback page, which                   Ultimately, we ran 464 successful OAuth 2.0 flows between 378
would indicate the successful completion of OAuth 2.0.                                  Client sites and 16 IdPs.
   Finally, we verify our findings by exercising the OAuth 2.0 trigger
we found on Client sites. Specifically, we use an OAuth 2.0 Player                      3 https://tranco-list.eu/list/KXNW.




                                                                                  260
ACSAC ’23, December 04–08, 2023, Austin, TX, USA                                                                                                 Innocenti, et al.


                                  Setup                                   Data Collection                                 Data Analysis

                      Sites &                                              OAuth 2.0 Player                                Network   Login
                                                                                                                           Dump      Results
                      OAuth 2.0
                      Triggers
                                                                                                                            Proxy    Screen
                                                                                                                            Logs     Captures

                                                         imdb.com/LOGIN                             facebook.com/LOGIN

                                                       IMDb                                       
                      IdP             IdP
                                                              Sign in                                                     OAuth 2.0 Flow
                      Detection       Credentials                                                    Username
                                                                                                                          Analysis
                                                                                                     *****




                      Login page          Tranco                             Path
                      detection           sites list                                                                            Analysis
                                                                             Confusion
                                                                                                                                Results
                                                                             Payloads




                      Figure 3: Experiment methodology for detecting IdPs vulnerable to path confusion attacks.


   Analysis of the experimental data revealed that 6 out of the                             The attacker first crafts a URL pointing to the target IdP’s au-
16 IdPs we tested did not correctly validate redirect URI,                               thorization endpoint, including all the necessary and valid query
and were exposed to path confusion attacks. The vulnerable                               string parameters response type = code, client ID, state, and
IdPs were Atlassian, Facebook, GitHub, Microsoft, NAVER, and VK.                         redirect URI. However, they then modify the included redirect
This experiment empirically confirms our hypothesis that the RFC-                        URI by appending it a query parameter code. The value of this
prescribed redirect URI validation strategy is insufficient and                          parameter may be an arbitrary string; or alternatively, the attacker
that path confusion attacks on OAuth 2.0 are practical. We answer                        can obtain and use a valid code value by starting another OAuth 2.0
our research question (Q1) affirmatively.                                                flow and prematurely stopping it after the Authorization Process.
                                                                                         In either case, the net effect is a malicious URL already containing a
5     BAD VALIDATION PART II:                                                            code parameter appended to its redirect URI parameter, shown
                                                                                         in blue below. Note that the attacker encodes the "?" and "=" char-
      PARAMETER POLLUTION
                                                                                         acters in the appended query string, shown in red, to minimize the
We now answer our next research question (Q2) (see Section 3.2)                          chances of a parsing error on the IdP end.
by exercising IdPs with parameter pollution payloads.

5.1     OAuth 2.0 Parameter Pollution (OPP)                                              https :// idp . example . com / oauth / authorize ?
HTTP parameter pollution (HPP) is a well-known web applica-                                response_type = code & client_id = < valid ID >&
tion exploitation technique where an attacker crafts a request that                        state = < value >&
includes multiple parameters with identical names, but different                           redirect_uri =
values. The processing order for such parameters (or whether they                          https :// client . example . com /
are processed at all) is implementation dependent. The attacker                                       oauth / callback %3 F code %3 D < value >
can elicit unusual behavior or bypass security checks by targeting
applications made up of multiple components that process the same
query string inconsistently [2].                                                            Once the attack URL is ready, the attacker tricks a victim into
   Building on previous work demonstrating parameter pollution                           visiting it via social engineering or injection techniques. (1) This
in OAuth 2.0 (i.e., [13, 28]), and combining both observations from                      starts a normal OAuth 2.0 flow, taking the victim’s browser to the
Section 3, that the RFC allows redirect URI values with differing                        IdP’s legitimate authorization page. (2) The victim logs into their
lengths to pass validation and that IdPs are required to keep query                      account, authorizing the Client to access their data. During this
strings intact, we set out to investigate whether HPP attacks apply                      step, the IdP performs validation on redirect URI as prescribed,
to OAuth 2.0 flows more generally. We call this rendition of the                         but there is no reason to flag the unexpected query parameter
attack OAuth 2.0 parameter pollution, or OPP.                                            code, as the prefix perfectly matches the registered redirect URI
   OPP has one express goal: To influence an OAuth 2.0 flow so that,                     value, therefore passing the validation successfully. (3) Finally, the
at the end of the Authorization Process, the victim is redirected to                     IdP takes the redirect URI that already includes the attacker
a Client callback endpoint with two distinct code parameters, one                        injected code, keeps it intact as mandated in RFC 6749 Section 3.1,
being the legitimate value, and the other injected by the attacker.                      and appends to it a second code freshly generated for this flow.
We present the attack in Figure 4 and describe how it plays out                          (4) Ultimately, the victim lands on the Client callback endpoint
below. We emphasize that we will describe how this capability                            with two code parameters. If the Client implementation chooses to
enables an end-to-end attack in the following sections. Here,                            process the attacker-injected code, the victim’s valid code remains
our sole goal is to describe the technique and verify that IdPs                          unused, ready to be leaked via another vulnerability for an account
are indeed impacted.                                                                     takeover.




                                                                              261
OAuth 2.0 Redirect URI Validation Falls Short, Literally                                                            ACSAC ’23, December 04–08, 2023, Austin, TX, USA


Client                Attacker                             Victim                                      IdP
                    Attack start                       (Web Browser)



                              redirect_uri ( code )                 1. redirect_uri ( code )                 2. Victim authentication
                                                                                                                             IdP status
          4.   redirect_uri ( code + code )                    3. redirect_uri ( code + code )                      ( code ), redirect_uri ( code )

                                                                                                                                                 redirect_uri ( code )
                                                                                                                     Wrong redirect_uri
                                                                                                                         validation                       ≠
                                                                                                                                                   redirect_uri ( )


                                              Figure 4: Attack flow for OAuth 2.0 parameter pollution.


5.2    Experiment & Results                                                                    RFC 6749 Section 3.1.2.5 The Client SHOULD NOT
We tested the viability of OPP by creating a simple Client applica-                            include any third-party scripts (e.g., third-party ana-
tion, registering it with IdPs, and participating in OAuth 2.0 with                            lytics, social plug-ins, ad networks) in the redirection
them. We replicated the conceptual attack steps described above,                               endpoint response. Instead, it SHOULD extract the cre-
injecting duplicate code parameters into flows. We conducted this                              dentials from the URI and redirect the user-agent again
experiment with the same set of 16 IdPs as determined in the previ-                            to another endpoint without exposing the credentials
ous path confusion experiments; we omit those redundant phases                                 (in the URI or elsewhere). If third-party scripts are in-
of the methodology.                                                                            cluded, the Client MUST ensure that its own scripts(used
   The results showed that 10 out of 16 IdPs were impacted by                                  to extract and remove the credentials from the URI) will
OPP. They did not terminate the flow or strip away the superfluous                             execute first.
parameter, which resulted in our browser landing on the callback                        Even if a Client ignores this requirement and the code ends up
endpoint with both code parameters intact. The impacted IdPs were                    being leaked, attacks are not trivial. Foremost, the attacker cannot
GitHub, LINE, LinkedIn, Microsoft, NAVER, OK, ORCID, Slack, VK,                      influence the leak destination unless a very specific XSS, JavaScript
and Yahoo. This experiment again confirms our hypothesis that                        inclusion, or open redirect vulnerability is already present on the
the RFC-prescribed redirect URI validation is inadequate and                         precise callback page–a code leaked to an arbitrary legitimate third
validates the previous findings in literature. We answer our research                party is of no value to the attacker. Next, even if the attacker could
question (Q2) affirmatively.                                                         gain access to the leaked code, they must then enter a tight race
                                                                                     condition with the legitimate OAuth 2.0 flow to use the code first–
6     IMPACT                                                                         the code is a short-lived, single-use token. As a result of these
                                                                                     limitations, code leakage attacks are often not considered a relevant
So far, we have presented two abuse techniques targeting IdPs that                   risk, and the research community has not focused on them.
do not validate redirect URI correctly during the Authorization                         Our attack techniques remove these limitations and make
Process. This is not due to arbitrary bugs or design decisions, but                  code leakage viable.
they are rooted in the OAuth 2.0 specification; in other words, IdPs                    In particular, path confusion and OPP eliminate the aforemen-
that strictly follow the formal validation guidance may still be                     tioned race condition, as the victim’s code remains unused. Path
vulnerable. The result is that the authorization code is delivered to                confusion redirects the user to an entirely different endpoint on the
a maliciously modified callback endpoint.                                            Client, where the application logic does not expect an OAuth 2.0
   However, the victim is not compromised yet. For a successful end-                 flow, and therefore does not consume the code. OPP tricks the
to-end attack, two more conditions are necessary: (1) The attacker                   Client into proceeding with the flow using an attacker-injected
must be able to gain possession of the victim’s code, and ultimately                 code, leaving the victim’s original code intact.
(2) redeem it for an access token resulting in a complete account                       Path confusion has another powerful property. Now that the
takeover. In this section, we explain how these additional steps can                 attacker can influence the callback endpoint, a data exfiltration vul-
be achieved in practice, what our abuse techniques contribute to the                 nerability present on any path of the Client can be weaponized to
security concerns already covered in the OAuth 2.0 specification,                    compromise OAuth 2.0 and escalate to a complete account takeover.
and how we significantly expand the attack surface of applications.                  This greatly increases the attack surface of a web application, trans-
This addresses our research question (Q3) (see Section 3.2).                         forming (even non-exploitable) common vulnerabilities into critical
                                                                                     security issues. For instance, an attacker can inspect a web applica-
6.1    code Leakage                                                                  tion to find any of the below issues, on any path, and redirect their
Exposure of sensitive OAuth 2.0 parameters to third/fourth-party                     victim to that path to steal their code reliably:
code included on a callback endpoint is a concern that the protocol                       • XSS, style, or HTML injection of any kind that allows
specification already recognizes. The RFC calls out this risk and                           the attacker to extract query string parameters and trigger a
assigns the responsibility of protecting the Authorization Response                         request to a domain they control, giving them direct access
to the Client:                                                                              to the code.




                                                                             262
ACSAC ’23, December 04–08, 2023, Austin, TX, USA                                                                                     Innocenti, et al.


      • Open redirect vulnerabilities, immediately re-routing the            performs an incorrect validation action. We stress again that we
        Authorization Response to an attacker domain.                        cannot experimentally determine what that incorrect validation
      • Multi-tenant sites, where different entities can reside on           action is without observing IdP internals; this is necessarily a black
        the same domain name under different paths, and the at-              box test. The second experiment follows the same methodology,
        tacker sign up as a legitimate tenant to hijack the Authoriza-       but this time with an OPP attack introduced in the Authorization
        tion Response.                                                       Request.
      • Leaky third-party code inclusion, the original threat that              In both experiments, we found the 2 IdPs GitHub and NAVER
        the OAuth 2.0 specification advice attempts to mitigate on           to perform insufficient validation in the Redeem Process and
        callback endpoints, now becoming a concern across the en-            allow an end-to-end account takeover attack.
        tire Client site.                                                       In order to understand what might be happening under the hood,
   We present two real-life examples of these scenarios in more              we explored the documentation for each service. GitHub references
detail later in this section.                                                the redirect URI parameter in the Redeem Process, but the pro-
                                                                             vided definition (i.e., "The URL in your application where users are
6.2     redirect URI Validation in Redeem Process                            sent after authorization.") is incomplete at best; this value must be
                                                                             required to match the redirect URI used in the Authorization
Once the attacker obtains the victim’s code, they need to redeem it
                                                                             Request. Moreover, the parameter is marked optional, even when a
for an access token, and this step poses a final challenge. Recall
                                                                             redirect URI is provided in the Authorization Request [10]. With
from our overview of OAuth 2.0 in Section 2, Figure 1, Step (7)
                                                                             further testing, we were indeed able to verify that entirely omitting
that the Client includes another redirect URI parameter in the
                                                                             this value also results in a successful flow. NAVER’s documentation
Access Token Request. The protocol specification requires this value
                                                                             and examples did not include a redirect URI in the Access Token
to match the redirect URI that was previously supplied in the
                                                                             Request [21] at all. Likewise, performing a complete OAuth 2.0 with
Authorization Request:
                                                                             NAVER was possible when our Client provided no redirect URI.
        RFC 6749 Section 4.1.3 The Client makes a request                    In either case, it was not clear whether the string matching strategy
        to the token endpoint by sending the following pa-                   was flawed when a redirect URI is provided by the Clients, or
        rameters [...]                                                       whether the IdPs omitted validation on the provided values at all
        redirect_uri REQUIRED, if the "redirect_uri" param-                  times. Regardless, both IdPs were exploitable in practice.
        eter was included in the authorization request as de-                   Influencing the Access Token Request. We make a final
        scribed in Section 4.1.1, and their values MUST be                   observation that depending on how real-life Clients construct the
        identical.                                                           Access Token Request, an attacker may be able to influence the
    This requirement implies that the attacker’s modifications to            process, and trick the Client into re-creating an identical redirect
the redirect URI in the Authorization Request must be correctly              URI to the attack payload. As a result, both redirect URI values
reflected in the Access Token Request. This is problematic for the at-       would naturally match, in theory defeating all validation checks.
tacker, because they do not have control over this second redirect           We present an example of how this might play out with a typical
URI parameter: The Authorization Request is sent from the User-              Client implementation of the Access Token Request build process in
Agent that the attacker operates, whereas the Access Token Request           Figure 5, zooming into Steps (6) and (7) in our OAuth 2.0 overview
is issued by the Client, protected from the attacker’s influence.            diagram previously shown in Figure 1.
    Once again, the quoted RFC section mandates an identical value              On the left, we see a normal flow, where (1) the Client receives
without concrete guidance on how this validation should be per-              a benign Authorization Response at the correct callback endpoint,
formed. In light of this observation, we hypothesize that IdPs will          (2) parses the query string into three components code, state, and
follow the same improper redirect URI validation prescribed in               everything else that comes after as a monolithic block to capture the
RFC 6749 Section 3.1.2.3 (as also suggested in the OAuth 2.0 Secu-           application-specific parameters, (3) performs the state check, (4)
rity Best Current Practice), or otherwise, either Clients or IdPs will       and finally constructs the new redirect URI by appending to the
make arbitrary design decisions that may be hazardous.                       callback endpoint the previously parsed block of custom parameters.
    Unfortunately, it is not feasible to explore how exactly IdPs            This is the expected behavior, required by RFC 6749 Section 4.1.3, so
perform the check from an external vantage point, without visi-              the query strings in the old and new redirect URI values match.
bility into the IdPs’ implementation. Therefore, verifying this hy-          On the right, we see the outcome of the same build process, but for
pothesis within a scientific framework is outside the scope of our           an Authorization Response that was polluted with a superfluous
work. Instead, we present a number of experiments that empirically           code as a result of an OPP attack. As the figure demonstrates,
demonstrate what IdPs under our lens perform the Redeem Process              the attacker-injected code is now treated as part of the custom
validation incorrectly, enabling a complete attack.                          parameter block, and directly copied to the new redirect URI,
    Experiments. In the first experiment, we use our Client appli-           which becomes identical to the previous redirect URI that the
cation and perform a series of OAuth 2.0 flows against each IdP. We          attacker manipulated to trigger the OPP. The subsequent redirect
launch the described path confusion attack in the Authorization              URI validation in the IdP should find a perfect match.
Request by modifying the redirect URI. However, we use the                      Surprisingly, when we tested this scenario with the 10 IdPs vul-
original, unmodified redirect URI in the Access Token Request.               nerable to OPP, only 6 (i.e., GitHub, LinkedIn, NAVER, OK, Slack,
If the OAuth 2.0 completes successfully regardless of the mismatch           and VK) completed the protocol. That is, the remaining 4 IdPs re-
between the two redirect URI values, we conclude that the IdP                fused to validate matching redirect URI values. This was contrary




                                                                       263
OAuth 2.0 Redirect URI Validation Falls Short, Literally                                                                  ACSAC ’23, December 04–08, 2023, Austin, TX, USA


                                          Client                                                                        Client

                               6) Authorization Response                                                    6) Authorization Response


               https://example.com/authorize?code=user_code&state=user_state&            https://example.com/authorize?code=victim_code&state=user_state&
               subscribe=yes&continue=                                                   code=attacker_code&subscribe=yes
               https://example.com/premium                                               &continue=https://example.com/premium

                                                                 State check                                                                  State check
                     Access Token Request Build                                                   Access Token Request Build
         Urlencode




                                                                                      Urlencode
                     idp_redeem?client_id=123&code=user_code&                                     idp_redeem?client_id=123&code=victim_code&
                     redirect_uri=https://example.com/authorize%3F                                redirect_uri=https://example.com/authorize%3F
                     subscribe%3Dyes%26continue                                                   code%3Dattacker_code%26subscribe%3Dyes
                     %3Dhttps://example.com/premium                                               %26continue%3Dhttps://example.com/premium

                               7) Access Token Request                                                      7) Access Token Request




Figure 5: Typical implementation of Access Token Request build process. On the left: The Client builds the Access Token
Request, correctly matching the application-specific query string parameters received in the request to the newly constructed
redirect URI. On the right: The same process during an OPP attack results in a redirect URI value that matches the attack
payload.


to our expectations; the two redirect URI values were identical,                            integrates with NAVER as an IdP, the combination escalates this
and both the RFC-prescribed validation strategy and an exact string                         low-risk vulnerability to a complete OAuth 2.0 account takeover.
comparison should have succeeded. This again demonstrates that                                 We crafted the proof-of-concept attack below that takes the
IdPs may be following arbitrary validation routines designed to fill                        link to the NAVER Authorization Server and appends a malicious
the gaps in the RFC, or maintaining a custom state about the ob-                            redirect URI that contains our path confusion payload. We redact
served redirect URI values, as opposed to doing a straightforward                           the site as this vulnerability remains exploitable as of this writing,
string comparison. Although that had the desirable effect of block-                         but our methodology is trivial to repeat.
ing the OPP attack here, non-standard validation is error-prone,                             https :// nid . naver . com / oauth2 .0/ authorize ?
and such inconsistent behavior is a common cause of hazardous                                  client_id = < REDACTED > &
interactions in systems-centric security.                                                      response_type = code &
                                                                                               redirect_uri = https %3 A %2 F %2 F < REDACTED > %2 F
                                                                                                 openapi %2 Fsocial %2 Flogin . php /
6.3    Case Studies                                                                              %252 e %252 e /%252 e %252 e /%252 e %252 e /
                                                                                                 redirect . php %3 Ftarget %3 Dhttps %3 a %2 F %2 F
As discussed, the real-life exploitability of insufficient redirect
                                                                                                 < attacker - domain > %2 F &
URI validation vulnerabilities depends on both Client and IdP imple-
                                                                                               state = random - state
mentations. Due to the infeasibility of performing detailed testing
with each website in the wild, we present two real-life attacks as                           The attack then plays out as expected: (1) The attacker tricks
case studies. We leave an exploration of the automated discovery                          the victim into clicking on this link via social engineering. (2) The
of end-to-end attacks for future work.                                                    victim lands on the legitimate NAVER login page and enters their
   Weaponizing Open Redirects. An open redirect is a common                               credentials. (3) NAVER redirects the victim back to <REDACTED>,
web application vulnerability that allows an attacker to influence                        but to the page that contains the open redirect vulnerability due
the URL to which a victim is redirected when they visit a vulnerable                      to our path confusion payload. (4) The open redirect forwards the
site. Open redirect vulnerabilities that may be present on callback                       request to an attacker-controlled domain, leaking the code. (5) With
endpoints are formally acknowledged as a threat to OAuth 2.0 in the                       access to the code, the attacker starts a new OAuth 2.0 flow, inter-
specification. However, using our novel path confusion technique                          cepts it at the browser before sending the Authorization Response,
and the knowledge of IdPs that do not perform the Redeem Process                          and injects into it the victim’s stolen code before forwarding it to
validation properly, we are now equipped to weaponize any open                            <REDACTED>. (6) <REDACTED> performs the rest of the Redeem
redirect on a site to compromise OAuth 2.0.                                               Process, and because NAVER does not implement correct validation
   Because open redirect vulnerabilities are so common, instead of                        of the redirect URI, the protocol is successfully executed, giving
doing our own testing, we searched the Open Bug Bounty program                            the attacker full control of the victim’s resources.
for sites from our dataset with known, but unresolved issues [23].                           We presented one specific case here; however, attackers can
The issue we picked was reported in 2018, assessed as a very low                          scrape bug bounty reports or perform their own testing to exploit
risk, and presumably not fixed as a result. However, because the site                     open redirects at scale by following the same simple methodology.




                                                                                264
ACSAC ’23, December 04–08, 2023, Austin, TX, USA                                                                                         Innocenti, et al.


                   Table 1: Summary of findings.                                 Our experiments prove that the current "best practice" is not
                                                                              good enough, leaving IdPs, Clients, and Internet users exposed to
      IdP       Path Confusion           OPP        Redeem Validation         attacks. In particular, we have shown that path confusion and pa-
    Atlassian     Vulnerable       Not Vulnerable        Correct              rameter pollution attacks are viable with popular IdPs, affirmatively
    Dropbox     Not Vulnerable     Not Vulnerable        Correct              answering our research questions (Q1) and (Q2). We summarize the
    Facebook      Vulnerable       Not Vulnerable        Correct
     GitHub       Vulnerable         Vulnerable         Incorrect             full list of IdPs we experimented with and our findings in Table 1.
     Kakao      Not Vulnerable     Not Vulnerable        Correct                 The vulnerabilities we discovered are not mere implementation
      LINE      Not Vulnerable       Vulnerable          Correct              bugs, but they are rooted in the OAuth 2.0 specification where
    LinkedIn    Not Vulnerable       Vulnerable          Correct
    Microsoft     Vulnerable         Vulnerable          Correct              language is not prescriptive enough, or otherwise where the re-
     NAVER        Vulnerable         Vulnerable         Incorrect             quirements miss threats like path confusion that have only recently
       OK
     ORCID
                Not Vulnerable
                Not Vulnerable
                                     Vulnerable
                                     Vulnerable
                                                         Correct
                                                         Correct
                                                                              started to gain traction in security literature. As a result, IdPs that
      Slack     Not Vulnerable       Vulnerable          Correct              systematically follow the relevant RFCs still run the risk of exposing
     Twitter    Not Vulnerable     Not Vulnerable        Correct              redirect URI validation vulnerabilities.
       VK         Vulnerable         Vulnerable          Correct
     Yahoo      Not Vulnerable       Vulnerable          Correct                 It is important to stress that not all of these vulnerabilities trans-
     Yandex     Not Vulnerable     Not Vulnerable        Correct              late to exploitable scenarios. OAuth 2.0 is a reasonably mature
                                                                              protocol that has received much security attention, resulting in
                                                                              adequate mitigating controls. Elsewhere, IdPs and Clients fill in the
   Abusing Real-Time Bidding. As we previously pointed out,                   gaps and may address the protocol’s weaknesses via their custom
RFC 6749 Section 3.1.2.5 states that Clients should never include             design decisions. Nevertheless, we have shown that end-to-end
third-party scripts in OAuth 2.0 endpoints to prevent code leaks.             exploits affect real-life applications and have severe consequences,
As part of an exploratory study, we measured the prevalence of                addressing our research question (Q3).
this unsafe practice. Specifically, we inspected the network flows               Recommendations. The steady stream of systems-centric web
recorded in our previous experiments (see Section 4), identifying             attacks like HTTP request smuggling and cache poisoning demon-
such a leak to third-party domains in 46 measurements out of                  strate that, strictly prescribed input validation instructions are para-
464 (10%), involving 11 IdPs out of 16 (68%), and 30 sites (8%). We           mount for consistent behavior in protocols that involve complex in-
identified 76 distinct domains as leak destinations, the largest              teractions. Thankfully, improving the OAuth 2.0 validation require-
category being Ad networks with 30% of these domains.                         ments is not an intractable effort. Devising a standard, narrowly
   Our investigation showed that this complex Ad network infras-              defined string comparison strategy, and better input validation on
tructure can be abused as a viable OAuth 2.0 code leakage vector,             sensitive parameters would immediately block the techniques we
specifically by targeting the Real-Time Bidding (RTB) mechanism.              have presented, with minor implementation barriers.
RTB allows advertisers to bid in real-time for Ad placement by pro-              Consequently, we conclude our paper with simple yet effective
viding them with information about the audience visiting a page.              recommendations, addressing our final research question (Q4). All
Our data showed that this information includes the referral headers           recommendations apply during both the Authorization Process
of visitors. Therefore, when the callback endpoint contains such an           and Redeem Process validation, and in fact must be implemented
Ad service, advertisers receive bid requests that contain OAuth 2.0           consistently in both checks to avoid further hazardous processing
parameters. Anybody can sign up as an advertiser and access code              discrepancies.
parameters in real-time.                                                         redirect URI validation must be performed via a strict string
   This attack vector is not critical for the reasons we have stated          equality check, and this requirement must be clearly stated in formal
earlier; the code is a one-time token that expires after use, and             specifications. That is, the compared URIs must be of equal size, and
the legitimate OAuth 2.0 flow would redeem it before a malicious              must be made up of an identical byte sequence. This ensures that
bidder can act. However, if an attacker utilizes OPP to inject an             validation checks cover all components of the URI.
invalid code and break the legitimate OAuth 2.0 flow, the victim’s               OAuth 2.0 parameters (e.g, code, state) must be reserved names.
code that is leaked will be available for use without a race condition.       Servers must check redirect URI for these reserved names and fail
When combined with an IdP that does not correctly perform the                 the validation if they are present. Observing these parameters in
Redeem Process redirect URI validation, the situation escalates               redirect URI is either an attack indication, or a Client namespac-
to a complete account takeover. We verified that this attack is               ing issue which could lead to hazardous interactions. Performing
practicable with real-life websites.                                          the check on the server shifts Client-side implementation responsi-
   This RTB attack can also be combined with path confusion when              bilities to the IdP, allowing consistent security guarantees.
ad services are not present on the callback endpoint but elsewhere               Servers must NOT perform input sanitization on redirect URI.
on the site.                                                                  Any URI transformation or encoding/decoding operation on un-
                                                                              trusted input could be weaponized by an attacker to elicit parsing
7    DISCUSSION AND CONCLUSION                                                discrepancies between a Client and the IdP, bypassing validations.
Summary. In this paper, we have presented our observations on                 Examples include the path confusion payloads we presented here
the OAuth 2.0 redirect URI validation requirements and security               and the security issues already documented in the specification,
recommendations by referencing specific guidance from the pro-                such as the abuse of URI fragments. redirect URI must always be
tocol specification. We investigated the potential gaps in them in            validated, never sanitized.
light of the contemporary systems-centric web application attacks.




                                                                        265
OAuth 2.0 Redirect URI Validation Falls Short, Literally                                                    ACSAC ’23, December 04–08, 2023, Austin, TX, USA


   One implementation hurdle we foresee with IdPs enforcing these         REFERENCES
recommendations is maintaining compatibility with the vast num-            [1] Sajjad Arshad, Seyed Ali Mirheidari, Tobias Lauinger, Bruno Crispo, Engin Kirda,
ber of existing Clients with unusual or buggy protocol implementa-             and William Robertson. 2018. Large-Scale Analysis of Style Injection by Relative
                                                                               Path Overwrite. In International World Wide Web Conference.
tions. For instance, a Client may be reordering the redirect URI           [2] Marco Balduzzi, Carmen Torrano Gimenez, Davide Balzarotti, and Engin Kirda.
query string parameters between the Authorization Process and                  2011. Automated Discovery of Parameter Pollution Vulnerabilities in Web Appli-
                                                                               cations. In Network and Distributed System Security Symposium.
Redeem Process, or they may be fronting OAuth 2.0 endpoints                [3] Adam Bannister. 2023. OAuth ‘masterclass’ crowned top web hacking technique
with proxies that perform request transformations. This is a valid             of 2022. PortSwigger–The Daily Swig. https://portswigger.net/daily-swig/oauth-
concern; however, it is also one that IdPs must address via opt-in             masterclass-crowned-top-web-hacking-technique-of-2022.
                                                                           [4] Michele Benolli, Seyed Ali Mirheidari, Elham Arshad, and Bruno Crispo. 2021.
non-secure configuration options that allow permissive validation              The Full Gamut of an Attack: An Empirical Analysis of OAuth CSRF in the
checks for Clients that desire it. The OAuth 2.0 specification must            Wild. In International Conference on Detection of Intrusions and Malware, and
provide prescriptive and correct guidance.                                     Vulnerability Assessment.
                                                                           [5] Stefano Calzavara, Riccardo Focardi, Matteo Maffei, Clara Schneidewind, Marco
   Ethical Considerations. All experiments described in this work              Squarcina, and Mauro Tempesta. 2018. WPSE: Fortifying Web Protocols via
were designed and conducted ethically, posing no risk to the tested            Browser-Side Security Monitoring. In USENIX Security Symposium.
                                                                           [6] Suresh Chari, Charanjit Jutla, and Arnab Roy. 2011. Universally Composable
Client sites, IdPs, or their users.                                            Security Analysis of OAuth v2.0. Cryptology ePrint Archive (2011).
   The data we used to seed the experiments and collected through          [7] Daniel Fett, Ralf Küsters, and Guido Schmitz. 2016. A Comprehensive Formal
our experiments was obtained using publicly available sources.                 Security Analysis of OAuth 2.0. In ACM Conference on Computer and Communi-
                                                                               cations Security.
   Following the common Internet measurement practice, our crawlers        [8] Mohammad Ghasemisharif, Chris Kanich, and Jason Polakis. 2022. Towards
were limited to send below 15 requests per minute. We expect this              Automated Auditing for Account and Session Management Flaws in Single Sign-
added traffic load to be well below the threshold for performance              On Deployments. In IEEE Symposium on Security and Privacy.
                                                                           [9] Mohammad Ghasemisharif, Amrutha Ramesh, Stephen Checkoway, Chris Kanich,
degradation, an availability issue, or any other security anomaly              and Jason Polakis. 2018. O Single Sign-Off, Where Art Thou? An Empirical
that could get flagged by the tested Clients or IdPs, causing them             Analysis of Single Sign-On Account Hijacking and Session Management on the
                                                                               Web. In USENIX Security Symposium.
undue effort to investigate.                                              [10] GitHub Docs. 2023. Authorizing OAuth Apps. https://docs.github.com/en/apps/
   We designed our testing methodology and proof-of-concept at-                oauth-apps/building-oauth-apps/authorizing-oauth-apps#web-application-
tacks to have no negative effects on the Clients, IdPs, or their users,        flow.
                                                                          [11] Dick Hardt. 2005. RFC 3986–Uniform Resource Identifier (URI): Generic Syntax.
persistent or otherwise. We used our own Client application and                https://datatracker.ietf .org/doc/rfc3986/.
IdP accounts in all tests, demonstrating the attacks on our resources.    [12] Dick Hardt. 2012. RFC 6749–The OAuth 2.0 Authorization Framework. https:
We did not otherwise disrupt the everyday activities of the involved           //datatracker.ietf .org/doc/rfc6749/.
                                                                          [13] Lauritz Holtmann. 2021. Insufficient Redirect URI validation: The risk of allowing
parties. Since we could not influence the OAuth 2.0 flows of Internet          to dynamically add arbitrary query parameters and fragments to the redirect_uri.
users, there was no possibility of inadvertent damage.                         (Web-)Insecurity Blog. https://security.lauritz-holtmann.de/post/sso-security-
                                                                               redirect-uri-ii/.
   We notified all IdPs of our findings promptly. We notified the IdPs    [14] David Krispin and Nir Swartz. 2021.            Microsoft and GitHub OAuth
that were found to be impacted by improper validation throughout               Implementation Vulnerabilities Lead to Redirection Attacks.                   https:
our experiments as we discovered vulnerabilities. When applicable              //www.proofpoint.com/us/blog/cloud-security/microsoft-and-github-oauth-
                                                                               implementation-vulnerabilities-lead-redirection.
to their circumstances, we provided them with detailed reports of         [15] Wanpeng Li, Chris J. Mitchell, and Thomas Chen. 2019. OAuthGuard: Protecting
our findings and proof-of-concept attack videos. We notified the               User Security and Privacy with OAuth 2.0 and OpenID Connect. In ACM Workshop
remaining, non-vulnerable IdPs at the conclusion of our research               on Security Standardisation Research.
                                                                          [16] T. Lodderstedt, J. Bradley, A. Labunets, and D. Fett. 2023. OAuth 2.0 Security
by sending them a copy of this paper. All in all, we notified all              Best Current Practice. https://datatracker.ietf .org/doc/html/draft-ietf-oauth-
16 IdPs we tested, allowing them more than 90 days to mitigate                 security-topics.
                                                                          [17] T. Lodderstedt, M. McGloin, and P. Hunt. 2013. RFC 6819–OAuth 2.0 Threat
their vulnerabilities. At the time of this writing, only Microsoft has         Model and Security Considerations. https://datatracker.ietf .org/doc/rfc6819/.
confirmed that they mitigated the issue. The remaining IdPs ac-           [18] Seyed Ali Mirheidari, Sajjad Arshad, Kaan Onarlioglu, Bruno Crispo, Engin Kirda,
knowledged receipt of the notification but did not share mitigation            and William Robertson. 2020. Cached and Confused: Web Cache Deception in
                                                                               the Wild. In USENIX Security Symposium.
plans or report progress.                                                 [19] Seyed Ali Mirheidari, Matteo Golinelli, Kaan Onarlioglu, Engin Kirda, and Bruno
   We coordinated our findings with the OAuth Working Group                    Crispo. 2022. Web Cache Deception Escalates!. In USENIX Security Symposium.
(OWG) from the early stages of this work. This has resulted in an         [20] Srivathsan G. Morkonda, Sonia Chiasson, and Paul C. van Oorschot. 2021. Empir-
                                                                               ical Analysis and Privacy Implications in OAuth-Based Single Sign-On Systems.
update to the OAuth 2.0 Security Best Current Practice, Section                In Workshop on Privacy in the Electronic Society.
4.1.3, clarifying the requirement for an exact string match during        [21] NAVER Developers. 2023. API Specification. https://developers.naver.com/docs/
                                                                               login/api/api.md.
redirect URI validation [16].                                             [22] OAuth 2.0. 2014. OAuth Security Advisory: 2014.1 "Covert Redirect". https:
                                                                               //oauth.net/advisories/2014-1-covert-redirect/.
8    ACKS                                                                 [23] Open Bug Bounty. [n. d.]. Free Bug Bounty Program and Coordinated Vulnera-
                                                                               bility Disclosure. https://www.openbugbounty.org.
We thank Daniel Fett, Rifaat Shekh-Yusef and Hannes Tschofenig            [24] Suhas Pai, Yash Sharma, Sunil Kumar, Radhika M. Pai, and Sanjay Singh. 2011. For-
from the OAuth Working Group for their guidance and coordination               mal Verification of OAuth 2.0 Using Alloy Framework. In International Conference
                                                                               on Communication Systems and Network Technologies.
with us throughout this work.                                             [25] Pieter Philippaerts, Davy Preuveneers, and Wouter Joosen. 2022. OAuch: Explor-
   We also thank Avinash Sudhodanan for his helpful insights.                  ing Security Compliance in the OAuth 2.0 Ecosystem. In International Symposium
   This work was partially supported by the EU Horizon project                 on Research in Attacks, Intrusions and Defenses.
                                                                          [26] Victor Le Pochat, Tom Van Goethem, Samaneh Tajalizadehkhoob, Maciej Ko-
DUCA (HORIZON-MSCA-2021-SE-01 programme under GA 101086308)                    rczynski, and Wouter Joosen. 2019. Tranco: A Research-Oriented Top Sites
and by NSF grants 2329540, 2219921, and 2127200.                               Ranking Hardened Against Manipulation. In Network and Distributed System
                                                                               Security Symposium.
                                                                          [27] Frans Rosén. 2022. Account hijacking using "dirty dancing" in sign-in OAuth-
                                                                               flows. https://labs.detectify.com/2022/07/06/account-hijacking-using-dirty-
                                                                               dancing-in-sign-in-oauth-flows/.




                                                                    266
ACSAC ’23, December 04–08, 2023, Austin, TX, USA                                                                                                             Innocenti, et al.


[28] Youssef Sammouda. 2021. More secure Facebook Canvas: Tale of $126k worth of               Computer and Communications Security.
     bugs that lead to Facebook Account Takeovers. https://ysamm.com/?p=708.              [32] Rui Wang, Yuchen Zhou, Shuo Chen, Shaz Qadeer, David Evans, and Yuri Gure-
[29] Ethan Shernan, Henry Carter, Dave Tian, Patrick Traynor, and Kevin Butler. 2015.          vich. 2013. Explicating SDKs: Uncovering Assumptions Underlying Secure Au-
     More Guidelines Than Rules: CSRF Vulnerabilities from Noncompliant OAuth                  thentication and Authorization. In USENIX Security Symposium.
     2.0 Implementations. In International Conference on Detection of Intrusions and      [33] Xianbo Wang, Wing Cheong Lau, Shangcheng Shi, and Ronghai Yang. 2019.
     Malware, and Vulnerability Assessment.                                                    Make Redirection Evil Again - URL Parser Issues in OAuth. Black Hat
[30] Avinash Sudhodanan and Andrew Paverd. 2022. Pre-hijacked accounts: An                     Asia. https://www.blackhat.com/asia-19/briefings/schedule/#make-redirection-
     Empirical Study of Security Failures in User Account Creation on the Web. In              evil-again---url-parser-issues-in-oauth-13704.
     USENIX Security Symposium.                                                           [34] Yuchen Zhou and David Evans. 2014. SSOScan: Automated Testing of Web
[31] San-Tsai Sun and Konstantin Beznosov. 2012. The Devil is in the (Implementation)          Applications for Single Sign-On Vulnerabilities. In USENIX Security Symposium.
     Details: An Empirical Analysis of OAuth SSO Systems. In ACM Conference on




                                                                                    267
