<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.nl" -->
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd' []>
<rfc ipr="trust200902" submissionType="IETF" category="bcp" xml:lang="en" consensus="yes" docName="draft-ietf-oauth-security-topics-13">
<?rfc toc="yes"?><?rfc symrefs="yes"?><?rfc sortrefs="yes"?><?rfc compact="yes"?><?rfc subcompact="no"?><?rfc comments="no"?>
<front>
<title abbrev="oauth-security-topics">OAuth 2.0 Security Best Current Practice</title><author initials="T." surname="Lodderstedt" fullname="Torsten Lodderstedt"><organization>yes.com</organization><address><postal><street></street>
</postal><email>torsten@lodderstedt.net</email>
</address></author>
<author initials="J." surname="Bradley" fullname="John Bradley"><organization>Yubico</organization><address><postal><street></street>
</postal><email>ve7jtb@ve7jtb.com</email>
</address></author>
<author initials="A." surname="Labunets" fullname="Andrey Labunets"><organization>Facebook</organization><address><postal><street></street>
</postal><email>isciurus@fb.com</email>
</address></author>
<author initials="D." surname="Fett" fullname="Daniel Fett"><organization>yes.com</organization><address><postal><street></street>
</postal><email>mail@danielfett.de</email>
</address></author>
<date year="2019" month="July" day="8"></date>
<area>Security</area><workgroup>Web Authorization Protocol</workgroup><keyword>security</keyword>
<keyword>oauth2</keyword>
<keyword>best current practice</keyword>

<abstract><t>This document describes best current security practice for OAuth 2.0.
It updates and extends the OAuth 2.0 Security Threat Model to
incorporate practical experiences gathered since OAuth 2.0 was
published and covers new threats relevant due to the broader
application of OAuth 2.0.</t>
</abstract>

</front>

<middle>

<section anchor="Introduction" title="Introduction">
<t>Since its publication in <xref target="RFC6749"></xref> and
<xref target="RFC6750"></xref>, OAuth 2.0 has gotten massive traction
in the market and became the standard for API protection and, as the
foundation of OpenID Connect <xref target="OpenID"></xref>, identity providing. While
OAuth was used in a variety of scenarios and different kinds of
deployments, the following challenges could be observed:</t>
<t>
<list style="symbols">
<t>OAuth implementations are being attacked through known
implementation weaknesses and anti-patterns (CSRF, referrer
header). Although most of these threats are discussed in the OAuth
2.0 Threat Model and Security Considerations <xref target="RFC6819"></xref>,
continued exploitation demonstrates there may be a need for more
specific recommendations, that the existing mitigations may be too
difficult to deploy, and that more defense in depth is needed.</t>
<t>Technology has changed, e.g., the way browsers treat fragments in
some situations, which changes the implicit grant's underlying
security model.</t>
<t>OAuth is being used in environments with higher security
requirements than considered initially, such as Open Banking,
eHealth, eGovernment, and Electronic Signatures. Those use cases
call for stricter guidelines and additional protection.</t>
<t>OAuth is being used in much more dynamic setups than originally
anticipated, creating new challenges with respect to security.
Those challenges go beyond the original scope of <xref target="RFC6749"></xref>,
<xref target="RFC6750"></xref>, and <xref target="RFC6819"></xref>.</t>
</list>
</t>
<t>OAuth initially assumed a static relationship between client,
authorization server and resource servers. The URLs of AS and RS were
known to the client at deployment time and built an anchor for the
trust relationship among those parties. The validation whether the
client talks to a legitimate server was based on TLS server
authentication (see <xref target="RFC6819"></xref>, Section 4.5.4). With the increasing
adoption of OAuth, this simple model dissolved and, in several
scenarios, was replaced by a dynamic establishment of the relationship
between clients on one side and the authorization and resource servers
of a particular deployment on the other side. This way the same client
could be used to access services of different providers (in case of
standard APIs, such as e-mail or OpenID Connect) or serves as a
frontend to a particular tenant in a multi-tenancy. Extensions of
OAuth, such as <xref target="RFC7591"></xref> and <xref target="RFC8414"></xref> were developed in order to
support the usage of OAuth in dynamic scenarios. As a challenge to the
community, such usage scenarios open up new attack angles,
which are discussed in this document.</t>

<section anchor="structure" title="Structure">
<t>The remainder of the document is organized as follows: The next
section updates the OAuth attacker model. Afterwards, the most important
recommendations of the OAuth working group for every OAuth implementor
are summarized. Subsequently, a detailed analysis of the threats and
implementation issues which can be found in the wild today is given
along with a discussion of potential countermeasures.</t>
</section>

<section anchor="conventions-and-terminology" title="Conventions and Terminology">
<t>The key words &quot;MUST&quot;, &quot;MUST NOT&quot;, &quot;REQUIRED&quot;, &quot;SHALL&quot;, &quot;SHALL
NOT&quot;, &quot;SHOULD&quot;, &quot;SHOULD NOT&quot;, &quot;RECOMMENDED&quot;, &quot;NOT RECOMMENDED&quot;,
&quot;MAY&quot;, and &quot;OPTIONAL&quot; in this document are to be interpreted as
described in BCP 14 <xref target="RFC2119"></xref> <xref target="RFC8174"></xref> when, and only when, they
appear in all capitals, as shown here.</t>
</section>
</section>

<section anchor="the-updated-oauth-2-0-attacker-model" title="The Updated OAuth 2.0 Attacker Model">
<t>In <xref target="RFC6819"></xref>, an attacker model was laid out that described the
capabilities of attackers against which OAuth deployments must defend.
In the following, this attacker model is updated to account for the
potentially dynamic relationships involving multiple parties (as
described above), to include new types of attackers, and to define the
attacker model more clearly.</t>
<t>OAuth 2.0 MUST ensure that the authorization of the resource owner
(RO) (with a user agent) at an authorization server (AS) and the
subsequent usage of the access token at the resource server (RS) is
protected at least against the following attackers:</t>
<t>
<list style="symbols">
<t>(A1) Web Attackers that control an arbitrary number of network
endpoints (except for the concrete RO, AS, and RS). Web attackers
may set up web sites that are visited by the RO, operate their own
user agents, participate in the protocol using their own user
credentials, etc.<vspace />
Web attackers may, in particular, operate OAuth clients that are
registered at AS, and operate their own authorization and resource
servers that can be used (in parallel) by ROs.<vspace />
It must also be assumed that web attackers can lure the user to
open arbitrary attacker-chosen URIs at any time. This can be
achieved through many ways, for example, by injecting malicious
advertisements into advertisement networks, or by sending
legit-looking emails.</t>
<t>(A2) Network Attackers that additionally have full control over
the network over which protocol participants communicate. They can
eavesdrop on, manipulate, and spoof messages, except when these
are properly protected by cryptographic methods (e.g., TLS).
Network attackers can also block arbitrary messages.</t>
</list>
</t>
<t>These attackers conform to the attacker model that was used in formal
analysis efforts for OAuth <xref target="arXiv.1601.01229"></xref>. Previous attacks on
OAuth have shown that OAuth deployments SHOULD protect against an
even stronger attacker model that is described as follows:</t>
<t>
<list style="symbols">
<t>(A3) Attackers that can read, but not modify, the contents of the
authorization response (i.e., the authorization response can leak
to an attacker).<vspace />
Examples for such attacks include open redirector
attacks, problems existing on mobile operating systems (where
different apps can register themselves on the same URI), so-called
mix-up attacks, where the client is tricked into sending
credentials to a attacker-controlled AS, and the fact that URLs
are often stored/logged by browsers (history), proxy servers, and
operating systems.</t>
<t>(A4) Attackers that can read, but not modify, the contents of the
authorization request (i.e., the authorization request can leak,
in the same manner as above, to an attacker).</t>
<t>(A5) Attackers that control a resource server used by RO with
an access token issued by AS. For example, a resource server can
be compromised by an attacker, an access token may be sent to an
attacker-controlled resource server due to a misconfiguration, or
an RO is social-engineered into using a attacker-controlled RS.</t>
</list>
</t>
<t>Note that in this attacker model, an attacker (see A1) can be a RO or
act as one. For example, an attacker can use his own browser to replay
tokens or authorization codes obtained by any of the attacks described
above at the client or RS.</t>
<t>This document discusses the additional threats resulting from these
attackers in detail and recommends suitable mitigations. Attacks in an
even stronger attacker model are discussed, for example, in
<xref target="arXiv.1901.11520"></xref>.</t>
<t>This is a minimal attacker model. Implementers MUST take into account
all possible attackers in the environment in which their OAuth
implementations are expected to run.</t>
</section>

<section anchor="recommendations" title="Recommendations">
<t>This section describes the set of security mechanisms the OAuth
working group recommends to OAuth implementers.</t>

<section anchor="rec_redirect" title="Protecting Redirect-Based Flows">
<t>Authorization servers MUST utilize exact matching of client redirect
URIs against pre-registered URIs. This measure contributes to the
prevention of leakage of authorization codes and access tokens
(depending on the grant type). It also helps to detect mix-up attacks.</t>
<t>Clients SHOULD avoid forwarding the user’s browser to a URI obtained
from a query parameter since such a function could be utilized to
exfiltrate authorization codes and access tokens. If there is a strong
need for this kind of redirects, clients are advised to implement
appropriate countermeasures against open redirection, e.g., as
described by OWASP <xref target="owasp"></xref>.</t>
<t>Clients MUST prevent CSRF. One-time use CSRF tokens carried in the
<spanx style="verb">state</spanx> parameter, which are securely bound to the user agent, SHOULD
be used for that purpose. If PKCE <xref target="RFC7636"></xref> is used by the client and
the authorization server supports PKCE, clients MAY opt to not use
<spanx style="verb">state</spanx> for CSRF protection, as such protection is provided by PKCE.
In this case, <spanx style="verb">state</spanx> MAY be used again for its original purpose,
namely transporting data about the application state of the client
(see <xref target="csrf_countermeasures"></xref>).</t>
<t>In order to prevent mix-up attacks, clients MUST only process redirect
responses of the OAuth authorization server they sent the respective
request to and from the same user agent this authorization request was
initiated with. Clients MUST memorize which authorization server they
sent an authorization request to and bind this information to the user
agent and ensure any sub-sequent messages are sent to the same
authorization server. Clients SHOULD use AS-specific redirect URIs as
a means to identify the AS a particular response came from.</t>
<t>Note: <xref target="I-D.bradley-oauth-jwt-encoded-state"></xref> gives advice on how to
implement CSRF prevention and AS matching using signed JWTs in the
<spanx style="verb">state</spanx> parameter.</t>
<t>AS which redirect a request that potentially contains user credentials
MUST avoid forwarding these user credentials accidentally (see
<xref target="redirect_307"></xref>).</t>

<section anchor="ac" title="Authorization Code Grant">
<t>Clients utilizing the authorization grant type MUST use PKCE
<xref target="RFC7636"></xref> in order to (with the help of the authorization server)
detect and prevent attempts to inject (replay) authorization codes
into the authorization response. The PKCE challenges must be
transaction-specific and securely bound to the user agent in which the
transaction was started and the respective client. OpenID Connect
clients MAY use the <spanx style="verb">nonce</spanx> parameter of the OpenID Connect
authentication request as specified in <xref target="OpenID"></xref> in conjunction with
the corresponding ID Token claim for the same purpose.</t>
<t>Note: although PKCE so far was recommended as a mechanism to protect
native apps, this advice applies to all kinds of OAuth clients,
including web applications.</t>
<t>Clients SHOULD use PKCE code challenge methods that do not expose the
PKCE verifier in the authorization request. (Otherwise, the attacker
A4 can trivially break the security provided by PKCE.) Currently,
<spanx style="verb">S256</spanx> is the only such method.</t>
<t>AS MUST support PKCE [!@RFC7636].</t>
<t>AS SHOULD provide a way to detect their support for PKCE. To this end,
they SHOULD either (a) publish, in their AS metadata ([!@RFC8418]), the
element <spanx style="verb">code_challenge_methods_supported</spanx> containing the supported
PKCE challenge methods (which can be used by the client to detect PKCE
support) or (b) provide a deployment-specific way to ensure or determine PKCE
support by the AS.</t>
<t>Authorization servers SHOULD furthermore consider the recommendations
given in <xref target="RFC6819"></xref>, Section 4.4.1.1, on authorization code replay
prevention.</t>
</section>

<section anchor="implicit-grant" title="Implicit Grant">
<t>The implicit grant (response type &quot;token&quot;) and other response types
causing the authorization server to issue access tokens in the
authorization response are vulnerable to access token leakage and
access token replay as described in <xref target="insufficient_uri_validation"></xref>,
<xref target="credential_leakage_referrer"></xref>, <xref target="browser_history"></xref>, and
<xref target="access_token_injection"></xref>.</t>
<t>Moreover, no viable mechanism exists to cryptographically bind access
tokens issued in the authorization response to a certain client as it
is recommended in <xref target="token_replay_prevention"></xref>. This makes replay
detection for such access tokens at resource servers impossible.</t>
<t>In order to avoid these issues, clients SHOULD NOT use the implicit
grant (response type &quot;token&quot;) or any other response type issuing
access tokens in the authorization response, such as &quot;token id_token&quot;
and &quot;code token id_token&quot;, unless the issued access tokens are
sender-constrained and access token injection in the authorization
response is prevented.</t>
<t>A sender-constrained access token scopes the applicability of an access
token to a certain sender. This sender is obliged to demonstrate knowledge
of a certain secret as prerequisite for the acceptance of that token at
the recipient (e.g., a resource server).</t>
<t>Clients SHOULD instead use the response type &quot;code&quot; (aka authorization code
grant type) as specified in <xref target="ac"></xref> or any other response type that
causes the authorization server to issue access tokens in the token response.
This allows the authorization server to detect replay attempts and
generally reduces the attack surface since access tokens are not exposed in URLs. It also allows the authorization server to sender-constrain the issued tokens.</t>
</section>
</section>

<section anchor="token_replay_prevention" title="Token Replay Prevention">
<t>Authorization servers SHOULD use TLS-based methods for
sender-constrained access tokens as described in <xref target="pop_tokens"></xref>, such
as token binding <xref target="I-D.ietf-oauth-token-binding"></xref> or Mutual TLS for
OAuth 2.0 <xref target="I-D.ietf-oauth-mtls"></xref> in order to prevent token replay.
Refresh tokens MUST be sender-constrained or use refresh token
rotation as described in <xref target="refresh_token_protection"></xref>.</t>
<t>It is recommended to use end-to-end TLS whenever possible. If TLS
traffic needs to be terminated at an intermediary, refer to
<xref target="tls_terminating"></xref> for further security advice.</t>
</section>

<section anchor="access-token-privilege-restriction" title="Access Token Privilege Restriction">
<t>The privileges associated with an access token SHOULD be restricted to the
minimum required for the particular application or use case. This prevents
clients from exceeding the privileges authorized by the resource owner. It also
prevents users from exceeding their privileges authorized by the respective
security policy. Privilege restrictions also limit the impact of token leakage
although more effective counter-measures are described in
<xref target="token_replay_prevention"></xref>.</t>
<t>In particular, access tokens SHOULD be restricted to certain resource
servers, preferably to a single resource server. To put this into
effect, the authorization server associates the access token with
certain resource servers and every resource server is obliged to
verify for every request, whether the access token sent with that
request was meant to be used for that particular resource server. If
not, the resource server MUST refuse to serve the respective request.
Clients and authorization servers MAY utilize the parameters <spanx style="verb">scope</spanx>
or <spanx style="verb">resource</spanx> as specified in <xref target="RFC6749"></xref> and
<xref target="I-D.ietf-oauth-resource-indicators"></xref>, respectively, to determine the
resource server they want to access.</t>
<t>Additionally, access tokens SHOULD be restricted to certain resources
and actions on resource servers or resources. To put this into effect,
the authorization server associates the access token with the
respective resource and actions and every resource server is obliged
to verify for every request, whether the access token sent with that
request was meant to be used for that particular action on the
particular resource. If not, the resource server must refuse to serve
the respective request. Clients and authorization servers MAY utilize
the parameter <spanx style="verb">scope</spanx> as specified in <xref target="RFC6749"></xref> to determine those
resources and/or actions.</t>
</section>

<section anchor="resource-owner-password-credentials-grant" title="Resource Owner Password Credentials Grant">
<t>The resource owner password credentials grant MUST NOT be used. This
grant type insecurely exposes the credentials of the resource owner to
the client. Even if the client is benign, this results in an increased
attack surface (credentials can leak in more places than just the AS)
and users are trained to enter their credentials in places other than
the AS.</t>
<t>Furthermore, adapting the resource owner password credentials grant to
two-factor authentication, authentication with cryptographic
credentials, and authentication processes that require multiple steps
can be hard or impossible (WebCrypto, WebAuthn).</t>
</section>

<section anchor="client-authentication" title="Client Authentication">
<t>Authorization servers SHOULD use client authentication if possible.</t>
<t>It is RECOMMENDED to use asymmetric (public key based) methods for
client authentication such as MTLS [I-D.draft-ietf-oauth-mtls] or
<spanx style="verb">private_key_jwt</spanx> [OIDC]. When asymmetric methods for client
authentication are used, authorization servers do not need to store
sensitive symmetric keys, making these methods more robust against a
number of attacks. Additionally, these methods enable non-repudation
and work well with sender-constrained access tokens (without requiring
additional keys to be distributed).</t>
</section>

<section anchor="other-recommendations" title="Other Recommendations">
<t>Authorization servers SHOULD NOT allow clients to influence their
<spanx style="verb">client_id</spanx> or <spanx style="verb">sub</spanx> value or any other claim that might cause
confusion with a genuine resource owner (see <xref target="client_impersonating"></xref>).</t>
</section>
</section>

<section anchor="attacks-and-mitigations" title="Attacks and Mitigations">
<t>This section gives a detailed description of attacks on OAuth
implementations, along with potential countermeasures. This section
complements and enhances the description given in <xref target="RFC6819"></xref>.</t>

<section anchor="insufficient_uri_validation" title="Insufficient Redirect URI Validation">
<t>Some authorization servers allow clients to register redirect URI
patterns instead of complete redirect URIs. In those cases, the
authorization server, at runtime, matches the actual redirect URI
parameter value at the authorization endpoint against this pattern.
This approach allows clients to encode transaction state into
additional redirect URI parameters or to register just a single
pattern for multiple redirect URIs. As a downside, it turned out to be
more complex to implement and error prone to manage than exact
redirect URI matching. Several successful attacks, utilizing flaws in
the pattern matching implementation or concrete configurations, have
been observed in the wild. Insufficient validation of the redirect URI
effectively breaks client identification or authentication (depending
on grant and client type) and allows the attacker to obtain an
authorization code or access token, either</t>
<t>
<list style="symbols">
<t>by directly sending the user agent to a URI under the attackers
control, or</t>
<t>by exposing the OAuth credentials to an attacker by utilizing an
open redirector at the client in conjunction with the way user
agents handle URL fragments.</t>
</list>
</t>

<section anchor="insufficient_uri_validation_acg" title="Redirect URI Validation Attacks on Authorization Code Grant">
<t>For a public client using the grant type code, an attack would look as
follows:</t>
<t>Let's assume the redirect URL pattern <spanx style="verb">https://*.somesite.example/*</spanx>
had been registered for the client &quot;s6BhdRkqt3&quot;. This pattern allows
redirect URIs pointing to any host residing in the domain
somesite.example. So if an attacker manages to establish a host or
subdomain in somesite.example he can impersonate the legitimate
client. Assume the attacker sets up the host <spanx style="verb">evil.somesite.example</spanx>.</t>
<t>The attack can then be conducted as follows:</t>
<t>First, the attacker needs to trick the user into opening a tampered
URL in his browser, which launches a page under the attacker's
control, say <spanx style="verb">https://www.evil.example</spanx>. (See Attacker A1.)</t>
<t>This URL initiates an authorization request with the client id of a
legitimate client to the authorization endpoint. This is the example
authorization request (line breaks are for display purposes only):</t>

<figure><artwork>GET /authorize?response_type=code&amp;client_id=s6BhdRkqt3&amp;state=9ad67f13
     &amp;redirect_uri=https%3A%2F%2Fevil.somesite.example%2Fcb HTTP/1.1
Host: server.somesite.example
</artwork></figure>

<t>Afterwards, the authorization server validates the redirect URI in
order to identify the client. Since the pattern allows arbitrary
host names in &quot;somesite.example&quot;, the authorization request is
processed under the legitimate client's identity. This includes the
way the request for user consent is presented to the user. If
auto-approval is allowed (which is not recommended for public clients
according to <xref target="RFC6749"></xref>), the attack can be performed even easier.</t>
<t>If the user does not recognize the attack, the code is issued and
immediately sent to the attacker's client.</t>
<t>Since the attacker impersonated a public client, it can
exchange the code for tokens at the respective token endpoint.</t>
<t>Note: This attack will not work as easily for confidential clients,
since the code exchange requires authentication with the legitimate
client's secret. The attacker will need to impersonate or utilize the
legitimate client to redeem the code (e.g., by performing a code
injection attack). This kind of injections is covered in
<xref target="code_injection"></xref>.</t>
</section>

<section anchor="redirect-uri-validation-attacks-on-implicit-grant" title="Redirect URI Validation Attacks on Implicit Grant">
<t>The attack described above works for the implicit grant as well. If
the attacker is able to send the authorization response to a URI under
his control, he will directly get access to the fragment carrying the
access token.</t>
<t>Additionally, implicit clients can be subject to a further kind of
attack. It utilizes the fact that user agents re-attach fragments to
the destination URL of a redirect if the location header does not
contain a fragment (see <xref target="RFC7231"></xref>, Section 9.5). The attack
described here combines this behavior with the client as an open
redirector in order to get access to access tokens. This allows
circumvention even of very narrow redirect URI patterns (but not strict URL
matching!).</t>
<t>Assume the pattern for client &quot;s6BhdRkqt3&quot; is
<spanx style="verb">https://client.somesite.example/cb?*</spanx>, i.e., any parameter is allowed
for redirects to <spanx style="verb">https://client.somesite.example/cb</spanx>. Unfortunately,
the client exposes an open redirector. This endpoint supports a
parameter <spanx style="verb">redirect_to</spanx> which takes a target URL and will send the
browser to this URL using an HTTP Location header redirect 303.</t>
<t>The attack can now be conducted as follows:</t>
<t>First, and as above, the attacker needs to trick the user into opening
a tampered URL in his browser, which launches a page under the
attacker's control, say <spanx style="verb">https://www.evil.example</spanx>.</t>
<t>Afterwards, the website initiates an authorization request, which is
very similar to the one in the attack on the code flow. Different to
above, it utilizes the open redirector by encoding
<spanx style="verb">redirect_to=https://client.evil.example</spanx> into the redirect URI and it
uses the response type &quot;token&quot; (line breaks are for display purposes
only):</t>

<figure><artwork>GET /authorize?response_type=token&amp;state=9ad67f13
    &amp;client_id=s6BhdRkqt3
    &amp;redirect_uri=https%3A%2F%2Fclient.somesite.example
     %2Fcb%26redirect_to%253Dhttps%253A%252F
     %252Fclient.evil.example%252Fcb HTTP/1.1
Host: server.somesite.example
</artwork></figure>

<t>Now, since the redirect URI matches the registered pattern, the
authorization server allows the request and sends the resulting access
token with a 303 redirect (some response parameters are omitted for
better readability)</t>

<figure><artwork>HTTP/1.1 303 See Other
Location: https://client.somesite.example/cb?
          redirect_to%3Dhttps%3A%2F%2Fclient.evil.example%2Fcb
          #access_token=2YotnFZFEjr1zCsicMWpAA&amp;...
</artwork></figure>

<t>At example.com, the request arrives at the open redirector. It will
read the redirect parameter and will issue an HTTP 303 Location header
redirect to the URL <spanx style="verb">https://client.evil.example/cb</spanx>.</t>

<figure><artwork>HTTP/1.1 303 See Other
Location: https://client.evil.example/cb
</artwork></figure>

<t>Since the redirector at client.somesite.example does not include a
fragment in the Location header, the user agent will re-attach the
original fragment <spanx style="verb">#access_token=2YotnFZFEjr1zCsicMWpAA&amp;amp;...</spanx> to
the URL and will navigate to the following URL:</t>

<figure><artwork>https://client.evil.example/cb#access_token=2YotnFZFEjr1z...
</artwork></figure>

<t>The attacker's page at <spanx style="verb">client.evil.example</spanx> can now access the
fragment and obtain the access token.</t>
</section>

<section anchor="proposed-countermeasures" title="Proposed Countermeasures">
<t>The complexity of implementing and managing pattern matching correctly
obviously causes security issues. This document therefore proposes to
simplify the required logic and configuration by using exact redirect
URI matching only. This means the authorization server must compare
the two URIs using simple string comparison as defined in <xref target="RFC3986"></xref>,
Section 6.2.1.</t>
<t>Additional recommendations:</t>
<t>
<list style="symbols">
<t>Servers on which callbacks are hosted must not expose open
redirectors (see <xref target="open_redirection"></xref>).</t>
<t>Clients MAY drop fragments via intermediary URLs with &quot;fix
fragments&quot; (see <xref target="fb_fragments"></xref>) to prevent the user agent from
appending any unintended fragments.</t>
<t>Clients SHOULD use the authorization code response type instead of
response types causing access token issuance at the authorization
endpoint. This offers countermeasures against reuse of leaked
credentials through the exchange process with the authorization
server and token replay through certificate binding of the access
tokens.</t>
</list>
</t>
<t>As an alternative to exact redirect URI matching, the AS could also
authenticate clients, e.g., using <xref target="I-D.ietf-oauth-jwsreq"></xref>.</t>
</section>
</section>

<section anchor="credential_leakage_referrer" title="Credential Leakage via Referrer Headers">
<t>Authorization codes or values of <spanx style="verb">state</spanx> can unintentionally be
disclosed to attackers through the referrer header, by leaking either
from a client's web site or from an AS's web site. Note: even if
specified otherwise in <xref target="RFC7231"></xref>, Section 5.5.2, the same may happen
to access tokens conveyed in URI fragments due to browser
implementation issues as illustrated by Chromium Issue 168213
<xref target="bug.chromium"></xref>.</t>

<section anchor="leakage-from-the-oauth-client" title="Leakage from the OAuth Client">
<t>Leakage from the OAuth client requires that the client, as a result of a successful
authorization request, renders a page that</t>
<t>
<list style="symbols">
<t>contains links to other pages under the attacker's control (ads,
faq, ...) and a user clicks on such a link, or</t>
<t>includes third-party content (iframes, images, etc.), for example
if the page contains user-generated content (blog).</t>
</list>
</t>
<t>As soon as the browser navigates to the attacker's page or loads the
third-party content, the attacker receives the authorization response
URL and can extract <spanx style="verb">code</spanx>, <spanx style="verb">access token</spanx>, or <spanx style="verb">state</spanx>.</t>
</section>

<section anchor="leakage-from-the-authorization-server" title="Leakage from the Authorization Server">
<t>In a similar way, an attacker can learn <spanx style="verb">state</spanx> if the authorization
endpoint at the authorization server contains links or third-party
content as above.</t>
</section>

<section anchor="consequences" title="Consequences">
<t>An attacker that learns a valid code or access token through a
referrer header can perform the attacks as described in
<xref target="insufficient_uri_validation_acg"></xref>, <xref target="code_injection"></xref>, and
<xref target="access_token_injection"></xref>. If the attacker learns <spanx style="verb">state</spanx>, the CSRF
protection achieved by using <spanx style="verb">state</spanx> is lost, resulting in CSRF
attacks as described in <xref target="RFC6819"></xref>, Section 4.4.1.8.</t>
</section>

<section anchor="proposed-countermeasures-1" title="Proposed Countermeasures">
<t>The page rendered as a result of the OAuth authorization response and
the authorization endpoint SHOULD NOT include third-party resources or
links to external sites.</t>
<t>The following measures further reduce the chances of a successful attack:</t>
<t>
<list style="symbols">
<t>Bind authorization code to a confidential client or PKCE
challenge. In this case, the attacker lacks the secret to request
the code exchange.</t>
<t>As described in <xref target="RFC6749"></xref>, Section 4.1.2, authorization codes
MUST be invalidated by the AS after their first use at the token
endpoint. For example, if an AS invalidated the code after the
legitimate client redeemed it, the attacker would fail exchanging
this code later.<vspace />
This does not mitigate the attack if the attacker manages to
exchange the code for a token before the legitimate client does
so. Therefore, <xref target="RFC6749"></xref> further recommends that, when an
attempt is made to redeem a code twice, the AS SHOULD revoke all
tokens issued previously based on that code.</t>
<t>The <spanx style="verb">state</spanx> value SHOULD be invalidated by the client after its
first use at the redirection endpoint. If this is implemented, and
an attacker receives a token through the referrer header from the
client's web site, the <spanx style="verb">state</spanx> was already used, invalidated by
the client and cannot be used again by the attacker. (This does
not help if the <spanx style="verb">state</spanx> leaks from the
AS's web site, since then the <spanx style="verb">state</spanx>
has not been used at the redirection endpoint at the client yet.)</t>
<t>Suppress the referrer header by adding the attribute
<spanx style="verb">rel=&quot;noreferrer&quot;</spanx> to HTML links or by applying an appropriate
Referrer Policy <xref target="webappsec-referrer-policy"></xref> to the document
(either as part of the &quot;referrer&quot; meta attribute or by setting a
Referrer-Policy header).</t>
<t>Use authorization code instead of response types causing access
token issuance from the authorization endpoint. This provides
countermeasures against leakage on the OAuth protocol level
through the code exchange process with the authorization server.</t>
<t>Additionally, one might use the form post response mode instead of
redirect for authorization response (see
<xref target="oauth-v2-form-post-response-mode"></xref>).</t>
</list>
</t>
</section>
</section>

<section anchor="browser_history" title="Attacks through the Browser History">
<t>Authorization codes and access tokens can end up in the browser's
history of visited URLs, enabling the attacks described in the
following.</t>

<section anchor="code-in-browser-history" title="Code in Browser History">
<t>When a browser navigates to
<spanx style="verb">client.example/redirection_endpoint?code=abcd</spanx> as a result of a
redirect from a provider's authorization endpoint, the URL including
the authorization code may end up in the browser's history. An
attacker with access to the device could obtain the code and try to
replay it.</t>
<t>Proposed countermeasures:</t>
<t>
<list style="symbols">
<t>Authorization code replay prevention as described in <xref target="RFC6819"></xref>,
Section 4.4.1.1, and <xref target="code_injection"></xref></t>
<t>Use form post response mode instead of redirect for authorization
response (see <xref target="oauth-v2-form-post-response-mode"></xref>)</t>
</list>
</t>
</section>

<section anchor="access-token-in-browser-history" title="Access Token in Browser History">
<t>An access token may end up in the browser history if a client or
just a web site, which already has a token, deliberately navigates to
a page like &quot;provider.com/get<spanx style="emph">user</spanx>profile?access_token=abcdef.&quot;.
Actually <xref target="RFC6750"></xref> discourages this practice and asks to transfer
tokens via a header, but in practice web sites often just pass access
token in query parameters.</t>
<t>In case of implicit grant, a URL like
<spanx style="verb">client.example/redirection_endpoint#access_token=abcdef</spanx> may also end
up in the browser history as a result of a redirect from a provider's
authorization endpoint.</t>
<t>Proposed countermeasures:</t>
<t>
<list style="symbols">
<t>Replace implicit flow with postmessage communication or the
authorization code grant</t>
<t>Never pass access tokens in URL query parameters</t>
</list>
</t>
</section>
</section>

<section anchor="mix-up" title="Mix-Up">
<t>Mix-up is an attack on scenarios where an OAuth client interacts with
multiple authorization servers, as is usually the case when dynamic
registration is used. The goal of the attack is to obtain an
authorization code or an access token by tricking the client into
sending those credentials to the attacker instead of using them at the
respective endpoint at the authorization/resource server.</t>

<section anchor="attack-description" title="Attack Description">
<t>For a detailed attack description, refer to <xref target="arXiv.1601.01229"></xref> and
<xref target="I-D.ietf-oauth-mix-up-mitigation"></xref>. The description here closely
follows <xref target="arXiv.1601.01229"></xref>, with variants of the attack outlined
below.</t>
<t>Preconditions: For the attack to work, we assume that</t>
<t>
<list style="symbols">
<t>the implicit or authorization code grant are used with multiple AS
of which one is considered &quot;honest&quot; (H-AS) and one is operated by
the attacker (A-AS),</t>
<t>the client stores the AS chosen by the user in a session bound to
the user's browser and uses the same redirection endpoint URI for
each AS, and</t>
<t>the attacker can manipulate the first request/response pair from a
user's browser to the client (in which the user selects a certain
AS and is then redirected by the client to that AS), as in Attacker A2.</t>
</list>
</t>
<t>Some of the attack variants described below require different
preconditions.</t>
<t>In the following, we assume that the client is registered with H-AS
(URI: <spanx style="verb">https://honest.as.example</spanx>, client id: <spanx style="verb">7ZGZldHQ</spanx>) and with
A-AS (URI: <spanx style="verb">https://attacker.example</spanx>, client id: <spanx style="verb">666RVZJTA</spanx>).</t>
<t>Attack on the authorization code grant:</t>
<t>
<list style="numbers">
<t>The user selects to start the grant using H-AS (e.g., by clicking on a button at the
client's website).</t>
<t>The attacker intercepts this request and changes the user's
selection to &quot;A-AS&quot;.</t>
<t>The client stores in the user's session that the user selected
&quot;A-AS&quot; and redirects the user to A-AS's authorization endpoint by
sending the response code <spanx style="verb">303 See Other</spanx> with a Location header
containing the URL
<spanx style="verb">https://attacker.example/authorize?response_type=code&amp;client_id=666RVZJTA</spanx>.</t>
<t>Now the attacker intercepts this response and changes the
redirection such that the user is being redirected to H-AS. The
attacker also replaces the client id of the client at A-AS with
the client's id at H-AS. Therefore, the browser receives a
redirection (<spanx style="verb">303 See Other</spanx>) with a Location header pointing to
<spanx style="verb">https://honest.as.example/authorize?response_type=code&amp;client_id=7ZGZldHQ</spanx></t>
<t>Now, the user authorizes the client to access her resources at
H-AS. H-AS issues a code and sends it (via the browser) back to
the client.</t>
<t>Since the client still assumes that the code was issued by A-AS,
it will try to redeem the code at A-AS's token endpoint.</t>
<t>The attacker therefore obtains code and can either exchange the
code for an access token (for public clients) or perform a code
injection attack as described in <xref target="code_injection"></xref>.</t>
</list>
</t>
<t>Variants:</t>
<t>
<list style="symbols">
<t><spanx style="strong">Implicit Grant</spanx>: In the implicit grant, the attacker receives
an access token instead of the code; the rest of the attack works
as above.</t>
<t><spanx style="strong">Mix-Up Without Interception</spanx>: A variant of the above attack
works even if the first request/response pair cannot be
intercepted (for example, because TLS is used to protect these
messages): Here, we assume that the user wants to start the grant
using A-AS (and not H-AS, see Attacker A1). After the client
redirected the user to the authorization endpoint at A-AS, the
attacker immediately redirects the user to H-AS (changing the
client id to <spanx style="verb">7ZGZldHQ</spanx>). (A vigilant user might at this point
detect that she intended to use A-AS instead of H-AS.) The attack
now proceeds exactly as in Steps 3ff. of the attack description above.</t>
<t><spanx style="strong">Per-AS Redirect URIs</spanx>: If clients use different redirect URIs
for different ASs, do not store the selected AS in the user's
session, and ASs do not check the redirect URIs properly,
attackers can mount an attack called &quot;Cross-Social Network Request
Forgery&quot;. Refer to <xref target="oauth_security_jcs_14"></xref> for details.</t>
<t><spanx style="strong">OpenID Connect</spanx>: There are several variants that can be used to
attack OpenID Connect. They are described in detail in
<xref target="arXiv.1704.08539"></xref>, Appendix A, and <xref target="arXiv.1508.04324v2"></xref>,
Section 6 (&quot;Malicious Endpoints Attacks&quot;).</t>
</list>
</t>
</section>

<section anchor="countermeasures" title="Countermeasures">
<t>In scenarios where an OAuth client interacts with multiple
authorization servers, clients MUST prevent mix-up attacks.</t>
<t>Potential countermeasures:</t>
<t>
<list style="symbols">
<t>Configure authorization servers to return an AS identitifier
(<spanx style="verb">iss</spanx>) and the <spanx style="verb">client_id</spanx> for which a code or token was issued
in the authorization response. This enables clients to compare
this data to their own client id and the <spanx style="verb">iss</spanx> identifier of the
AS it believed it sent the user agent to. This mitigation is
discussed in detail in <xref target="I-D.ietf-oauth-mix-up-mitigation"></xref>. In
OpenID Connect, if an ID token is returned in the authorization
response, it carries client id and issuer. It can be used for this
mitigation.</t>
<t>As it can be seen in the preconditions of the attacks above,
clients can prevent mix-up attack by (1) using AS-specific
redirect URIs with exact redirect URI matching, (2) storing, for
each authorization request, the intended AS, and (3) comparing the
intended AS with the actual redirect URI where the authorization
response was received.</t>
</list>
</t>
</section>
</section>

<section anchor="code_injection" title="Authorization Code Injection">
<t>In such an attack, the adversary attempts to inject a stolen
authorization code into a legitimate client on a device under his
control. In the simplest case, the attacker would want to use the code
in his own client. But there are situations where this might not be
possible or intended. Examples are:</t>
<t>
<list style="symbols">
<t>The attacker wants to access certain functions in this particular
client. As an example, the attacker wants to impersonate his
victim in a certain app or on a certain web site.</t>
<t>The code is bound to a particular confidential client and the
attacker is unable to obtain the required client credentials to
redeem the code himself.</t>
<t>The authorization or resource servers are limited to certain
networks that the attacker is unable to access directly.</t>
</list>
</t>
<t>In the following attack description and discussion, we assume the
presence of a web or network attacker, but not of an attacker with
advanced capabilities (A3-A5).</t>

<section anchor="attack-description-1" title="Attack Description">
<t>The attack works as follows:</t>
<t>
<list style="numbers">
<t>The attacker obtains an authorization code by performing any of
the attacks described above.</t>
<t>He performs a regular OAuth authorization process with the
legitimate client on his device.</t>
<t>The attacker injects the stolen authorization code in the response
of the authorization server to the legitimate client.</t>
<t>The client sends the code to the authorization server's token
endpoint, along with client id, client secret and actual
<spanx style="verb">redirect_uri</spanx>.</t>
<t>The authorization server checks the client secret, whether the
code was issued to the particular client and whether the actual
redirect URI matches the <spanx style="verb">redirect_uri</spanx> parameter (see
<xref target="RFC6749"></xref>).</t>
<t>If all checks succeed, the authorization server issues access and
other tokens to the client, so now the attacker is able to
impersonate the legitimate user.</t>
</list>
</t>
</section>

<section anchor="discussion" title="Discussion">
<t>Obviously, the check in step (5.) will fail if the code was issued to
another client id, e.g., a client set up by the attacker. The check
will also fail if the authorization code was already redeemed by the
legitimate user and was one-time use only.</t>
<t>An attempt to inject a code obtained via a manipulated redirect URI
should also be detected if the authorization server stored the
complete redirect URI used in the authorization request and compares
it with the <spanx style="verb">redirect_uri</spanx> parameter.</t>
<t><xref target="RFC6749"></xref>, Section 4.1.3, requires the AS to &quot;... ensure that the
<spanx style="verb">redirect_uri</spanx> parameter is present if the <spanx style="verb">redirect_uri</spanx> parameter
was included in the initial authorization request as described in
Section 4.1.1, and if included ensure that their values are
identical.&quot;. In the attack scenario described above, the legitimate
client would use the correct redirect URI it always uses for
authorization requests. But this URI would not match the tampered
redirect URI used by the attacker (otherwise, the redirect would not
land at the attackers page). So the authorization server would detect
the attack and refuse to exchange the code.</t>
<t>Note: this check could also detect attempts to inject a code which had
been obtained from another instance of the same client on another
device, if certain conditions are fulfilled:</t>
<t>
<list style="symbols">
<t>the redirect URI itself needs to contain a nonce or another kind
of one-time use, secret data and</t>
<t>the client has bound this data to this particular instance.</t>
</list>
</t>
<t>But this approach conflicts with the idea to enforce exact redirect
URI matching at the authorization endpoint. Moreover, it has been
observed that providers very often ignore the <spanx style="verb">redirect_uri</spanx> check
requirement at this stage, maybe because it doesn't seem to be
security-critical from reading the specification.</t>
<t>Other providers just pattern match the <spanx style="verb">redirect_uri</spanx> parameter against
the registered redirect URI pattern. This saves the authorization
server from storing the link between the actual redirect URI and the
respective authorization code for every transaction. But this kind of
check obviously does not fulfill the intent of the spec, since the
tampered redirect URI is not considered. So any attempt to inject a
code obtained using the <spanx style="verb">client_id</spanx> of a legitimate client or by
utilizing the legitimate client on another device won't be detected in
the respective deployments.</t>
<t>It is also assumed that the requirements defined in <xref target="RFC6749"></xref>,
Section 4.1.3, increase client implementation complexity as clients
need to memorize or re-construct the correct redirect URI for the call
to the tokens endpoint.</t>
<t>This document therefore recommends to instead bind every authorization
code to a certain client instance on a certain device (or in a certain
user agent) in the context of a certain transaction.</t>
</section>

<section anchor="proposed-countermeasures-2" title="Proposed Countermeasures">
<t>There are multiple technical solutions to achieve this goal:</t>
<t>
<list style="symbols">
<t><spanx style="strong">Nonce</spanx>: OpenID Connect's existing <spanx style="verb">nonce</spanx> parameter can be used
for the purpose of detecting authorization code injection attacks.
The <spanx style="verb">nonce</spanx> value is one-time use and created by the client. The
client is supposed to bind it to the user agent session and sends
it with the initial request to the OpenId Provider (OP). The OP
binds <spanx style="verb">nonce</spanx> to the authorization code and attests this
binding in the ID token, which is issued as part of the code
exchange at the token endpoint. If an attacker injected an
authorization code in the authorization response, the nonce value
in the client session and the nonce value in the ID token will not
match and the attack is detected. The assumption is that an
attacker cannot get hold of the user agent state on the victim's
device, where he has stolen the respective authorization code. The
main advantage of this option is that <spanx style="verb">nonce</spanx> is an existing feature
used in the wild. On the other hand, leveraging <spanx style="verb">nonce</spanx> by the
broader OAuth community would require AS and clients to adopt ID
Tokens.</t>
<t><spanx style="strong">Code-bound State</spanx>: The <spanx style="verb">state</spanx> parameter as specified in
<xref target="RFC6749"></xref> could be used similarly to what is described above.
This would require to add a further parameter <spanx style="verb">state</spanx> to the code
exchange token endpoint request. The authorization server would
then compare the <spanx style="verb">state</spanx> value it associated with the code and the
<spanx style="verb">state</spanx> value in the parameter. If those values do not match, it
is considered an attack and the request fails. The advantage of
this approach would be to utilize an existing OAuth parameter. But
it would also mean to re-interpret the purpose of <spanx style="verb">state</spanx> and to
extend the token endpoint request.</t>
<t><spanx style="strong">PKCE</spanx>: The PKCE parameter <spanx style="verb">code_challenge</spanx> along with the
corresponding <spanx style="verb">code_verifier</spanx> as specified in <xref target="RFC7636"></xref> could be used
in the same way as <spanx style="verb">nonce</spanx> or <spanx style="verb">state</spanx>. In contrast to its original
intention, the verifier check would fail although the client uses
its correct verifier but the code is associated with a challenge,
which does not match. PKCE is a deployed OAuth feature, even
though it is used today to secure native apps only.</t>
<t><spanx style="strong">Token Binding</spanx>: Token binding <xref target="I-D.ietf-oauth-token-binding"></xref>
could also be used. In this case, the code would need to be bound
to two legs, between user agent and AS and the user agent and the
client. This requires further data (extension to response) to
manifest binding id for particular code. Token binding is
promising as a secure and convenient mechanism (due to its browser
integration). As a challenge, it requires broad browser support
and use with native apps is still under discussion.</t>
<t><spanx style="strong">Per-instance client id/secret</spanx>: One could use per instance
<spanx style="verb">client_id</spanx> and secrets and bind the code to the respective
<spanx style="verb">client_id</spanx>. Unfortunately, this does not fit into the web
application programming model (would need to use per-user client
IDs).</t>
</list>
</t>
<t>PKCE seems to be the most obvious solution for OAuth clients as it is
available and effectively used today for similar purposes for OAuth
native apps whereas <spanx style="verb">nonce</spanx> is appropriate for OpenId Connect clients.</t>
<t>Note on pre-warmed secrets: An attacker can circumvent the
countermeasures described above if he is able to create or capture the
respective secret or code_challenge on a device under his control,
which is then used in the victim's authorization request.</t>
<t>Exact redirect URI matching of authorization requests can prevent the
attacker from using the pre-warmed secret in the faked authorization
transaction on the victim's device.</t>
<t>Unfortunately, it does not work for all kinds of OAuth clients. It is
effective for web and JS apps and for native apps with claimed URLs.
Attacks on native apps using custom schemes or redirect URIs on
localhost cannot be prevented this way, except if the AS enforces
one-time use for PKCE verifier or <spanx style="verb">nonce</spanx> values.</t>
</section>
</section>

<section anchor="access_token_injection" title="Access Token Injection">
<t>In such an attack, the adversary attempts to inject a stolen access
token into a legitimate client on a device under his control. This
will typically happen if the attacker wants to utilize a leaked access
token to impersonate a user in a certain client.</t>
<t>To conduct the attack, the adversary starts an OAuth flow with the
client and modifies the authorization response by replacing the access
token issued by the authorization server or directly makes up an
authorization server response including the leaked access token. Since
the response includes the state value generated by the client for this
particular transaction, the client does not treat the response as a
CSRF and will use the access token injected by the attacker.</t>

<section anchor="proposed-countermeasures-3" title="Proposed Countermeasures">
<t>There is no way to detect such an injection attack on the OAuth
protocol level, since the token is issued without any binding to the
transaction or the particular user agent.</t>
<t>The recommendation is therefore to use the authorization code grant
type instead of relying on response types issuing acess tokens at the
authorization endpoint. Code injection can be detected using one of
the countermeasures discussed in <xref target="code_injection"></xref>.</t>
</section>
</section>

<section anchor="cross-site-request-forgery" title="Cross Site Request Forgery">
<t>An attacker might attempt to inject a request to the redirect URI of
the legitimate client on the victim's device, e.g., to cause the
client to access resources under the attacker's control.</t>

<section anchor="csrf_countermeasures" title="Proposed Countermeasures">
<t>Use of CSRF tokens which are bound to the user agent and passed in the
<spanx style="verb">state</spanx> parameter to the authorization server as described in [!@RFC6819].
Alternatively, PKCE provides CSRF protection.</t>
<t>It is important to note that:</t>
<t>
<list style="symbols">
<t>Clients MUST ensure that the AS supports PKCE before using PKCE for
CSRF protection. If an authorization server does not support PKCE,
<spanx style="verb">state</spanx> MUST be used for CSRF protection.</t>
<t>If <spanx style="verb">state</spanx> is used for carrying application state, and integrity of
its contents is a concern, clients MUST protect state against
tampering and swapping. This can be achieved by binding the
contents of state to the browser session and/or signed/encrypted
state values <xref target="I-D.bradley-oauth-jwt-encoded-state"></xref>.</t>
</list>
</t>
<t>The recommendation therefore is that AS publish their PKCE support
either in AS metadata according to <xref target="RFC8418"></xref> or provide a
deployment-specific way to ensure or determine PKCE support.</t>
<t>Additionally, standard CSRF defenses MAY be used to protect the
redirection endpoint, for example the Origin header.</t>
<t>For more details see <xref target="owasp_csrf"></xref>.</t>
</section>
</section>

<section anchor="access-token-leakage-at-the-resource-server" title="Access Token Leakage at the Resource Server">
<t>Access tokens can leak from a resource server under certain
circumstances.</t>

<section anchor="access-token-phishing-by-counterfeit-resource-server" title="Access Token Phishing by Counterfeit Resource Server">
<t>An attacker may setup his own resource server and trick a client into
sending access tokens to it that are valid for other resource servers
(see Attackers A1 and A5). If the client sends a valid access token to
this counterfeit resource server, the attacker in turn may use that
token to access other services on behalf of the resource owner.</t>
<t>This attack assumes the client is not bound to one specific resource
server (and its URL) at development time, but client instances are
provided with the resource server URL at runtime. This kind of late
binding is typical in situations where the client uses a service
implementing a standardized API (e.g., for e-Mail, calendar, health,
or banking) and where the client is configured by a user or
administrator for a service which this user or company uses.</t>
<t>There are several potential mitigation strategies, which will be
discussed in the following sections.</t>

<section anchor="metadata" title="Metadata">
<t>An authorization server could provide the client with additional
information about the location where it is safe to use its access
tokens.</t>
<t>In the simplest form, this would require the AS to publish a list of
its known resource servers, illustrated in the following example using
a metadata parameter <spanx style="verb">resource_servers</spanx>:</t>

<figure><artwork>HTTP/1.1 200 OK
Content-Type: application/json

{
  &quot;issuer&quot;:&quot;https://server.somesite.example&quot;,
  &quot;authorization_endpoint&quot;:
    &quot;https://server.somesite.example/authorize&quot;,
  &quot;resource_servers&quot;:[
    &quot;email.somesite.example&quot;,
    &quot;storage.somesite.example&quot;,
    &quot;video.somesite.example&quot;
  ]
  ...
} 
</artwork></figure>

<t>The AS could also return the URL(s) an access token is good for in the
token response, illustrated by the example return parameter
<spanx style="verb">access_token_resource_server</spanx>:</t>

<figure><artwork>HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: no-store
Pragma: no-cache

{
  &quot;access_token&quot;:&quot;2YotnFZFEjr1zCsicMWpAA&quot;,
  &quot;access_token_resource_server&quot;:
    &quot;https://hostedresource.somesite.example/path1&quot;,
...
}
</artwork></figure>

<t>This mitigation strategy would rely on the client to enforce the
security policy and to only send access tokens to legitimate
destinations. Results of OAuth related security research (see for
example <xref target="oauth_security_ubc"></xref> and <xref target="oauth_security_cmu"></xref>) indicate a
large portion of client implementations do not or fail to properly
implement security controls, like <spanx style="verb">state</spanx> checks. So relying on
clients to prevent access token phishing is likely to fail as well.
Moreover given the ratio of clients to authorization and resource
servers, it is considered the more viable approach to move as much as
possible security-related logic to those entities. Clearly, the client
has to contribute to the overall security. But there are alternative
countermeasures, as described in the next sections, which provide a
better balance between the involved parties.</t>
</section>

<section anchor="pop_tokens" title="Sender-Constrained Access Tokens">
<t>As the name suggests, sender-constrained access token scope the
applicability of an access token to a certain sender. This sender is
obliged to demonstrate knowledge of a certain secret as prerequisite
for the acceptance of that token at a resource server.</t>
<t>A typical flow looks like this:</t>
<t>
<list style="numbers">
<t>The authorization server associates data with the access token
which binds this particular token to a certain client. The binding
can utilize the client identity, but in most cases the AS utilizes
key material (or data derived from the key material) known to the
client.</t>
<t>This key material must be distributed somehow. Either the key
material already exists before the AS creates the binding or the
AS creates ephemeral keys. The way pre-existing key material is
distributed varies among the different approaches. For example,
X.509 Certificates can be used in which case the distribution
happens explicitly during the enrollment process. Or the key
material is created and distributed at the TLS layer, in which
case it might automatically happen during the setup of a TLS
connection.</t>
<t>The RS must implement the actual proof of possession check. This
is typically done on the application level, it may utilize
capabilities of the transport layer (e.g., TLS). Note: replay
prevention is required as well!</t>
</list>
</t>
<t>There exist several proposals to demonstrate the proof of possession
 in the scope of the OAuth working group:</t>
<t>
<list style="symbols">
<t><spanx style="strong">OAuth Token Binding</spanx> (<xref target="I-D.ietf-oauth-token-binding"></xref>): In this approach, an access
token is, via the so-called token binding id, bound to key
material representing a long term association between a client and
a certain TLS host. Negotiation of the key material and proof of
possession in the context of a TLS handshake is taken care of by
the TLS stack. The client needs to determine the token binding id
of the target resource server and pass this data to the access
token request. The authorization server then associates the access
token with this id. The resource server checks on every invocation
that the token binding id of the active TLS connection and the
token binding id of associated with the access token match. Since
all crypto-related functions are covered by the TLS stack, this
approach is very client developer friendly. As a prerequisite,
token binding as described in <xref target="RFC8473"></xref>
(including federated token bindings) must be supported on all ends
(client, authorization server, resource server).</t>
<t><spanx style="strong">OAuth Mutual TLS</spanx> (<xref target="I-D.ietf-oauth-mtls"></xref>): The approach as
specified in this document allows the use of mutual TLS (mTLS) for both
client authentication and sender-constrained access tokens. For
the purpose of sender-constrained access tokens, the client is
identified towards the resource server by the fingerprint of its
public key. During processing of an access token request, the
authorization server obtains the client's public key from the TLS
stack and associates its fingerprint with the respective access
tokens. The resource server in the same way obtains the public key
from the TLS stack and compares its fingerprint with the
fingerprint associated with the access token.</t>
<t><spanx style="strong">Signed HTTP Requests</spanx> (<xref target="I-D.ietf-oauth-signed-http-request"></xref>):
This approach utilizes <xref target="I-D.ietf-oauth-pop-key-distribution"></xref> and
represents the elements of the signature in a JSON object. The
signature is built using JWS. The mechanism has built-in support
for signing of HTTP method, query parameters and headers. It also
incorporates a timestamp as basis for replay prevention.</t>
<t><spanx style="strong">JWT Pop Tokens</spanx> (<xref target="I-D.sakimura-oauth-jpop"></xref>): This draft
describes different ways to constrain access token usage, namely
TLS or request signing. Note: Since the authors of this draft
contributed the TLS-related proposal to <xref target="I-D.ietf-oauth-mtls"></xref>,
this document only considers the request signing part. For request
signing, the draft utilizes
<xref target="I-D.ietf-oauth-pop-key-distribution"></xref> and <xref target="RFC7800"></xref>. The
signature data is represented in a JWT and JWS is used for
signing. Replay prevention is provided by building the signature
over a server-provided nonce, client-provided nonce and a nonce
counter.</t>
</list>
</t>
<t>Mutual TLS and OAuth Token Binding are built
on top of TLS and this way continue the successful OAuth 2.0
philosophy to leverage TLS to secure OAuth wherever possible. Both
mechanisms allow prevention of access token leakage in a fairly client
developer friendly way.</t>
<t>There are some differences between both approaches: To start with, for OAuth Token Binding, all key material is automatically
managed by the TLS stack whereas mTLS requires the
developer to create and maintain the key pairs and respective
certificates. Use of self-signed certificates, which is supported by
the draft, significantly reduces the complexity of this task.
Furthermore, OAuth Token Binding allows to use different
key pairs for different resource servers, which is a privacy benefit.
On the other hand, <xref target="I-D.ietf-oauth-mtls"></xref> only requires widely
deployed TLS features, which means it might be easier to adopt in the
short term.</t>
<t>Application level signing approaches, like
<xref target="I-D.ietf-oauth-signed-http-request"></xref> and <xref target="I-D.sakimura-oauth-jpop"></xref>
have been debated for a long time in the OAuth working group without a
clear outcome.</t>
<t>As one advantage, application-level signing allows for end-to-end
protection including non-repudiation even if the TLS connection is
terminated between client and resource server. But deployment
experiences have revealed challenges regarding robustness (e.g.,
reproduction of the signature base string including correct URL) as
well as state management (e.g., replay prevention).</t>
<t>This document therefore recommends implementors to consider one of
TLS-based approaches wherever possible.</t>
</section>

<section anchor="aud_restriction" title="Audience Restricted Access Tokens">
<t>An audience restriction essentially restricts the resource server a
particular access token can be used at. The authorization server
associates the access token with a certain resource server and every
resource server is obliged to verify for every request, whether the
access token sent with that request was meant to be used at the
particular resource server. If not, the resource server must refuse to
serve the respective request. In the general case, audience
restrictions limit the impact of a token leakage. In the case of a
counterfeit resource server, it may (as described below) also
prevent abuse of the phished access token at the legitimate resource
server.</t>
<t>The audience can basically be expressed using logical names or
physical addresses (like URLs). In order to prevent phishing, it is
necessary to use the actual URL the client will send requests to. In
the phishing case, this URL will point to the counterfeit resource
server. If the attacker tries to use the access token at the
legitimate resource server (which has a different URL), the resource
server will detect the mismatch (wrong audience) and refuse to serve
the request.</t>
<t>In deployments where the authorization server knows the URLs of all
resource servers, the authorization server may just refuse to issue
access tokens for unknown resource server URLs.</t>
<t>The client needs to tell the authorization server, at which URL it
will use the access token it is requesting. It could use the mechanism
proposed <xref target="I-D.ietf-oauth-resource-indicators"></xref> or encode the
information in the scope value.</t>
<t>Instead of the URL, it is also possible to utilize the fingerprint of
the resource server's X.509 certificate as audience value. This
variant would also allow to detect an attempt to spoof the legit
resource server's URL by using a valid TLS certificate obtained from a
different CA. It might also be considered a privacy benefit to hide
the resource server URL from the authorization server.</t>
<t>Audience restriction seems easy to use since it does not require any
crypto on the client side. But since every access token is bound to a
certain resource server, the client also needs to obtain different
RS-specific access tokens, if it wants to access several resource
services. <xref target="I-D.ietf-oauth-token-binding"></xref> has the same property,
since different token binding ids must be associated with the access
token. <xref target="I-D.ietf-oauth-mtls"></xref> on the other hand allows a client to
use the access token at multiple resource servers.</t>
<t>It shall be noted that audience restrictions, or generally speaking an
indication by the client to the authorization server where it wants to
use the access token, has additional benefits beyond the scope of
token leakage prevention. It allows the authorization server to create
different access token whose format and content is specifically minted
for the respective server. This has huge functional and privacy
advantages in deployments using structured access tokens.</t>
</section>
</section>

<section anchor="compromised-resource-server" title="Compromised Resource Server">
<t>An attacker may compromise a resource server in order to get access to
its resources and other resources of the respective deployment. Such a
compromise may range from partial access to the system, e.g., its
logfiles, to full control of the respective server.</t>
<t>If the attacker was able to take over full control including shell
access it will be able to circumvent all controls in place and access
resources without access control. It will also get access to access
tokens, which are sent to the compromised system and which potentially
are valid for access to other resource servers as well. Even if the
attacker &quot;only&quot; is able to access logfiles or databases of the server
system, it may get access to valid access tokens.</t>
<t>Preventing server breaches by way of hardening and monitoring server
systems is considered a standard operational procedure and therefore
out of scope of this document. This section will focus on the impact
of such breaches on OAuth-related parts of the ecosystem, which is the
replay of captured access tokens on the compromised resource server
and other resource servers of the respective deployment.</t>
<t>The following measures should be taken into account by implementors in
order to cope with access token replay:</t>
<t>
<list style="symbols">
<t>The resource server must treat access tokens like any other
credentials. It is considered good practice to not log them and
not to store them in plain text.</t>
<t>Sender-constrained access tokens as described in <xref target="pop_tokens"></xref> will
prevent the attacker from replaying the access tokens on other
resource servers. Depending on the severity of the penetration, it
will also prevent replay on the compromised system.</t>
<t>Audience restriction as described in <xref target="aud_restriction"></xref>
may be used to prevent replay of captured access tokens on other resource
servers.</t>
</list>
</t>
</section>
</section>

<section anchor="open_redirection" title="Open Redirection">
<t>The following attacks can occur when an AS or client
has an open redirector, i.e., a URL which causes an HTTP
redirect to an attacker-controlled web site.</t>

<section anchor="authorization-server-as-open-redirector" title="Authorization Server as Open Redirector">
<t>Attackers could try to utilize a user's trust in the authorization
server (and its URL in particular) for performing phishing attacks.</t>
<t><xref target="RFC6749"></xref>, Section 4.1.2.1, already prevents open redirects by
stating the AS MUST NOT automatically redirect the user agent in case
of an invalid combination of client<spanx style="emph">id and redirect</spanx>uri.</t>
<t>However, as described in <xref target="I-D.ietf-oauth-closing-redirectors"></xref>, an
attacker could also utilize a correctly registered redirect URI to
perform phishing attacks. It could for example register a client via
dynamic client registration <xref target="RFC7591"></xref> and intentionally send an
erroneous authorization request, e.g., by using an invalid scope
value, to cause the AS to automatically redirect the user agent to its
phishing site.</t>
<t>The AS MUST take precautions to prevent this threat. Based on its risk
assessment the AS needs to decide whether it can trust the redirect
URI or not and SHOULD only automatically redirect the user agent, if
it trusts the redirect URI. If not, it MAY inform the user that it is
about to redirect her to the another site and rely on the user to
decide or MAY just inform the user about the error.</t>
</section>

<section anchor="clients-as-open-redirector" title="Clients as Open Redirector">
<t>Client MUST NOT expose URLs which could be utilized as open
redirector. Attackers may use an open redirector to produce URLs which
appear to point to the client, which might trick users to trust the
URL and follow it in her browser. Another abuse case is to produce
URLs pointing to the client and utilize them to impersonate a client
with an authorization server.</t>
<t>In order to prevent open redirection, clients should only expose such
a function, if the target URLs are whitelisted or if the origin of a
request can be authenticated.</t>
</section>
</section>

<section anchor="redirect_307" title="307 Redirect">
<t>At the authorization endpoint, a typical protocol flow is that the AS
prompts the user to enter her credentials in a form that is then
submitted (using the HTTP POST method) back to the authorization
server. The AS checks the credentials and, if successful, redirects
the user agent to the client's redirection endpoint.</t>
<t>In <xref target="RFC6749"></xref>, the HTTP status code 302 is used for this purpose, but
&quot;any other method available via the user-agent to accomplish this
redirection is allowed&quot;. However, when the status code 307 is used for
redirection, the user agent will send the form data (user credentials)
via HTTP POST to the client since this status code does not require
the user agent to rewrite the POST request to a GET request (and
thereby dropping the form data in the POST request body). If the
relying party is malicious, it can use the credentials to impersonate
the user at the AS.</t>
<t>In the HTTP standard <xref target="RFC6749"></xref>, only the status code 303
unambigiously enforces rewriting the HTTP POST request to an HTTP GET
request. For all other status codes, including the popular 302, user
agents can opt not to rewrite POST to GET requests and therefore to
reveal the user credentials to the client. (In practice, however, most
user agents will only show this behaviour for 307 redirects.)</t>
<t>AS which redirect a request that potentially contains user credentials
therefore MUST NOT use the HTTP 307 status code for redirection. If an
HTTP redirection (and not, for example, JavaScript) is used for such a
request, AS SHOULD use HTTP status code 303 &quot;See Other&quot;.</t>
</section>

<section anchor="tls_terminating" title="TLS Terminating Reverse Proxies">
<t>A common deployment architecture for HTTP applications is to have the
application server sitting behind a reverse proxy which terminates
the TLS connection and dispatches the incoming requests to the
respective application server nodes.</t>
<t>This section highlights some attack angles of this deployment
architecture which are relevant to OAuth, and gives recommendations
for security controls.</t>
<t>In some situations, the reverse proxy needs to pass security-related
data to the upstream application servers for further processing.
Examples include the IP address of the request originator, token
binding ids, and authenticated TLS client certificates.</t>
<t>If the reverse proxy would pass through any header sent from the
outside, an attacker could try to directly send the faked header
values through the proxy to the application server in order to
circumvent security controls that way. For example, it is standard
practice of reverse proxies to accept <spanx style="verb">forwarded_for</spanx> headers and just
add the origin of the inbound request (making it a list). Depending on
the logic performed in the application server, the attacker could
simply add a whitelisted IP address to the header and render a IP
whitelist useless. A reverse proxy must therefore sanitize any inbound
requests to ensure the authenticity and integrity of all header values
relevant for the security of the application servers.</t>
<t>If an attacker was able to get access to the internal network between
proxy and application server, he could also try to circumvent security
controls in place. It is therefore important to ensure the
authenticity of the communicating entities. Furthermore, the
communication link between reverse proxy and application server must
therefore be protected against eavesdropping, injection, and replay of
messages.</t>
</section>

<section anchor="refresh_token_protection" title="Refresh Token Protection">
<t>Refresh tokens are a convenient and UX-friendly way to obtain new access
tokens after the expiration of older access tokens. Refresh tokens also add
to the security of OAuth since they allow the authorization server to issue
access tokens with a short lifetime and reduced scope thus reducing the
potential impact of access token leakage.</t>
<t>Refresh tokens are an attractive target for attackers since they
represent the overall grant a resource owner delegated to a certain
client. If an attacker is able to exfiltrate and successfully replay a
refresh token, the attacker will be able to mint access tokens and use
them to access resource servers on behalf of the resource owner.</t>
<t><xref target="RFC6749"></xref> already provides a robust baseline protection by requiring</t>
<t>
<list style="symbols">
<t>confidentiality of the refresh tokens in transit and storage,</t>
<t>the transmission of refresh tokens over TLS-protected connections between
authorization server and client,</t>
<t>the authorization server to maintain and check the binding of a refresh token
to a certain client (i.e., <spanx style="verb">client_id</spanx>),</t>
<t>authentication of this client during token refresh, if possible, and</t>
<t>that refresh tokens cannot be generated, modified, or guessed.</t>
</list>
</t>
<t><xref target="RFC6749"></xref> also lays the foundation for further (implementation
specific) security measures, such as refresh token expiration and
revocation as well as refresh token rotation by defining respective
error codes and response behavior.</t>
<t>This draft gives recommendations beyond the scope of <xref target="RFC6749"></xref> and
clarifications.</t>
<t>Authorization servers MUST determine based on their risk assessment
whether to issue refresh tokens to a certain client. If the
authorization server decides not to issue refresh tokens, the client
may refresh access tokens by utilizing other grant types, such as the
authorization code grant type. In such a case, the authorization
server may utilize cookies and persistent grants to optimize the user
experience.</t>
<t>If refresh tokens are issued, those refresh tokens MUST be bound to
the scope and resource servers as consented by the resource owner.
This is to prevent privilege escalation by the legit client and reduce
the impact of refresh token leakage.</t>
<t>Authorization server MUST utilize one of these methods to
detect refresh token replay for public clients:</t>
<t>
<list style="symbols">
<t><spanx style="strong">Sender-constrained refresh tokens:</spanx> the authorization server
cryptographically binds the refresh token to a certain client
instance by utilizing <xref target="I-D.ietf-oauth-token-binding"></xref> or
<xref target="I-D.ietf-oauth-mtls"></xref>.</t>
<t><spanx style="strong">Refresh token rotation:</spanx> the authorization server issues a new
refresh token with every access token refresh response. The
previous refresh token is invalidated but information about the
relationship is retained by the authorization server. If a refresh
token is compromised and subsequently used by both the attacker
and the legitimate client, one of them will present an invalidated
refresh token, which will inform the authorization server of the
breach. The authorization server cannot determine which party
submitted the invalid refresh token, but it can revoke the active
refresh token. This stops the attack at the cost of forcing the
legit client to obtain a fresh authorization grant.<vspace />
Implementation note: refresh tokens belonging to the same grant
may share a common id. If any of those refresh tokens is used at
the authorization server, the authorization server uses this
common id to look up the currently active refresh token and can
revoke it.</t>
</list>
</t>
<t>Authorization servers may revoke refresh tokens automatically in case
of a security event, such as:</t>
<t>
<list style="symbols">
<t>password change</t>
<t>logout at the authorization server</t>
</list>
</t>
<t>Refresh tokens SHOULD expire if the client has been inactive for some
time, i.e., the refresh token has not been used to obtain fresh access
tokens for some time. The expiration time is at the discretion of the
authorization server. It might be a global value or determined based
on the client policy or the grant associated with the refresh token
(and its sensitivity).</t>
</section>

<section anchor="client_impersonating" title="Client Impersonating Resource Owner">
<t>Resource servers may make access control decisions based on the
identity of the resource owner as communicated in the <spanx style="verb">sub</spanx> claim
returned by the authorization server in a token introspection response
<xref target="RFC7662"></xref> or other mechanism. If a client is able to choose its own
<spanx style="verb">client_id</spanx> during registration with the authorization server, then
there is a risk that it can register with the same <spanx style="verb">sub</spanx> value as a
privileged user. A subsequent access token obtained under the client
credentials grant may be mistaken as an access token authorized by the
privileged user if the resource server does not perform additional
checks.</t>

<section anchor="client_impersonating_countermeasures" title="Proposed Countermeasures">
<t>Authorization servers SHOULD NOT allow clients to influence their
<spanx style="verb">client_id</spanx> or <spanx style="verb">sub</spanx> value or any other claim that might cause
confusion with a genuine resource owner. Where this cannot be avoided,
authorization servers MUST provide another means for the resource
server to distinguish between access tokens authorized by a resource
owner from access tokens authorized by the client itself.</t>
</section>
</section>
</section>

<section anchor="Acknowledgements" title="Acknowledgements">
<t>We would like to thank Jim Manico, Phil Hunt, Nat Sakimura, Christian
Mainka, Doug McDorman, Johan Peeters, Joseph Heenan, Brock Allen,
Vittorio Bertocci, David Waite, Nov Matake, Tomek Stojecki, Dominick
Baier, Neil Madden, William Dennis, Dick Hardt, Petteri Stenius,
Annabelle Richard Backman, Aaron Parecki, George Fletscher, Brian
Campbell, Konstantin Lapine, and Tim Würtele for their valuable
feedback.</t>
</section>

<section anchor="IANA" title="IANA Considerations">
<t>This draft includes no request to IANA.</t>
</section>

<section anchor="Security" title="Security Considerations">
<t>All relevant security considerations have been given in the
functional specification.</t>
</section>

</middle>

<back>
<references title="Normative References">
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6749.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3986.xml"?>
<reference anchor="oauth-v2-form-post-response-mode" target="http://openid.net/specs/oauth-v2-form-post-response-mode-1_0.html">
  <front>
    <title>OAuth 2.0 Form Post Response Mode</title>
    <author fullname="Mike Jones" initials="M." surname="Jones">
      <organization>Microsoft</organization>
    </author>
    <author fullname="Brian Campbell" initials="B." surname="Campbell">
      <organization>Ping Identity</organization>
    </author>
    <date year="2015" month="April" day="27"></date>
  </front>
</reference>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7662.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6750.xml"?>
<reference anchor="OpenID" target="http://openid.net/specs/openid-connect-core-1_0.html">
  <front>
    <title>OpenID Connect Core 1.0 incorporating errata set 1</title>
    <author fullname="Nat Sakimura" initials="N." surname="Sakimura">
      <organization>NRI</organization>
    </author>
    <author fullname="John Bradley" initials="J." surname="Bradley">
      <organization>Ping Identity</organization>
    </author>
    <author fullname="Mike Jones" initials="M." surname="Jones">
      <organization>Microsoft</organization>
    </author>
    <author fullname="Breno de Medeiros" initials="B." surname="de Medeiros">
      <organization>Google</organization>
    </author>
    <author fullname="Chuck Mortimore" initials="C." surname="Mortimore">
      <organization>Salesforce</organization>
    </author>
    <date year="2014" month="Nov" day="8"></date>
  </front>
</reference>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7636.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8418.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6819.xml"?>
</references>
<references title="Informative References">
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.ietf-oauth-jwsreq.xml"?>
<reference anchor="bug.chromium" target="https://bugs.chromium.org/p/chromium/issues/detail?id=168213/">
  <front>
    <title>Referer header includes URL fragment when opening link using New Tab</title>
    <author></author>
    <date></date>
  </front>
</reference>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8473.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.sakimura-oauth-jpop.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7800.xml"?>
<reference anchor="owasp" target="https://www.owasp.org/">
  <front>
    <title>Open Web Application Security Project Home Page</title>
    <author></author>
    <date></date>
  </front>
</reference>
<reference anchor="fb_fragments" target="https://developers.facebook.com/blog/post/552/">
  <front>
    <title>Facebook Developer Blog</title>
    <author></author>
    <date></date>
  </front>
</reference>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.ietf-oauth-signed-http-request.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7591.xml"?>
<reference anchor="arXiv.1901.11520" target="http://arxiv.org/abs/1901.11520/">
  <front>
    <title>An Extensive Formal Security Analysis of the OpenID Financial-grade API</title>
    <author fullname="Daniel Fett" initials="D." surname="Fett">
      <organization></organization>
    </author>
    <author fullname="Pedram Hosseyni" initials="P." surname="Hosseyni">
      <organization></organization>
    </author>
    <author fullname="Ralf Küsters" initials="R." surname="Küsters">
      <organization></organization>
    </author>
    <date year="2019" month="January" day="31"></date>
  </front>
</reference>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.ietf-oauth-mtls.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"?>
<reference anchor="owasp_csrf" target="https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet">
  <front>
    <title>Cross-Site Request Forgery (CSRF) Prevention Cheat Sheet</title>
    <author></author>
    <date></date>
  </front>
</reference>
<reference anchor="oauth_security_ubc" target="http://passwordresearch.com/papers/paper267.html">
  <front>
    <title>The Devil is in the (Implementation) Details: An Empirical Analysis of OAuth SSO Systems</title>
    <author fullname="San-Tsai Sun" initials="S.-T." surname="Sun">
      <organization abbrev="UBC">University of British Columbia</organization>
    </author>
    <author fullname="Konstantin Beznosov" initials="K." surname="Beznosov">
      <organization abbrev="UBC">University of British Columbia</organization>
    </author>
    <date year="2012" month="October"></date>
  </front>
  <format type="HTML" target="http://passwordresearch.com/papers/paper267.html"></format>
</reference>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8414.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.ietf-oauth-mix-up-mitigation.xml"?>
<reference anchor="oauth_security_cmu" target="">
  <front>
    <title>OAuth Demystified for Mobile Application Developers</title>
    <author fullname="Eric Chen" initials="E." surname="Chen">
      <organization abbrev="CMU">Carnegie Mellon University</organization>
    </author>
    <author fullname="Yutong Pei" initials="Y." surname="Pei">
      <organization abbrev="CMU">Carnegie Mellon University</organization>
    </author>
    <author fullname="Shuo Chen" initials="S." surname="Chen">
      <organization abbrev="MR">Microsoft Research</organization>
    </author>
    <author fullname="Yuan Tian" initials="Y." surname="Tian">
      <organization abbrev="CMU">Carnegie Mellon University</organization>
    </author>
    <author fullname="Robert Kotcher" initials="R." surname="Kotcher">
      <organization abbrev="CMU">Carnegie Mellon University</organization>
    </author>
    <author fullname="Patrick Tague" initials="P." surname="Tague">
      <organization abbrev="CMU">Carnegie Mellon University</organization>
    </author>
    <date year="2014" month="November"></date>
  </front>
  <format type="pdf" target="http://css.csail.mit.edu/6.858/2012/readings/oauth-sso.pdf"></format>
</reference>
<reference anchor="webappsec-referrer-policy" target="https://w3c.github.io/webappsec-referrer-policy">
  <front>
    <title>Referrer Policy</title>
    <author initials="J." surname="Eisinger">
      <organization>Google Inc.</organization>
    </author>
    <author initials="E." surname="Stark">
      <organization>Google Inc.</organization>
    </author>
    <date year="2017" month="April" day="20"></date>
  </front>
</reference>
<reference anchor="arXiv.1704.08539" target="http://arxiv.org/abs/1704.08539/">
  <front>
    <title>The Web SSO Standard OpenID Connect: In-Depth Formal Security Analysis and Security Guidelines</title>
    <author fullname="Daniel Fett" initials="D." surname="Fett">
      <organization></organization>
    </author>
    <author fullname="Ralf Küsters" initials="R." surname="Küsters">
      <organization></organization>
    </author>
    <author fullname="Guido Schmitz" initials="G." surname="Schmitz">
      <organization></organization>
    </author>
    <date year="2017" month="April" day="27"></date>
  </front>
</reference>
<reference anchor="arXiv.1508.04324v2" target="http://arxiv.org/abs/1508.04324v2/">
  <front>
    <title>On the security of modern Single Sign-On Protocols: Second-Order Vulnerabilities in OpenID Connect</title>
    <author fullname="Vladislav Mladenov" initials="V." surname="Mladenov">
      <organization></organization>
    </author>
    <author fullname="Christian Mainka" initials="C." surname="Mainka">
      <organization></organization>
    </author>
    <author fullname="Jörg Schwenk" initials="J." surname="Schwenk">
      <organization></organization>
    </author>
    <date year="2016" month="January" day="7"></date>
  </front>
</reference>
<reference anchor="arXiv.1601.01229" target="http://arxiv.org/abs/1601.01229/">
  <front>
    <title>A Comprehensive Formal Security Analysis of OAuth 2.0</title>
    <author fullname="Daniel Fett" initials="D." surname="Fett">
      <organization></organization>
    </author>
    <author fullname="Ralf Küsters" initials="R." surname="Küsters">
      <organization></organization>
    </author>
    <author fullname="Guido Schmitz" initials="G." surname="Schmitz">
      <organization></organization>
    </author>
    <date year="2016" month="January" day="6"></date>
  </front>
</reference>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.bradley-oauth-jwt-encoded-state.xml"?>
<reference anchor="oauth_security_jcs_14" target="">
  <front>
    <title>Discovering concrete attacks on website authorization by formal analysis</title>
    <author fullname="Chetan Bansal" initials="C." surname="Bansal">
      <organization></organization>
    </author>
    <author fullname="Karthikeyan Bhargavan" initials="K." surname="Bhargavan">
      <organization></organization>
    </author>
    <author fullname="Antoine Delignat-Lavaud" initials="A." surname="Delignat-Lavaud">
      <organization></organization>
    </author>
    <author fullname="Sergio Maffeis" initials="S." surname="Maffeis">
      <organization></organization>
    </author>
    <date year="2014" month="April" day="23"></date>
  </front>
  <format type="pdf" target="https://www.doc.ic.ac.uk/~maffeis/papers/jcs14.pdf"></format>
</reference>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.ietf-oauth-resource-indicators.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.ietf-oauth-pop-key-distribution.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.ietf-oauth-closing-redirectors.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml-ids/reference.I-D.ietf-oauth-token-binding.xml"?>
<?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7231.xml"?>
</references>

<section anchor="document-history" title="Document History">
<t>[[ To be removed from the final specification ]]</t>
<t>-13</t>
<t>
<list style="symbols">
<t>Discourage use of Resource Owner Password Credentials Grant</t>
<t>Added text on client impersonating resource owner</t>
<t>Recommend asymmetric methods for client authentication</t>
<t>Encourage use of PKCE mode &quot;S256&quot;</t>
<t>PKCE may replace state for CSRF protection</t>
<t>AS SHOULD publish PKCE support</t>
<t>Cleaned up discussion on auth code injection</t>
<t>AS MUST support PKCE</t>
</list>
</t>
<t>-12</t>
<t>
<list style="symbols">
<t>Added updated attacker model</t>
</list>
</t>
<t>-11</t>
<t>
<list style="symbols">
<t>Adapted section 2.1.2 to outcome of consensus call</t>
<t>more text on refresh token inactivity and implementation note on refresh token replay detection via refresh token rotation</t>
</list>
</t>
<t>-10</t>
<t>
<list style="symbols">
<t>incorporated feedback by Joseph Heenan</t>
<t>changed occurrences of SHALL to MUST</t>
<t>added text on lack of token/cert binding support tokens issued in
  the authorization response as justification to not recommend
  issuing tokens there at all</t>
<t>added requirement to authenticate clients during code exchange
  (PKCE or client credential) to 2.1.1.</t>
<t>added section on refresh tokens</t>
<t>editorial enhancements to 2.1.2 based on feedback</t>
</list>
</t>
<t>-09</t>
<t>
<list style="symbols">
<t>changed text to recommend not to use implicit but code</t>
<t>added section on access token injection</t>
<t>reworked sections 3.1 through 3.3 to be more specific on implicit
  grant issues</t>
</list>
</t>
<t>-08</t>
<t>
<list style="symbols">
<t>added recommendations re implicit and token injection</t>
<t>uppercased key words in Section 2 according to RFC 2119</t>
</list>
</t>
<t>-07</t>
<t>
<list style="symbols">
<t>incorporated findings of Doug McDorman</t>
<t>added section on HTTP status codes for redirects</t>
<t>added new section on access token privilege restriction based on
  comments from Johan Peeters</t>
</list>
</t>
<t>-06</t>
<t>
<list style="symbols">
<t>reworked section 3.8.1</t>
<t>incorporated Phil Hunt's feedback</t>
<t>reworked section on mix-up</t>
<t>extended section on code leakage via referrer header to also cover
  state leakage</t>
<t>added Daniel Fett as author</t>
<t>replaced text intended to inform WG discussion by recommendations
  to implementors</t>
<t>modified example URLs to conform to RFC 2606</t>
</list>
</t>
<t>-05</t>
<t>
<list style="symbols">
<t>Completed sections on code leakage via referrer header, attacks in
  browser, mix-up, and CSRF</t>
<t>Reworked Code Injection Section</t>
<t>Added reference to OpenID Connect spec</t>
<t>removed refresh token leakage as respective considerations have
  been given in section 10.4 of RFC 6749</t>
<t>first version on open redirection</t>
<t>incorporated Christian Mainka's review feedback</t>
</list>
</t>
<t>-04</t>
<t>
<list style="symbols">
<t>Restructured document for better readability</t>
<t>Added best practices on Token Leakage prevention</t>
</list>
</t>
<t>-03</t>
<t>
<list style="symbols">
<t>Added section on Access Token Leakage at Resource Server</t>
<t>incorporated Brian Campbell's findings</t>
</list>
</t>
<t>-02</t>
<t>
<list style="symbols">
<t>Folded Mix up and Access Token leakage through a bad AS into new
  section for dynamic OAuth threats</t>
<t>reworked dynamic OAuth section</t>
</list>
</t>
<t>-01</t>
<t>
<list style="symbols">
<t>Added references to mitigation methods for token leakage</t>
<t>Added reference to Token Binding for Authorization Code</t>
<t>incorporated feedback of Phil Hunt</t>
<t>fixed numbering issue in attack descriptions in section 2</t>
</list>
</t>
<t>-00 (WG document)</t>
<t>
<list style="symbols">
<t>turned the ID into a WG document and a BCP</t>
<t>Added federated app login as topic in Other Topics</t>
</list>
</t>
</section>

</back>

</rfc>
