draft-ietf-oauth-security-topics-13.txt   draft-ietf-oauth-security-topics-14.txt 
Web Authorization Protocol T. Lodderstedt Web Authorization Protocol T. Lodderstedt
Internet-Draft yes.com Internet-Draft yes.com
Intended status: Best Current Practice J. Bradley Intended status: Best Current Practice J. Bradley
Expires: January 9, 2020 Yubico Expires: August 13, 2020 Yubico
A. Labunets A. Labunets
Facebook
D. Fett D. Fett
yes.com yes.com
July 8, 2019 February 10, 2020
OAuth 2.0 Security Best Current Practice OAuth 2.0 Security Best Current Practice
draft-ietf-oauth-security-topics-13 draft-ietf-oauth-security-topics-14
Abstract Abstract
This document describes best current security practice for OAuth 2.0. This document describes best current security practice for OAuth 2.0.
It updates and extends the OAuth 2.0 Security Threat Model to It updates and extends the OAuth 2.0 Security Threat Model to
incorporate practical experiences gathered since OAuth 2.0 was incorporate practical experiences gathered since OAuth 2.0 was
published and covers new threats relevant due to the broader published and covers new threats relevant due to the broader
application of OAuth 2.0. application of OAuth 2.0.
Status of This Memo Status of This Memo
skipping to change at page 1, line 39 skipping to change at page 1, line 39
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/. Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on January 9, 2020. This Internet-Draft will expire on August 13, 2020.
Copyright Notice Copyright Notice
Copyright (c) 2019 IETF Trust and the persons identified as the Copyright (c) 2020 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(https://trustee.ietf.org/license-info) in effect on the date of (https://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License. described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1. Structure . . . . . . . . . . . . . . . . . . . . . . . . 4 1.1. Structure . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2. Conventions and Terminology . . . . . . . . . . . . . . . 4 1.2. Conventions and Terminology . . . . . . . . . . . . . . . 4
2. The Updated OAuth 2.0 Attacker Model . . . . . . . . . . . . 4 2. Recommendations . . . . . . . . . . . . . . . . . . . . . . . 5
3. Recommendations . . . . . . . . . . . . . . . . . . . . . . . 6 2.1. Protecting Redirect-Based Flows . . . . . . . . . . . . . 5
3.1. Protecting Redirect-Based Flows . . . . . . . . . . . . . 6 2.1.1. Authorization Code Grant . . . . . . . . . . . . . . 6
3.1.1. Authorization Code Grant . . . . . . . . . . . . . . 7 2.1.2. Implicit Grant . . . . . . . . . . . . . . . . . . . 6
3.1.2. Implicit Grant . . . . . . . . . . . . . . . . . . . 8 2.2. Token Replay Prevention . . . . . . . . . . . . . . . . . 7
3.2. Token Replay Prevention . . . . . . . . . . . . . . . . . 8 2.3. Access Token Privilege Restriction . . . . . . . . . . . 7
3.3. Access Token Privilege Restriction . . . . . . . . . . . 9 2.4. Resource Owner Password Credentials Grant . . . . . . . . 8
3.4. Resource Owner Password Credentials Grant . . . . . . . . 9 2.5. Client Authentication . . . . . . . . . . . . . . . . . . 8
3.5. Client Authentication . . . . . . . . . . . . . . . . . . 10 2.6. Other Recommendations . . . . . . . . . . . . . . . . . . 8
3.6. Other Recommendations . . . . . . . . . . . . . . . . . . 10 3. The Updated OAuth 2.0 Attacker Model . . . . . . . . . . . . 8
4. Attacks and Mitigations . . . . . . . . . . . . . . . . . . . 10 4. Attacks and Mitigations . . . . . . . . . . . . . . . . . . . 10
4.1. Insufficient Redirect URI Validation . . . . . . . . . . 10 4.1. Insufficient Redirect URI Validation . . . . . . . . . . 11
4.1.1. Redirect URI Validation Attacks on Authorization Code 4.1.1. Redirect URI Validation Attacks on Authorization Code
Grant . . . . . . . . . . . . . . . . . . . . . . . . 11 Grant . . . . . . . . . . . . . . . . . . . . . . . . 11
4.1.2. Redirect URI Validation Attacks on Implicit Grant . . 12 4.1.2. Redirect URI Validation Attacks on Implicit Grant . . 13
4.1.3. Proposed Countermeasures . . . . . . . . . . . . . . 13 4.1.3. Countermeasures . . . . . . . . . . . . . . . . . . . 14
4.2. Credential Leakage via Referrer Headers . . . . . . . . . 14 4.2. Credential Leakage via Referer Headers . . . . . . . . . 15
4.2.1. Leakage from the OAuth Client . . . . . . . . . . . . 14 4.2.1. Leakage from the OAuth Client . . . . . . . . . . . . 15
4.2.2. Leakage from the Authorization Server . . . . . . . . 14 4.2.2. Leakage from the Authorization Server . . . . . . . . 15
4.2.3. Consequences . . . . . . . . . . . . . . . . . . . . 14 4.2.3. Consequences . . . . . . . . . . . . . . . . . . . . 16
4.2.4. Proposed Countermeasures . . . . . . . . . . . . . . 14 4.2.4. Countermeasures . . . . . . . . . . . . . . . . . . . 16
4.3. Attacks through the Browser History . . . . . . . . . . . 15 4.3. Credential Leakage via Browser History . . . . . . . . . 17
4.3.1. Code in Browser History . . . . . . . . . . . . . . . 16 4.3.1. Authorization Code in Browser History . . . . . . . . 17
4.3.2. Access Token in Browser History . . . . . . . . . . . 16 4.3.2. Access Token in Browser History . . . . . . . . . . . 17
4.4. Mix-Up . . . . . . . . . . . . . . . . . . . . . . . . . 16 4.4. Mix-Up Attacks . . . . . . . . . . . . . . . . . . . . . 18
4.4.1. Attack Description . . . . . . . . . . . . . . . . . 17 4.4.1. Attack Description . . . . . . . . . . . . . . . . . 18
4.4.2. Countermeasures . . . . . . . . . . . . . . . . . . . 18 4.4.2. Countermeasures . . . . . . . . . . . . . . . . . . . 20
4.5. Authorization Code Injection . . . . . . . . . . . . . . 19 4.5. Authorization Code Injection . . . . . . . . . . . . . . 21
4.5.1. Attack Description . . . . . . . . . . . . . . . . . 19 4.5.1. Attack Description . . . . . . . . . . . . . . . . . 21
4.5.2. Discussion . . . . . . . . . . . . . . . . . . . . . 20 4.5.2. Discussion . . . . . . . . . . . . . . . . . . . . . 22
4.5.3. Proposed Countermeasures . . . . . . . . . . . . . . 21 4.5.3. Countermeasures . . . . . . . . . . . . . . . . . . . 23
4.6. Access Token Injection . . . . . . . . . . . . . . . . . 23 4.5.4. Limitations . . . . . . . . . . . . . . . . . . . . . 24
4.6.1. Proposed Countermeasures . . . . . . . . . . . . . . 23 4.6. Access Token Injection . . . . . . . . . . . . . . . . . 24
4.7. Cross Site Request Forgery . . . . . . . . . . . . . . . 23 4.6.1. Countermeasures . . . . . . . . . . . . . . . . . . . 25
4.7.1. Proposed Countermeasures . . . . . . . . . . . . . . 23 4.7. Cross Site Request Forgery . . . . . . . . . . . . . . . 25
4.8. Access Token Leakage at the Resource Server . . . . . . . 24 4.7.1. Countermeasures . . . . . . . . . . . . . . . . . . . 25
4.8.1. Access Token Phishing by Counterfeit Resource Server 24 4.8. Access Token Leakage at the Resource Server . . . . . . . 25
4.8.2. Compromised Resource Server . . . . . . . . . . . . . 29 4.8.1. Access Token Phishing by Counterfeit Resource Server 26
4.9. Open Redirection . . . . . . . . . . . . . . . . . . . . 30 4.8.2. Compromised Resource Server . . . . . . . . . . . . . 31
4.9.1. Authorization Server as Open Redirector . . . . . . . 30 4.9. Open Redirection . . . . . . . . . . . . . . . . . . . . 31
4.9.2. Clients as Open Redirector . . . . . . . . . . . . . 31 4.9.1. Client as Open Redirector . . . . . . . . . . . . . . 32
4.10. 307 Redirect . . . . . . . . . . . . . . . . . . . . . . 31 4.9.2. Authorization Server as Open Redirector . . . . . . . 32
4.11. TLS Terminating Reverse Proxies . . . . . . . . . . . . . 32 4.10. 307 Redirect . . . . . . . . . . . . . . . . . . . . . . 32
4.12. Refresh Token Protection . . . . . . . . . . . . . . . . 32 4.11. TLS Terminating Reverse Proxies . . . . . . . . . . . . . 33
4.13. Client Impersonating Resource Owner . . . . . . . . . . . 34 4.12. Refresh Token Protection . . . . . . . . . . . . . . . . 34
4.13.1. Proposed Countermeasures . . . . . . . . . . . . . . 35 4.12.1. Discussion . . . . . . . . . . . . . . . . . . . . . 34
5. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 35 4.12.2. Recommendations . . . . . . . . . . . . . . . . . . 35
6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 35 4.13. Client Impersonating Resource Owner . . . . . . . . . . . 36
7. Security Considerations . . . . . . . . . . . . . . . . . . . 35 4.13.1. Countermeasures . . . . . . . . . . . . . . . . . . 36
8. References . . . . . . . . . . . . . . . . . . . . . . . . . 35 4.14. Clickjacking . . . . . . . . . . . . . . . . . . . . . . 36
8.1. Normative References . . . . . . . . . . . . . . . . . . 35 5. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 37
8.2. Informative References . . . . . . . . . . . . . . . . . 36 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 38
Appendix A. Document History . . . . . . . . . . . . . . . . . . 39 7. Security Considerations . . . . . . . . . . . . . . . . . . . 38
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 42 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 38
8.1. Normative References . . . . . . . . . . . . . . . . . . 38
8.2. Informative References . . . . . . . . . . . . . . . . . 39
Appendix A. Document History . . . . . . . . . . . . . . . . . . 42
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 46
1. Introduction 1. Introduction
Since its publication in [RFC6749] and [RFC6750], OAuth 2.0 has Since its publication in [RFC6749] and [RFC6750], OAuth 2.0 ("OAuth"
gotten massive traction in the market and became the standard for API in the following) has gotten massive traction in the market and
protection and, as the foundation of OpenID Connect [OpenID], became the standard for API protection and the basis for federated
identity providing. While OAuth was used in a variety of scenarios login using OpenID Connect [OpenID]. While OAuth is used in a
and different kinds of deployments, the following challenges could be variety of scenarios and different kinds of deployments, the
observed: following challenges can be observed:
o OAuth implementations are being attacked through known o OAuth implementations are being attacked through known
implementation weaknesses and anti-patterns (CSRF, referrer implementation weaknesses and anti-patterns. Although most of
header). Although most of these threats are discussed in the these threats are discussed in the OAuth 2.0 Threat Model and
OAuth 2.0 Threat Model and Security Considerations [RFC6819], Security Considerations [RFC6819], continued exploitation
continued exploitation demonstrates there may be a need for more demonstrates a need for more specific recommendations, easier to
specific recommendations, that the existing mitigations may be too implement mitigations, and more defense in depth.
difficult to deploy, and that more defense in depth is needed.
o Technology has changed, e.g., the way browsers treat fragments in
some situations, which changes the implicit grant's underlying
security model.
o OAuth is being used in environments with higher security o OAuth is being used in environments with higher security
requirements than considered initially, such as Open Banking, requirements than considered initially, such as Open Banking,
eHealth, eGovernment, and Electronic Signatures. Those use cases eHealth, eGovernment, and Electronic Signatures. Those use cases
call for stricter guidelines and additional protection. call for stricter guidelines and additional protection.
o OAuth is being used in much more dynamic setups than originally o OAuth is being used in much more dynamic setups than originally
anticipated, creating new challenges with respect to security. anticipated, creating new challenges with respect to security.
Those challenges go beyond the original scope of [RFC6749], Those challenges go beyond the original scope of [RFC6749],
[RFC6750], and [RFC6819]. [RFC6750], and [RFC6819].
OAuth initially assumed a static relationship between client, OAuth initially assumed a static relationship between client,
authorization server and resource servers. The URLs of AS and RS authorization server and resource servers. The URLs of AS and RS
were known to the client at deployment time and built an anchor for were known to the client at deployment time and built an anchor
the trust relationship among those parties. The validation whether for the trust relationship among those parties. The validation
the client talks to a legitimate server was based on TLS server whether the client talks to a legitimate server was based on TLS
authentication (see [RFC6819], Section 4.5.4). With the increasing server authentication (see [RFC6819], Section 4.5.4). With the
adoption of OAuth, this simple model dissolved and, in several increasing adoption of OAuth, this simple model dissolved and, in
scenarios, was replaced by a dynamic establishment of the several scenarios, was replaced by a dynamic establishment of the
relationship between clients on one side and the authorization and relationship between clients on one side and the authorization and
resource servers of a particular deployment on the other side. This resource servers of a particular deployment on the other side.
way the same client could be used to access services of different This way, the same client could be used to access services of
providers (in case of standard APIs, such as e-mail or OpenID different providers (in case of standard APIs, such as e-mail or
Connect) or serves as a frontend to a particular tenant in a multi- OpenID Connect) or serve as a frontend to a particular tenant in a
tenancy. Extensions of OAuth, such as [RFC7591] and [RFC8414] were multi-tenancy environment. Extensions of OAuth, such as the OAuth
developed in order to support the usage of OAuth in dynamic 2.0 Dynamic Client Registration Protocol [RFC7591] and OAuth 2.0
scenarios. As a challenge to the community, such usage scenarios Authorization Server Metadata [RFC8414] were developed in order to
open up new attack angles, which are discussed in this document. support the usage of OAuth in dynamic scenarios.
o Technology has changed. For example, the way browsers treat
fragments when redirecting requests has changed, and with it, the
implicit grant's underlying security model.
This document provides updated security recommendations to address
these challenges. It does not supplant the security advice given in
[RFC6749], [RFC6750], and [RFC6819], but complements those documents.
1.1. Structure 1.1. Structure
The remainder of the document is organized as follows: The next The remainder of this document is organized as follows: The next
section updates the OAuth attacker model. Afterwards, the most section summarizes the most important recommendations of the OAuth
important recommendations of the OAuth working group for every OAuth working group for every OAuth implementor. Afterwards, the updated
implementor are summarized. Subsequently, a detailed analysis of the the OAuth attacker model is presented. Subsequently, a detailed
threats and implementation issues which can be found in the wild analysis of the threats and implementation issues that can be found
today is given along with a discussion of potential countermeasures. in the wild today is given along with a discussion of potential
countermeasures.
1.2. Conventions and Terminology 1.2. Conventions and Terminology
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in BCP "OPTIONAL" in this document are to be interpreted as described in BCP
14 [RFC2119] [RFC8174] when, and only when, they appear in all 14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here. capitals, as shown here.
2. The Updated OAuth 2.0 Attacker Model This specification uses the terms "access token", "authorization
endpoint", "authorization grant", "authorization server", "client",
In [RFC6819], an attacker model was laid out that described the "client identifier" (client ID), "protected resource", "refresh
capabilities of attackers against which OAuth deployments must token", "resource owner", "resource server", and "token endpoint"
defend. In the following, this attacker model is updated to account defined by OAuth 2.0 [RFC6749].
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.
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:
o (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.
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.
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.
o (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.
These attackers conform to the attacker model that was used in formal
analysis efforts for OAuth [arXiv.1601.01229]. Previous attacks on
OAuth have shown that OAuth deployments SHOULD protect against an
even stronger attacker model that is described as follows:
o (A3) Attackers that can read, but not modify, the contents of the
authorization response (i.e., the authorization response can leak
to an attacker).
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.
o (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).
o (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.
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.
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
[arXiv.1901.11520].
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.
3. Recommendations 2. Recommendations
This section describes the set of security mechanisms the OAuth This section describes the set of security mechanisms the OAuth
working group recommends to OAuth implementers. working group recommends to OAuth implementers.
3.1. Protecting Redirect-Based Flows 2.1. Protecting Redirect-Based Flows
Authorization servers MUST utilize exact matching of client redirect When comparing client redirect URIs against pre-registered URIs,
URIs against pre-registered URIs. This measure contributes to the authorization servers MUST utilize exact string matching. This
prevention of leakage of authorization codes and access tokens measure contributes to the prevention of leakage of authorization
(depending on the grant type). It also helps to detect mix-up codes and access tokens (see Section 4.1). It can also help to
attacks. detect mix-up attacks (see Section 4.4).
Clients SHOULD avoid forwarding the user's browser to a URI obtained Clients MUST NOT expose URLs that forward the user's browser to
from a query parameter since such a function could be utilized to arbitrary URIs obtained from a query parameter ("open redirector").
exfiltrate authorization codes and access tokens. If there is a Open redirectors can enable exfiltration of authorization codes and
strong need for this kind of redirects, clients are advised to access tokens, see Section 4.9.1.
implement appropriate countermeasures against open redirection, e.g.,
as described by OWASP [owasp].
Clients MUST prevent CSRF. One-time use CSRF tokens carried in the Clients MUST prevent Cross-Site Request Forgery (CSRF). In this
"state" parameter, which are securely bound to the user agent, SHOULD context, CSRF refers to requests to the redirection endpoint that do
be used for that purpose. If PKCE [RFC7636] is used by the client not originate at the authorization server, but a malicious third
and the authorization server supports PKCE, clients MAY opt to not party (see Section 4.4.1.8. of [RFC6819] for details). Clients that
use "state" for CSRF protection, as such protection is provided by have ensured that the authorization server supports PKCE [RFC7636]
PKCE. In this case, "state" MAY be used again for its original MAY rely the CSRF protection provided by PKCE. In OpenID Connect
purpose, namely transporting data about the application state of the flows, the "nonce" parameter provides CSRF protection. Otherwise,
client (see Section 4.7.1). one-time use CSRF tokens carried in the "state" parameter that are
securely bound to the user agent MUST be used for CSRF protection
(see Section 4.7.1).
In order to prevent mix-up attacks, clients MUST only process In order to prevent mix-up attacks (see Section 4.4), clients MUST
redirect responses of the OAuth authorization server they sent the only process redirect responses of the authorization server they sent
respective request to and from the same user agent this authorization the respective request to and from the same user agent this
request was initiated with. Clients MUST memorize which authorization request was initiated with. Clients MUST store the
authorization server they sent an authorization request to and bind authorization server they sent an authorization request to and bind
this information to the user agent and ensure any sub-sequent this information to the user agent and check that the authorization
messages are sent to the same authorization server. Clients SHOULD request was received from the correct authorization server. Clients
use AS-specific redirect URIs as a means to identify the AS a MUST ensure that the subsequent token request, if applicable, is sent
particular response came from. to the same authorization server. Clients SHOULD use distinct
redirect URIs for each authorization server as a means to identify
Note: [I-D.bradley-oauth-jwt-encoded-state] gives advice on how to the authorization server a particular response came from.
implement CSRF prevention and AS matching using signed JWTs in the
"state" parameter.
AS which redirect a request that potentially contains user An AS that redirects a request potentially containing user
credentials MUST avoid forwarding these user credentials accidentally credentials MUST avoid forwarding these user credentials accidentally
(see Section 4.10). (see Section 4.10 for details).
3.1.1. Authorization Code Grant 2.1.1. Authorization Code Grant
Clients utilizing the authorization grant type MUST use PKCE Clients MUST prevent injection (replay) of authorization codes into
[RFC7636] in order to (with the help of the authorization server) the authorization response by attackers. The use of PKCE [RFC7636]
detect and prevent attempts to inject (replay) authorization codes is RECOMMENDED to this end. The OpenID Connect "nonce" parameter and
into the authorization response. The PKCE challenges must be ID Token Claim [OpenID] MAY be used as well. The PKCE challenge or
transaction-specific and securely bound to the user agent in which OpenID Connect "nonce" MUST be transaction-specific and securely
the transaction was started and the respective client. OpenID bound to the client and the user agent in which the transaction was
Connect clients MAY use the "nonce" parameter of the OpenID Connect started.
authentication request as specified in [OpenID] in conjunction with
the corresponding ID Token claim for the same purpose.
Note: although PKCE so far was recommended as a mechanism to protect Note: although PKCE so far was designed as a mechanism to protect
native apps, this advice applies to all kinds of OAuth clients, native apps, this advice applies to all kinds of OAuth clients,
including web applications. including web applications.
Clients SHOULD use PKCE code challenge methods that do not expose the When using PKCE, clients SHOULD use PKCE code challenge methods that
PKCE verifier in the authorization request. (Otherwise, the attacker do not expose the PKCE verifier in the authorization request.
A4 can trivially break the security provided by PKCE.) Currently, Otherwise, attackers that can read the authorization request (cf.
"S256" is the only such method. Attacker A4 in Section 3) can break the security provided by PKCE.
Currently, "S256" is the only such method.
AS MUST support PKCE [!@RFC7636]. Authorization servers MUST support PKCE [RFC7636].
AS SHOULD provide a way to detect their support for PKCE. To this Authorization servers MUST provide a way to detect their support for
end, they SHOULD either (a) publish, in their AS metadata PKCE. To this end, they MUST either (a) publish the element
([!@RFC8418]), the element "code_challenge_methods_supported" "code_challenge_methods_supported" in their AS metadata ([RFC8418])
containing the supported PKCE challenge methods (which can be used by containing the supported PKCE challenge methods (which can be used by
the client to detect PKCE support) or (b) provide a deployment- the client to detect PKCE support) or (b) provide a deployment-
specific way to ensure or determine PKCE support by the AS. specific way to ensure or determine PKCE support by the AS.
Authorization servers SHOULD furthermore consider the recommendations 2.1.2. Implicit Grant
given in [RFC6819], Section 4.4.1.1, on authorization code replay
prevention.
3.1.2. Implicit Grant
The implicit grant (response type "token") and other response types The implicit grant (response type "token") and other response types
causing the authorization server to issue access tokens in the causing the authorization server to issue access tokens in the
authorization response are vulnerable to access token leakage and authorization response are vulnerable to access token leakage and
access token replay as described in Section 4.1, Section 4.2, access token replay as described in Section 4.1, Section 4.2,
Section 4.3, and Section 4.6. Section 4.3, and Section 4.6.
Moreover, no viable mechanism exists to cryptographically bind access Moreover, no viable mechanism exists to cryptographically bind access
tokens issued in the authorization response to a certain client as it tokens issued in the authorization response to a certain client as it
is recommended in Section 3.2. This makes replay detection for such is recommended in Section 2.2. This makes replay detection for such
access tokens at resource servers impossible. access tokens at resource servers impossible.
In order to avoid these issues, clients SHOULD NOT use the implicit In order to avoid these issues, clients SHOULD NOT use the implicit
grant (response type "token") or any other response type issuing grant (response type "token") or other response types issuing access
access tokens in the authorization response, such as "token id_token" tokens in the authorization response, unless access token injection
and "code token id_token", unless the issued access tokens are in the authorization response is prevented and the aforementioned
sender-constrained and access token injection in the authorization token leakage vectors are mitigated.
response is prevented.
Clients SHOULD instead use the response type "code" (aka
authorization code grant type) as specified in Section 2.1.1 or any
other response type that causes the authorization server to issue
access tokens in the token response, such as the "code id_token"
response type. This allows the authorization server to detect replay
attempts by attackers 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 (see next
section).
2.2. Token Replay Prevention
A sender-constrained access token scopes the applicability of an A sender-constrained access token scopes the applicability of an
access token to a certain sender. This sender is obliged to access token to a certain sender. This sender is obliged to
demonstrate knowledge of a certain secret as prerequisite for the demonstrate knowledge of a certain secret as prerequisite for the
acceptance of that token at the recipient (e.g., a resource server). acceptance of that token at the recipient (e.g., a resource server).
Clients SHOULD instead use the response type "code" (aka Authorization and resource servers SHOULD use mechanisms for sender-
authorization code grant type) as specified in Section 3.1.1 or any constrained access tokens to prevent token replay as described in
other response type that causes the authorization server to issue Section 4.8.1.1.2. The use of Mutual TLS for OAuth 2.0 [RFC8705] is
access tokens in the token response. This allows the authorization RECOMMENDED. Refresh tokens MUST be sender-constrained or use
server to detect replay attempts and generally reduces the attack refresh token rotation as described in Section 4.12.
surface since access tokens are not exposed in URLs. It also allows
the authorization server to sender-constrain the issued tokens.
3.2. Token Replay Prevention
Authorization servers SHOULD use TLS-based methods for sender-
constrained access tokens as described in Section 4.8.1.2, such as
token binding [I-D.ietf-oauth-token-binding] or Mutual TLS for OAuth
2.0 [I-D.ietf-oauth-mtls] in order to prevent token replay. Refresh
tokens MUST be sender-constrained or use refresh token rotation as
described in Section 4.12.
It is recommended to use end-to-end TLS whenever possible. If TLS It is RECOMMENDED to use end-to-end TLS. If TLS traffic needs to be
traffic needs to be terminated at an intermediary, refer to terminated at an intermediary, refer to Section 4.11 for further
Section 4.11 for further security advice. security advice.
3.3. Access Token Privilege Restriction 2.3. Access Token Privilege Restriction
The privileges associated with an access token SHOULD be restricted The privileges associated with an access token SHOULD be restricted
to the minimum required for the particular application or use case. to the minimum required for the particular application or use case.
This prevents clients from exceeding the privileges authorized by the This prevents clients from exceeding the privileges authorized by the
resource owner. It also prevents users from exceeding their resource owner. It also prevents users from exceeding their
privileges authorized by the respective security policy. Privilege privileges authorized by the respective security policy. Privilege
restrictions also limit the impact of token leakage although more restrictions also help to reduce the impact of access token leakage.
effective counter-measures are described in Section 3.2.
In particular, access tokens SHOULD be restricted to certain resource In particular, access tokens SHOULD be restricted to certain resource
servers, preferably to a single resource server. To put this into servers (audience restriction), preferably to a single resource
effect, the authorization server associates the access token with server. To put this into effect, the authorization server associates
certain resource servers and every resource server is obliged to the access token with certain resource servers and every resource
verify for every request, whether the access token sent with that server is obliged to verify, for every request, whether the access
request was meant to be used for that particular resource server. If token sent with that request was meant to be used for that particular
not, the resource server MUST refuse to serve the respective request. resource server. If not, the resource server MUST refuse to serve
Clients and authorization servers MAY utilize the parameters "scope" the respective request. Clients and authorization servers MAY
or "resource" as specified in [RFC6749] and utilize the parameters "scope" or "resource" as specified in
[I-D.ietf-oauth-resource-indicators], respectively, to determine the [RFC6749] and [I-D.ietf-oauth-resource-indicators], respectively, to
resource server they want to access. determine the resource server they want to access.
Additionally, access tokens SHOULD be restricted to certain resources Additionally, access tokens SHOULD be restricted to certain resources
and actions on resource servers or resources. To put this into and actions on resource servers or resources. To put this into
effect, the authorization server associates the access token with the effect, the authorization server associates the access token with the
respective resource and actions and every resource server is obliged respective resource and actions and every resource server is obliged
to verify for every request, whether the access token sent with that to verify, for every request, whether the access token sent with that
request was meant to be used for that particular action on the request was meant to be used for that particular action on the
particular resource. If not, the resource server must refuse to particular resource. If not, the resource server must refuse to
serve the respective request. Clients and authorization servers MAY serve the respective request. Clients and authorization servers MAY
utilize the parameter "scope" as specified in [RFC6749] to determine utilize the parameter "scope" as specified in [RFC6749] and
those resources and/or actions. "authorization_details" as specified in [I-D.ietf-oauth-rar] to
determine those resources and/or actions.
3.4. Resource Owner Password Credentials Grant 2.4. Resource Owner Password Credentials Grant
The resource owner password credentials grant MUST NOT be used. This The resource owner password credentials grant MUST NOT be used. This
grant type insecurely exposes the credentials of the resource owner grant type insecurely exposes the credentials of the resource owner
to the client. Even if the client is benign, this results in an to the client. Even if the client is benign, this results in an
increased attack surface (credentials can leak in more places than increased attack surface (credentials can leak in more places than
just the AS) and users are trained to enter their credentials in just the AS) and users are trained to enter their credentials in
places other than the AS. places other than the AS.
Furthermore, adapting the resource owner password credentials grant Furthermore, adapting the resource owner password credentials grant
to two-factor authentication, authentication with cryptographic to two-factor authentication, authentication with cryptographic
credentials, and authentication processes that require multiple steps credentials (cf. WebCrypto [webcrypto], WebAuthn [webauthn]), and
can be hard or impossible (WebCrypto, WebAuthn). authentication processes that require multiple steps can be hard or
impossible.
3.5. Client Authentication 2.5. Client Authentication
Authorization servers SHOULD use client authentication if possible. Authorization servers SHOULD use client authentication if possible.
It is RECOMMENDED to use asymmetric (public key based) methods for It is RECOMMENDED to use asymmetric (public-key based) methods for
client authentication such as MTLS [I-D.draft-ietf-oauth-mtls] or client authentication such as mTLS [RFC8705] or "private_key_jwt"
"private_key_jwt" [OIDC]. When asymmetric methods for client [OpenID]. When asymmetric methods for client authentication are
authentication are used, authorization servers do not need to store used, authorization servers do not need to store sensitive symmetric
sensitive symmetric keys, making these methods more robust against a keys, making these methods more robust against a number of attacks.
number of attacks. Additionally, these methods enable non-repudation
and work well with sender-constrained access tokens (without
requiring additional keys to be distributed).
3.6. Other Recommendations 2.6. Other Recommendations
Authorization servers SHOULD NOT allow clients to influence their Authorization servers SHOULD NOT allow clients to influence their
"client_id" or "sub" value or any other claim that might cause "client_id" or "sub" value or any other claim if that can cause
confusion with a genuine resource owner (see Section 4.13). confusion with a genuine resource owner (see Section 4.13).
3. The Updated OAuth 2.0 Attacker Model
In [RFC6819], an attacker model is laid out that describes the
capabilities of attackers against which OAuth deployments must be
protected. In the following, this attacker model is updated to
account for the potentially dynamic relationships involving multiple
parties (as described in Section 1), to include new types of
attackers and to define the attacker model more clearly.
OAuth MUST ensure that the authorization of the resource owner (RO)
(with a user agent) at the authorization server (AS) and the
subsequent usage of the access token at the resource server (RS) is
protected at least against the following attackers:
o (A1) Web Attackers that can set up and operate an arbitrary number
of network endpoints including browsers and servers (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, and
participate in the protocol.
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 the RO and other
resource owners.
It must also be assumed that web attackers can lure the user to
open arbitrary attacker-chosen URIs at any time. In practice,
this can be achieved in many ways, for example, by injecting
malicious advertisements into advertisement networks, or by
sending legit-looking emails.
Web attackers can use their own user credentials to create new
messages as well as any secrets they learned previously. For
example, if a web attacker learns an authorization code of a user
through a misconfigured redirect URI, the web attacker can then
try to redeem that code for an access token.
They cannot, however, read or manipulate messages that are not
targeted towards them (e.g., sent to a URL controlled by a non-
attacker controlled AS).
o (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.
While an example for a web attacker would be a customer of an
internet service provider, network attackers could be the internet
service provider itself, an attacker in a public (wifi) network using
ARP spoofing, or a state-sponsored attacker with access to internet
exchange points, for instance.
These attackers conform to the attacker model that was used in formal
analysis efforts for OAuth [arXiv.1601.01229]. 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. Previous attacks on OAuth have shown that OAuth
deployments SHOULD in particular consider the following, stronger
attackers in addition to those listed above:
o (A3) Attackers that can read, but not modify, the contents of the
authorization response (i.e., the authorization response can leak
to an attacker).
Examples for such attacks include open redirector attacks,
problems existing on mobile operating systems (where different
apps can register themselves on the same URI), mix-up attacks (see
Section 4.4), 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.
o (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).
o (A5) Attackers that can acquire 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. See also Section 4.8.2.
(A3), (A4) and (A5) typically occur together with either (A1) or
(A2).
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.
This document focusses on threats resulting from these attackers.
Attacks in an even stronger attacker model are discussed, for
example, in [arXiv.1901.11520].
4. Attacks and Mitigations 4. Attacks and Mitigations
This section gives a detailed description of attacks on OAuth This section gives a detailed description of attacks on OAuth
implementations, along with potential countermeasures. This section implementations, along with potential countermeasures. Attacks and
complements and enhances the description given in [RFC6819]. mitigations already covered in [RFC6819] are not listed here, except
where new recommendations are made.
4.1. Insufficient Redirect URI Validation 4.1. Insufficient Redirect URI Validation
Some authorization servers allow clients to register redirect URI Some authorization servers allow clients to register redirect URI
patterns instead of complete redirect URIs. In those cases, the patterns instead of complete redirect URIs. The authorization
authorization server, at runtime, matches the actual redirect URI servers then match the redirect URI parameter value at the
parameter value at the authorization endpoint against this pattern. authorization endpoint against the registered patterns at runtime.
This approach allows clients to encode transaction state into This approach allows clients to encode transaction state into
additional redirect URI parameters or to register just a single additional redirect URI parameters or to register a single pattern
pattern for multiple redirect URIs. As a downside, it turned out to for multiple redirect URIs.
be more complex to implement and error prone to manage than exact
redirect URI matching. Several successful attacks, utilizing flaws This approach turned out to be more complex to implement and more
in the pattern matching implementation or concrete configurations, error prone to manage than exact redirect URI matching. Several
have been observed in the wild. Insufficient validation of the successful attacks exploiting flaws in the pattern matching
redirect URI effectively breaks client identification or implementation or concrete configurations have been observed in the
authentication (depending on grant and client type) and allows the wild . Insufficient validation of the redirect URI effectively breaks
attacker to obtain an authorization code or access token, either client identification or authentication (depending on grant and
client type) and allows the attacker to obtain an authorization code
or access token, either
o by directly sending the user agent to a URI under the attackers o by directly sending the user agent to a URI under the attackers
control, or control, or
o by exposing the OAuth credentials to an attacker by utilizing an o by exposing the OAuth credentials to an attacker by utilizing an
open redirector at the client in conjunction with the way user open redirector at the client in conjunction with the way user
agents handle URL fragments. agents handle URL fragments.
These attacks are shown in detail in the following subsections.
4.1.1. Redirect URI Validation Attacks on Authorization Code Grant 4.1.1. Redirect URI Validation Attacks on Authorization Code Grant
For a public client using the grant type code, an attack would look For a client using the grant type code, an attack may work as
as follows: follows:
Let's assume the redirect URL pattern "https://*.somesite.example/*" Assume the redirect URL pattern "https://*.somesite.example/*" is
had been registered for the client "s6BhdRkqt3". This pattern allows registered for the client with the client ID "s6BhdRkqt3". The
redirect URIs pointing to any host residing in the domain intention is to allow any subdomain of "somesite.example" to be a
somesite.example. So if an attacker manages to establish a host or valid redirect URI for the client, for example
subdomain in somesite.example he can impersonate the legitimate "https://app1.somesite.example/redirect". A naive implementation on
client. Assume the attacker sets up the host the authorization server, however, might interpret the wildcard "*"
"evil.somesite.example". as "any character" and not "any character valid for a domain name".
The authorization server, therefore, might permit
"https://attacker.example/.somesite.example" as a redirect URI,
although "attacker.example" is a different domain potentially
controlled by a malicious party.
The attack can then be conducted as follows: The attack can then be conducted as follows:
First, the attacker needs to trick the user into opening a tampered First, the attacker needs to trick the user into opening a tampered
URL in his browser, which launches a page under the attacker's URL in his browser that launches a page under the attacker's control,
control, say "https://www.evil.example". (See Attacker A1.) say "https://www.evil.example" (see Attacker A1.)
This URL initiates an authorization request with the client id of a This URL initiates the following authorization request with the
legitimate client to the authorization endpoint. This is the example client ID of a legitimate client to the authorization endpoint (line
authorization request (line breaks are for display purposes only): breaks for display only):
GET /authorize?response_type=code&client_id=s6BhdRkqt3&state=9ad67f13 GET /authorize?response_type=code&client_id=s6BhdRkqt3&state=9ad67f13
&redirect_uri=https%3A%2F%2Fevil.somesite.example%2Fcb HTTP/1.1 &redirect_uri=https%3A%2F%2Fattacker.example%2F.somesite.example
HTTP/1.1
Host: server.somesite.example Host: server.somesite.example
Afterwards, the authorization server validates the redirect URI in The authorization server validates the redirect URI and compares it
order to identify the client. Since the pattern allows arbitrary to the registered redirect URL patterns for the client "s6BhdRkqt3".
host names in "somesite.example", the authorization request is The authorization request is processed and presented to the user.
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 [RFC6749]), the attack can be performed even easier.
If the user does not recognize the attack, the code is issued and If the user does not see the redirect URI or does not recognize the
immediately sent to the attacker's client. attack, the code is issued and immediately sent to the attacker's
domain. If an automatic approval of the authorization is enabled
(which is not recommended for public clients according to [RFC6749]),
the attack can be performed even without user interaction.
Since the attacker impersonated a public client, it can exchange the If the attacker impersonated a public client, the attacker can
code for tokens at the respective token endpoint. exchange the code for tokens at the respective token endpoint.
Note: This attack will not work as easily for confidential clients, This attack will not work as easily for confidential clients, since
since the code exchange requires authentication with the legitimate the code exchange requires authentication with the legitimate
client's secret. The attacker will need to impersonate or utilize client's secret. The attacker can, however, use the legitimate
the legitimate client to redeem the code (e.g., by performing a code confidential client to redeem the code by performing an authorization
injection attack). This kind of injections is covered in code injection attack, see Section 4.5.
Section 4.5.
Note: Vulnerabilities of this kind can also exist if the
authorization server handles wildcards properly. For example, assume
that the client registers the redirect URL pattern
"https://*.somesite.example/*" and the authorization server
interprets this as "allow redirect URIs pointing to any host residing
in the domain "somesite.example"". If an attacker manages to
establish a host or subdomain in "somesite.example", he can
impersonate the legitimate client. This could be caused, for
example, by a subdomain takeover attack [subdomaintakeover], where an
outdated CNAME record (say, "external-service.somesite.example")
points to an external DNS name that does no longer exist (say,
"customer-abc.service.example") and can be taken over by an attacker
(e.g., by registering as "customer-abc" with the external service).
4.1.2. Redirect URI Validation Attacks on Implicit Grant 4.1.2. Redirect URI Validation Attacks on Implicit Grant
The attack described above works for the implicit grant as well. If The attack described above works for the implicit grant as well. If
the attacker is able to send the authorization response to a URI the attacker is able to send the authorization response to a URI
under his control, he will directly get access to the fragment under his control, he will directly get access to the fragment
carrying the access token. carrying the access token.
Additionally, implicit clients can be subject to a further kind of Additionally, implicit clients can be subject to a further kind of
attack. It utilizes the fact that user agents re-attach fragments to attack. It utilizes the fact that user agents re-attach fragments to
the destination URL of a redirect if the location header does not the destination URL of a redirect if the location header does not
contain a fragment (see [RFC7231], Section 9.5). The attack contain a fragment (see [RFC7231], Section 9.5). The attack
described here combines this behavior with the client as an open described here combines this behavior with the client as an open
redirector in order to get access to access tokens. This allows redirector (see Section 4.9.1) in order to get access to access
circumvention even of very narrow redirect URI patterns (but not tokens. This allows circumvention even of very narrow redirect URI
strict URL matching!). patterns, but not strict URL matching.
Assume the pattern for client "s6BhdRkqt3" is Assume the registered URL pattern for client "s6BhdRkqt3" is
"https://client.somesite.example/cb?*", i.e., any parameter is "https://client.somesite.example/cb?*", i.e., any parameter is
allowed for redirects to "https://client.somesite.example/cb". allowed for redirects to "https://client.somesite.example/cb".
Unfortunately, the client exposes an open redirector. This endpoint Unfortunately, the client exposes an open redirector. This endpoint
supports a parameter "redirect_to" which takes a target URL and will supports a parameter "redirect_to" which takes a target URL and will
send the browser to this URL using an HTTP Location header redirect send the browser to this URL using an HTTP Location header redirect
303. 303.
The attack can now be conducted as follows: The attack can now be conducted as follows:
First, and as above, the attacker needs to trick the user into First, and as above, the attacker needs to trick the user into
opening a tampered URL in his browser, which launches a page under opening a tampered URL in his browser that launches a page under the
the attacker's control, say "https://www.evil.example". attacker's control, say "https://www.evil.example".
Afterwards, the website initiates an authorization request, which is Afterwards, the website initiates an authorization request that is
very similar to the one in the attack on the code flow. Different to very similar to the one in the attack on the code flow. Different to
above, it utilizes the open redirector by encoding above, it utilizes the open redirector by encoding
"redirect_to=https://client.evil.example" into the redirect URI and "redirect_to=https://attacker.example" into the parameters of the
it uses the response type "token" (line breaks are for display redirect URI and it uses the response type "token" (line breaks for
purposes only): display only):
GET /authorize?response_type=token&state=9ad67f13 GET /authorize?response_type=token&state=9ad67f13
&client_id=s6BhdRkqt3 &client_id=s6BhdRkqt3
&redirect_uri=https%3A%2F%2Fclient.somesite.example &redirect_uri=https%3A%2F%2Fclient.somesite.example
%2Fcb%26redirect_to%253Dhttps%253A%252F %2Fcb%26redirect_to%253Dhttps%253A%252F
%252Fclient.evil.example%252Fcb HTTP/1.1 %252Fattacker.example%252F HTTP/1.1
Host: server.somesite.example Host: server.somesite.example
Now, since the redirect URI matches the registered pattern, the Now, since the redirect URI matches the registered pattern, the
authorization server allows the request and sends the resulting authorization server permits the request and sends the resulting
access token with a 303 redirect (some response parameters are access token in a 303 redirect (some response parameters omitted for
omitted for better readability) readability):
HTTP/1.1 303 See Other HTTP/1.1 303 See Other
Location: https://client.somesite.example/cb? Location: https://client.somesite.example/cb?
redirect_to%3Dhttps%3A%2F%2Fclient.evil.example%2Fcb redirect_to%3Dhttps%3A%2F%2Fattacker.example%2Fcb
#access_token=2YotnFZFEjr1zCsicMWpAA&... #access_token=2YotnFZFEjr1zCsicMWpAA&...
At example.com, the request arrives at the open redirector. It will At example.com, the request arrives at the open redirector. The
read the redirect parameter and will issue an HTTP 303 Location endpoint will read the redirect parameter and will issue an HTTP 303
header redirect to the URL "https://client.evil.example/cb". Location header redirect to the URL "https://attacker.example/".
HTTP/1.1 303 See Other HTTP/1.1 303 See Other
Location: https://client.evil.example/cb Location: https://attacker.example/
Since the redirector at client.somesite.example does not include a Since the redirector at client.somesite.example does not include a
fragment in the Location header, the user agent will re-attach the fragment in the Location header, the user agent will re-attach the
original fragment "#access_token=2YotnFZFEjr1zCsicMWpAA&..." to original fragment "#access_token=2YotnFZFEjr1zCsicMWpAA&..." to
the URL and will navigate to the following URL: the URL and will navigate to the following URL:
https://client.evil.example/cb#access_token=2YotnFZFEjr1z... https://attacker.example/#access_token=2YotnFZFEjr1z...
The attacker's page at "client.evil.example" can now access the The attacker's page at "attacker.example" can now access the fragment
fragment and obtain the access token. and obtain the access token.
4.1.3. Proposed Countermeasures 4.1.3. Countermeasures
The complexity of implementing and managing pattern matching The complexity of implementing and managing pattern matching
correctly obviously causes security issues. This document therefore correctly obviously causes security issues. This document therefore
proposes to simplify the required logic and configuration by using advises to simplify the required logic and configuration by using
exact redirect URI matching only. This means the authorization exact redirect URI matching only. This means the authorization
server must compare the two URIs using simple string comparison as server MUST compare the two URIs using simple string comparison as
defined in [RFC3986], Section 6.2.1. defined in [RFC3986], Section 6.2.1.
Additional recommendations: Additional recommendations:
o Servers on which callbacks are hosted must not expose open o Servers on which callbacks are hosted MUST NOT expose open
redirectors (see Section 4.9). redirectors (see Section 4.9).
o Clients MAY drop fragments via intermediary URLs with "fix o Browsers reattach URL fragments to Location redirection URLs only
fragments" (see [fb_fragments]) to prevent the user agent from if the URL in the Location header does not already contain a
appending any unintended fragments. fragment. Therefore, servers MAY prevent browsers from
reattaching fragments to redirection URLs by attaching an
arbitrary fragment identifier, for example "#_", to URLs in
Location headers.
o Clients SHOULD use the authorization code response type instead of o Clients SHOULD use the authorization code response type instead of
response types causing access token issuance at the authorization response types causing access token issuance at the authorization
endpoint. This offers countermeasures against reuse of leaked endpoint. This offers countermeasures against reuse of leaked
credentials through the exchange process with the authorization credentials through the exchange process with the authorization
server and token replay through certificate binding of the access server and token replay through sender-constraining of the access
tokens. tokens.
As an alternative to exact redirect URI matching, the AS could also If the origin and integrity of the authorization request containing
authenticate clients, e.g., using [I-D.ietf-oauth-jwsreq]. the redirect URI can be verified, for example when using
[I-D.ietf-oauth-jwsreq] or [I-D.ietf-oauth-par] with client
authentication, the authorization server MAY trust the redirect URI
without further checks.
4.2. Credential Leakage via Referrer Headers 4.2. Credential Leakage via Referer Headers
Authorization codes or values of "state" can unintentionally be The contents of the authorization request URI or the authorization
disclosed to attackers through the referrer header, by leaking either response URI can unintentionally be disclosed to attackers through
from a client's web site or from an AS's web site. Note: even if the Referer HTTP header (see [RFC7231], Section 5.5.2), by leaking
specified otherwise in [RFC7231], Section 5.5.2, the same may happen either from the AS's or the client's web site, respectively. Most
to access tokens conveyed in URI fragments due to browser importantly, authorization codes or "state" values can be disclosed
implementation issues as illustrated by Chromium Issue 168213 in this way. Although specified otherwise in [RFC7231],
[bug.chromium]. 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 [bug.chromium].
4.2.1. Leakage from the OAuth Client 4.2.1. Leakage from the OAuth Client
Leakage from the OAuth client requires that the client, as a result Leakage from the OAuth client requires that the client, as a result
of a successful authorization request, renders a page that of a successful authorization request, renders a page that
o contains links to other pages under the attacker's control (ads, o contains links to other pages under the attacker's control and a
faq, ...) and a user clicks on such a link, or user clicks on such a link, or
o includes third-party content (iframes, images, etc.), for example o includes third-party content (advertisements in iframes, images,
if the page contains user-generated content (blog). etc.), for example if the page contains user-generated content
(blog).
As soon as the browser navigates to the attacker's page or loads the As soon as the browser navigates to the attacker's page or loads the
third-party content, the attacker receives the authorization response third-party content, the attacker receives the authorization response
URL and can extract "code", "access token", or "state". URL and can extract "code" or "state" (and potentially "access
token").
4.2.2. Leakage from the Authorization Server 4.2.2. Leakage from the Authorization Server
In a similar way, an attacker can learn "state" if the authorization In a similar way, an attacker can learn "state" from the
endpoint at the authorization server contains links or third-party authorization request if the authorization endpoint at the
content as above. authorization server contains links or third-party content as above.
4.2.3. Consequences 4.2.3. Consequences
An attacker that learns a valid code or access token through a An attacker that learns a valid code or access token through a
referrer header can perform the attacks as described in Referer header can perform the attacks as described in Section 4.1.1,
Section 4.1.1, Section 4.5, and Section 4.6. If the attacker learns Section 4.5, and Section 4.6. If the attacker learns "state", the
"state", the CSRF protection achieved by using "state" is lost, CSRF protection achieved by using "state" is lost, resulting in CSRF
resulting in CSRF attacks as described in [RFC6819], Section 4.4.1.8. attacks as described in [RFC6819], Section 4.4.1.8.
4.2.4. Proposed Countermeasures 4.2.4. Countermeasures
The page rendered as a result of the OAuth authorization response and The page rendered as a result of the OAuth authorization response and
the authorization endpoint SHOULD NOT include third-party resources the authorization endpoint SHOULD NOT include third-party resources
or links to external sites. or links to external sites.
The following measures further reduce the chances of a successful The following measures further reduce the chances of a successful
attack: attack:
o Suppress the Referer header by applying an appropriate Referrer
Policy [webappsec-referrer-policy] to the document (either as part
of the "referrer" meta attribute or by setting a Referrer-Policy
header). For example, the header "Referrer-Policy: no-referrer"
in the response completely suppresses the Referer header in all
requests originating from the resulting document.
o Use authorization code instead of response types causing access
token issuance from the authorization endpoint.
o Bind authorization code to a confidential client or PKCE o Bind authorization code to a confidential client or PKCE
challenge. In this case, the attacker lacks the secret to request challenge. In this case, the attacker lacks the secret to request
the code exchange. the code exchange.
o As described in [RFC6749], Section 4.1.2, authorization codes MUST o As described in [RFC6749], Section 4.1.2, authorization codes MUST
be invalidated by the AS after their first use at the token be invalidated by the AS after their first use at the token
endpoint. For example, if an AS invalidated the code after the endpoint. For example, if an AS invalidated the code after the
legitimate client redeemed it, the attacker would fail exchanging legitimate client redeemed it, the attacker would fail exchanging
this code later. this code later.
This does not mitigate the attack if the attacker manages to This does not mitigate the attack if the attacker manages to
exchange the code for a token before the legitimate client does exchange the code for a token before the legitimate client does
so. Therefore, [RFC6749] further recommends that, when an attempt so. Therefore, [RFC6749] further recommends that, when an attempt
is made to redeem a code twice, the AS SHOULD revoke all tokens is made to redeem a code twice, the AS SHOULD revoke all tokens
issued previously based on that code. issued previously based on that code.
o The "state" value SHOULD be invalidated by the client after its o The "state" value SHOULD be invalidated by the client after its
first use at the redirection endpoint. If this is implemented, first use at the redirection endpoint. If this is implemented,
and an attacker receives a token through the referrer header from and an attacker receives a token through the Referer header from
the client's web site, the "state" was already used, invalidated the client's web site, the "state" was already used, invalidated
by the client and cannot be used again by the attacker. (This by the client and cannot be used again by the attacker. (This
does not help if the "state" leaks from the AS's web site, since does not help if the "state" leaks from the AS's web site, since
then the "state" has not been used at the redirection endpoint at then the "state" has not been used at the redirection endpoint at
the client yet.) the client yet.)
o Suppress the referrer header by adding the attribute o Use the form post response mode instead of a redirect for the
"rel="noreferrer"" to HTML links or by applying an appropriate authorization response (see [oauth-v2-form-post-response-mode]).
Referrer Policy [webappsec-referrer-policy] to the document
(either as part of the "referrer" meta attribute or by setting a
Referrer-Policy header).
o 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.
o Additionally, one might use the form post response mode instead of
redirect for authorization response (see
[oauth-v2-form-post-response-mode]).
4.3. Attacks through the Browser History 4.3. Credential Leakage via Browser History
Authorization codes and access tokens can end up in the browser's Authorization codes and access tokens can end up in the browser's
history of visited URLs, enabling the attacks described in the history of visited URLs, enabling the attacks described in the
following. following.
4.3.1. Code in Browser History 4.3.1. Authorization Code in Browser History
When a browser navigates to "client.example/ When a browser navigates to "client.example/
redirection_endpoint?code=abcd" as a result of a redirect from a redirection_endpoint?code=abcd" as a result of a redirect from a
provider's authorization endpoint, the URL including the provider's authorization endpoint, the URL including the
authorization code may end up in the browser's history. An attacker 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. with access to the device could obtain the code and try to replay it.
Proposed countermeasures: Countermeasures:
o Authorization code replay prevention as described in [RFC6819], o Authorization code replay prevention as described in [RFC6819],
Section 4.4.1.1, and Section 4.5 Section 4.4.1.1, and Section 4.5.
o Use form post response mode instead of redirect for authorization o Use form post response mode instead of redirect for the
response (see [oauth-v2-form-post-response-mode]) authorization response (see [oauth-v2-form-post-response-mode]).
4.3.2. Access Token in Browser History 4.3.2. Access Token in Browser History
An access token may end up in the browser history if a client or just An access token may end up in the browser history if a client or a
a web site, which already has a token, deliberately navigates to a web site that already has a token deliberately navigates to a page
page like "provider.com/get_user_profile?access_token=abcdef.". like "provider.com/get_user_profile?access_token=abcdef". [RFC6750]
Actually [RFC6750] discourages this practice and asks to transfer discourages this practice and advises to transfer tokens via a
tokens via a header, but in practice web sites often just pass access header, but in practice web sites often pass access tokens in query
token in query parameters. parameters.
In case of implicit grant, a URL like "client.example/ In case of the implicit grant, a URL like "client.example/
redirection_endpoint#access_token=abcdef" may also end up in the redirection_endpoint#access_token=abcdef" may also end up in the
browser history as a result of a redirect from a provider's browser history as a result of a redirect from a provider's
authorization endpoint. authorization endpoint.
Proposed countermeasures: Countermeasures:
o Replace implicit flow with postmessage communication or the
authorization code grant
o Never pass access tokens in URL query parameters o Clients MUST NOT pass access tokens in a URI query parameter in
the way described in Section 2.3 of [RFC6750]. The authorization
code grant or alternative OAuth response modes like the form post
response mode [oauth-v2-form-post-response-mode] can be used to
this end.
4.4. Mix-Up 4.4. Mix-Up Attacks
Mix-up is an attack on scenarios where an OAuth client interacts with Mix-up is an attack on scenarios where an OAuth client interacts with
multiple authorization servers, as is usually the case when dynamic two or more authorization servers and at least one authorization
registration is used. The goal of the attack is to obtain an server is under the control of the attacker. This can be the case,
authorization code or an access token by tricking the client into for example, if the attacker uses dynamic registration to register
sending those credentials to the attacker instead of using them at the client at his own authorization server or if an authorization
the respective endpoint at the authorization/resource server. server becomes compromised.
The goal of the attack is to obtain an authorization code or an
access token for an uncompromised authorization server. This is
achieved by tricking the client into sending those credentials to the
compromised authorization server (the attacker) instead of using them
at the respective endpoint of the uncompromised authorization/
resource server.
4.4.1. Attack Description 4.4.1. Attack Description
For a detailed attack description, refer to [arXiv.1601.01229] and The description here closely follows [arXiv.1601.01229], with
[I-D.ietf-oauth-mix-up-mitigation]. The description here closely variants of the attack outlined below.
follows [arXiv.1601.01229], with variants of the attack outlined
below.
Preconditions: For the attack to work, we assume that Preconditions: For this variant of the attack to work, we assume that
o the implicit or authorization code grant are used with multiple AS o the implicit or authorization code grant are used with multiple AS
of which one is considered "honest" (H-AS) and one is operated by of which one is considered "honest" (H-AS) and one is operated by
the attacker (A-AS), the attacker (A-AS),
o the client stores the AS chosen by the user in a session bound to o 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 the user's browser and uses the same redirection endpoint URI for
each AS, and each AS, and
o the attacker can manipulate the first request/response pair from a o the attacker can intercept and manipulate the first request/
user's browser to the client (in which the user selects a certain response pair from a user's browser to the client (in which the
AS and is then redirected by the client to that AS), as in user selects a certain AS and is then redirected by the client to
Attacker A2. that AS), as in Attacker A2.
Some of the attack variants described below require different The latter ability can, for example, be the result of a man-in-the-
preconditions. middle attack on the user's connection to the client. Note that an
attack variant exists that does not require this ability, see below.
In the following, we assume that the client is registered with H-AS In the following, we assume that the client is registered with H-AS
(URI: "https://honest.as.example", client id: "7ZGZldHQ") and with (URI: "https://honest.as.example", client ID: "7ZGZldHQ") and with
A-AS (URI: "https://attacker.example", client id: "666RVZJTA"). A-AS (URI: "https://attacker.example", client ID: "666RVZJTA").
Attack on the authorization code grant: Attack on the authorization code grant:
1. The user selects to start the grant using H-AS (e.g., by clicking 1. The user selects to start the grant using H-AS (e.g., by clicking
on a button at the client's website). on a button at the client's website).
2. The attacker intercepts this request and changes the user's 2. The attacker intercepts this request and changes the user's
selection to "A-AS". selection to "A-AS" (see preconditions).
3. The client stores in the user's session that the user selected 3. The client stores in the user's session that the user selected
"A-AS" and redirects the user to A-AS's authorization endpoint by "A-AS" and redirects the user to A-AS's authorization endpoint
sending the response code "303 See Other" with a Location header with a Location header containing the URL
containing the URL "https://attacker.example/ "https://attacker.example/
authorize?response_type=code&client_id=666RVZJTA". authorize?response_type=code&client_id=666RVZJTA".
4. Now the attacker intercepts this response and changes the 4. Now the attacker intercepts this response and changes the
redirection such that the user is being redirected to H-AS. 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 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 the client's ID at H-AS. Therefore, the browser receives a
redirection ("303 See Other") with a Location header pointing to redirection ("303 See Other") with a Location header pointing to
"https://honest.as.example/ "https://honest.as.example/
authorize?response_type=code&client_id=7ZGZldHQ" authorize?response_type=code&client_id=7ZGZldHQ"
5. Now, the user authorizes the client to access her resources at 5. The user authorizes the client to access her resources at H-AS.
H-AS. H-AS issues a code and sends it (via the browser) back to H-AS issues a code and sends it (via the browser) back to the
the client. client.
6. Since the client still assumes that the code was issued by A-AS, 6. 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. it will try to redeem the code at A-AS's token endpoint.
7. The attacker therefore obtains code and can either exchange the 7. The attacker therefore obtains code and can either exchange the
code for an access token (for public clients) or perform a code code for an access token (for public clients) or perform an
injection attack as described in Section 4.5. authorization code injection attack as described in Section 4.5.
Variants: Variants:
o *Mix-Up Without Interception*: 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, it
is assumed 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 "7ZGZldHQ").
Note that 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.
o *Implicit Grant*: In the implicit grant, the attacker receives an o *Implicit Grant*: In the implicit grant, the attacker receives an
access token instead of the code; the rest of the attack works as access token instead of the code; the rest of the attack works as
above. above.
o *Mix-Up Without Interception*: 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 "7ZGZldHQ").
(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.
o *Per-AS Redirect URIs*: If clients use different redirect URIs for o *Per-AS Redirect URIs*: If clients use different redirect URIs for
different ASs, do not store the selected AS in the user's session, different ASs, do not store the selected AS in the user's session,
and ASs do not check the redirect URIs properly, attackers can and ASs do not check the redirect URIs properly, attackers can
mount an attack called "Cross-Social Network Request Forgery". mount an attack called "Cross-Social Network Request Forgery".
Refer to [oauth_security_jcs_14] for details. These attacks have been observed in practice. Refer to
[oauth_security_jcs_14] for details.
o *OpenID Connect*: There are several variants that can be used to o *OpenID Connect*: There are variants that can be used to attack
attack OpenID Connect. They are described in detail in OpenID Connect. In these attacks, the attacker misuses features
[arXiv.1704.08539], Appendix A, and [arXiv.1508.04324v2], of the OpenID Connect Discovery mechanism or replays access tokens
Section 6 ("Malicious Endpoints Attacks"). or ID Tokens to conduct a Mix-Up Attack. The attacks are
described in detail in [arXiv.1704.08539], Appendix A, and
[arXiv.1508.04324v2], Section 6 ("Malicious Endpoints Attacks").
4.4.2. Countermeasures 4.4.2. Countermeasures
In scenarios where an OAuth client interacts with multiple In scenarios where an OAuth client interacts with multiple
authorization servers, clients MUST prevent mix-up attacks. authorization servers, clients MUST prevent mix-up attacks.
Potential countermeasures: To this end, clients SHOULD use distinct redirect URIs for each AS
(with alternatives listed below). Clients MUST store, for each
authorization request, the AS they sent the authorization request to
and bind this information to the user agent. Clients MUST check that
the authorization request was received from the correct authorization
server and ensure that the subsequent token request, if applicable,
is sent to the same authorization server.
o Configure authorization servers to return an AS identitifier Unfortunately, distinct redirect URIs per AS do not work for all
("iss") and the "client_id" for which a code or token was issued kinds of OAuth clients. They are effective for web and JavaScript
in the authorization response. This enables clients to compare apps and for native apps with claimed URLs. Attacks on native apps
this data to their own client id and the "iss" identifier of the using custom schemes or redirect URIs on localhost cannot be
AS it believed it sent the user agent to. This mitigation is prevented this way.
discussed in detail in [I-D.ietf-oauth-mix-up-mitigation]. 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.
o As it can be seen in the preconditions of the attacks above, If clients cannot use distinct redirect URIs for each AS, the
clients can prevent mix-up attack by (1) using AS-specific following options exist:
redirect URIs with exact redirect URI matching, (2) storing, for
each authorization request, the intended AS, and (3) comparing the o Authorization servers can be configured to return an AS
intended AS with the actual redirect URI where the authorization identitifier ("iss") as a non-standard parameter in the
response was received. authorization response. This enables complying clients to compare
this data to the "iss" identifier of the AS it believed it sent
the user agent to.
o In OpenID Connect, if an ID Token is returned in the authorization
response, it carries client ID and issuer. It can be used in the
same way as the "iss" parameter.
4.5. Authorization Code Injection 4.5. Authorization Code Injection
In such an attack, the adversary attempts to inject a stolen In an authorization code injection attack, the attacker attempts to
authorization code into a legitimate client on a device under his inject a stolen authorization code into the attacker's own session
control. In the simplest case, the attacker would want to use the with the client. The aim is to associate the attacker's session at
code in his own client. But there are situations where this might the client with the victim's resources or identity.
not be possible or intended. Examples are:
o The attacker wants to access certain functions in this particular This attack is useful if the attacker cannot exchange the
client. As an example, the attacker wants to impersonate his authorization code for an access token himself. Examples include:
victim in a certain app or on a certain web site.
o The code is bound to a particular confidential client and the o The code is bound to a particular confidential client and the
attacker is unable to obtain the required client credentials to attacker is unable to obtain the required client credentials to
redeem the code himself. redeem the code himself.
o 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.
o The authorization or resource servers are limited to certain o The authorization or resource servers are limited to certain
networks that the attacker is unable to access directly. networks that the attacker is unable to access directly.
In the following attack description and discussion, we assume the In the following attack description and discussion, we assume the
presence of a web or network attacker, but not of an attacker with presence of a web (A1) or network attacker (A2).
advanced capabilities (A3-A5).
4.5.1. Attack Description 4.5.1. Attack Description
The attack works as follows: The attack works as follows:
1. The attacker obtains an authorization code by performing any of 1. The attacker obtains an authorization code by performing any of
the attacks described above. the attacks described above.
2. He performs a regular OAuth authorization process with the 2. He performs a regular OAuth authorization process with the
legitimate client on his device. legitimate client on his device.
3. The attacker injects the stolen authorization code in the 3. The attacker injects the stolen authorization code in the
response of the authorization server to the legitimate client. response of the authorization server to the legitimate client.
Since this response is passing through the attacker's device, the
attacker can use any tool that can intercept and manipulate the
authorization response to this end. The attacker does not need
to control the network.
4. The client sends the code to the authorization server's token 4. The legitimate client sends the code to the authorization
endpoint, along with client id, client secret and actual server's token endpoint, along with the client's client ID,
"redirect_uri". client secret and actual "redirect_uri".
5. The authorization server checks the client secret, whether the 5. The authorization server checks the client secret, whether the
code was issued to the particular client and whether the actual code was issued to the particular client, and whether the actual
redirect URI matches the "redirect_uri" parameter (see redirect URI matches the "redirect_uri" parameter (see
[RFC6749]). [RFC6749]).
6. If all checks succeed, the authorization server issues access and 6. All checks succeed and the authorization server issues access and
other tokens to the client, so now the attacker is able to other tokens to the client. The attacker has now associated his
impersonate the legitimate user. session with the legitimate client with the victim's resources
and/or identity.
4.5.2. Discussion 4.5.2. Discussion
Obviously, the check in step (5.) will fail if the code was issued to 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 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 will also fail if the authorization code was already redeemed by the
legitimate user and was one-time use only. legitimate user and was one-time use only.
An attempt to inject a code obtained via a manipulated redirect URI An attempt to inject a code obtained via a manipulated redirect URI
should also be detected if the authorization server stored the should also be detected if the authorization server stored the
complete redirect URI used in the authorization request and compares complete redirect URI used in the authorization request and compares
it with the "redirect_uri" parameter. it with the "redirect_uri" parameter.
[RFC6749], Section 4.1.3, requires the AS to "... ensure that the [RFC6749], Section 4.1.3, requires the AS to "... ensure that the
"redirect_uri" parameter is present if the "redirect_uri" parameter "redirect_uri" parameter is present if the "redirect_uri" parameter
was included in the initial authorization request as described in was included in the initial authorization request as described in
Section 4.1.1, and if included ensure that their values are Section 4.1.1, and if included ensure that their values are
identical.". In the attack scenario described above, the legitimate identical.". In the attack scenario described above, the legitimate
client would use the correct redirect URI it always uses for client would use the correct redirect URI it always uses for
authorization requests. But this URI would not match the tampered authorization requests. But this URI would not match the tampered
redirect URI used by the attacker (otherwise, the redirect would not redirect URI used by the attacker (otherwise, the redirect would not
land at the attackers page). So the authorization server would land at the attackers page). So the authorization server would
detect the attack and refuse to exchange the code. detect the attack and refuse to exchange the code.
Note: this check could also detect attempts to inject a code which Note: this check could also detect attempts to inject an
had been obtained from another instance of the same client on another authorization code which had been obtained from another instance of
device, if certain conditions are fulfilled: the same client on another device, if certain conditions are
fulfilled:
o the redirect URI itself needs to contain a nonce or another kind o the redirect URI itself needs to contain a nonce or another kind
of one-time use, secret data and of one-time use, secret data and
o the client has bound this data to this particular instance. o the client has bound this data to this particular instance of the
client.
But this approach conflicts with the idea to enforce exact redirect But this approach conflicts with the idea to enforce exact redirect
URI matching at the authorization endpoint. Moreover, it has been URI matching at the authorization endpoint. Moreover, it has been
observed that providers very often ignore the "redirect_uri" check observed that providers very often ignore the "redirect_uri" check
requirement at this stage, maybe because it doesn't seem to be requirement at this stage, maybe because it doesn't seem to be
security-critical from reading the specification. security-critical from reading the specification.
Other providers just pattern match the "redirect_uri" parameter Other providers just pattern match the "redirect_uri" parameter
against the registered redirect URI pattern. This saves the against the registered redirect URI pattern. This saves the
authorization server from storing the link between the actual authorization server from storing the link between the actual
redirect URI and the respective authorization code for every redirect URI and the respective authorization code for every
transaction. But this kind of check obviously does not fulfill the transaction. But this kind of check obviously does not fulfill the
intent of the spec, since the tampered redirect URI is not intent of the specification, since the tampered redirect URI is not
considered. So any attempt to inject a code obtained using the considered. So any attempt to inject an authorization code obtained
"client_id" of a legitimate client or by utilizing the legitimate using the "client_id" of a legitimate client or by utilizing the
client on another device won't be detected in the respective legitimate client on another device will not be detected in the
deployments. respective deployments.
It is also assumed that the requirements defined in [RFC6749], It is also assumed that the requirements defined in [RFC6749],
Section 4.1.3, increase client implementation complexity as clients Section 4.1.3, increase client implementation complexity as clients
need to memorize or re-construct the correct redirect URI for the need to store or re-construct the correct redirect URI for the call
call to the tokens endpoint. to the token endpoint.
This document therefore recommends to instead bind every This document therefore recommends to instead bind every
authorization code to a certain client instance on a certain device authorization code to a certain client instance on a certain device
(or in a certain user agent) in the context of a certain transaction. (or in a certain user agent) in the context of a certain transaction
using one of the mechanisms described next.
4.5.3. Proposed Countermeasures
There are multiple technical solutions to achieve this goal:
o *Nonce*: OpenID Connect's existing "nonce" parameter can be used 4.5.3. Countermeasures
for the purpose of detecting authorization code injection attacks.
The "nonce" 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 "nonce" 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 "nonce" is an existing feature used in the
wild. On the other hand, leveraging "nonce" by the broader OAuth
community would require AS and clients to adopt ID Tokens.
o *Code-bound State*: The "state" parameter as specified in There are two good technical solutions to achieve this goal:
[RFC6749] could be used similarly to what is described above.
This would require to add a further parameter "state" to the code
exchange token endpoint request. The authorization server would
then compare the "state" value it associated with the code and the
"state" 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 "state" and
to extend the token endpoint request.
o *PKCE*: The PKCE parameter "code_challenge" along with the o *PKCE*: The PKCE parameter "code_challenge" along with the
corresponding "code_verifier" as specified in [RFC7636] could be corresponding "code_verifier" as specified in [RFC7636] can be
used in the same way as "nonce" or "state". In contrast to its used as a countermeasure. In contrast to its original intention,
original intention, the verifier check would fail although the the verifier check fails although the client uses its correct
client uses its correct verifier but the code is associated with a verifier but the code is associated with a challenge that does not
challenge, which does not match. PKCE is a deployed OAuth match. PKCE is a deployed OAuth feature, although its original
feature, even though it is used today to secure native apps only. intended use was solely focused on securing native apps, not the
broader use recommended by this document.
o *Token Binding*: Token binding [I-D.ietf-oauth-token-binding] o *Nonce*: OpenID Connect's existing "nonce" parameter can be used
could also be used. In this case, the code would need to be bound for the same purpose. The "nonce" value is one-time use and
to two legs, between user agent and AS and the user agent and the created by the client. The client is supposed to bind it to the
client. This requires further data (extension to response) to user agent session and sends it with the initial request to the
manifest binding id for particular code. Token binding is OpenID Provider (OP). The OP binds "nonce" to the authorization
promising as a secure and convenient mechanism (due to its browser code and attests this binding in the ID Token, which is issued as
integration). As a challenge, it requires broad browser support part of the code exchange at the token endpoint. If an attacker
and use with native apps is still under discussion. 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.
o *Per-instance client id/secret*: One could use per instance Other solutions, like binding "state" to the code, using token
"client_id" and secrets and bind the code to the respective binding for the code, or per-instance client credentials are
"client_id". Unfortunately, this does not fit into the web conceivable, but lack support and bring new security requirements.
application programming model (would need to use per-user client
IDs).
PKCE seems to be the most obvious solution for OAuth clients as it is PKCE is the most obvious solution for OAuth clients as it is
available and effectively used today for similar purposes for OAuth available today (originally intended for OAuth native apps) whereas
native apps whereas "nonce" is appropriate for OpenId Connect "nonce" is appropriate for OpenID Connect clients.
clients.
Note on pre-warmed secrets: An attacker can circumvent the 4.5.4. Limitations
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.
Exact redirect URI matching of authorization requests can prevent the An attacker can circumvent the countermeasures described above if he
attacker from using the pre-warmed secret in the faked authorization can modify the "nonce" or "code_challenge" values that are used in
transaction on the victim's device. the victim's authorization request. The attacker can modify these
values to be the same ones as those chosen by the client in his own
session in Step 2 of the attack above. (This requires that the
victim's session with the client begins after the attacker started
his session with the client.) If the attacker is then able to
capture the authorization code from the victim, the attacker will be
able to inject the stolen code in Step 3 even if PKCE or "nonce" are
used.
Unfortunately, it does not work for all kinds of OAuth clients. It This attack is complex and requires a close interaction between the
is effective for web and JS apps and for native apps with claimed attacker and the victim's session. Nonetheless, measures to prevent
URLs. Attacks on native apps using custom schemes or redirect URIs attackers from reading the contents of the authorization response
on localhost cannot be prevented this way, except if the AS enforces still need to be taken, as described in Section 4.1, Section 4.2,
one-time use for PKCE verifier or "nonce" values. Section 4.3, Section 4.4, and Section 4.9.
4.6. Access Token Injection 4.6. Access Token Injection
In such an attack, the adversary attempts to inject a stolen access In an access token injection attack, the attacker attempts to inject
token into a legitimate client on a device under his control. This a stolen access token into a legitimate client (that is not under the
will typically happen if the attacker wants to utilize a leaked attacker's control). This will typically happen if the attacker
access token to impersonate a user in a certain client. wants to utilize a leaked access token to impersonate a user in a
certain client.
To conduct the attack, the adversary starts an OAuth flow with the To conduct the attack, the attacker starts an OAuth flow with the
client and modifies the authorization response by replacing the client using the implicit grant and modifies the authorization
access token issued by the authorization server or directly makes up response by replacing the access token issued by the authorization
an authorization server response including the leaked access token. server or directly makes up an authorization server response
Since the response includes the state value generated by the client including the leaked access token. Since the response includes the
for this particular transaction, the client does not treat the "state" value generated by the client for this particular
response as a CSRF and will use the access token injected by the transaction, the client does not treat the response as a CSRF attack
attacker. and uses the access token injected by the attacker.
4.6.1. Proposed Countermeasures 4.6.1. Countermeasures
There is no way to detect such an injection attack on the OAuth 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 protocol level, since the token is issued without any binding to the
transaction or the particular user agent. transaction or the particular user agent.
The recommendation is therefore to use the authorization code grant The recommendation is therefore to use the authorization code grant
type instead of relying on response types issuing acess tokens at the type instead of relying on response types issuing acess tokens at the
authorization endpoint. Code injection can be detected using one of authorization endpoint. Authorization code injection can be detected
the countermeasures discussed in Section 4.5. using one of the countermeasures discussed in Section 4.5.
4.7. Cross Site Request Forgery 4.7. Cross Site Request Forgery
An attacker might attempt to inject a request to the redirect URI of 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 the legitimate client on the victim's device, e.g., to cause the
client to access resources under the attacker's control. client to access resources under the attacker's control. This is a
variant of an attack known as Cross-Site Request Forgery (CSRF).
4.7.1. Proposed Countermeasures 4.7.1. Countermeasures
Use of CSRF tokens which are bound to the user agent and passed in The traditional countermeasure are CSRF tokens that are bound to the
the "state" parameter to the authorization server as described in user agent and passed in the "state" parameter to the authorization
[!@RFC6819]. Alternatively, PKCE provides CSRF protection. server as described in [RFC6819]. The same protection is provided by
PKCE or the OpenID Connect "nonce" value.
It is important to note that: When using PKCE instead of "state" or "nonce" for CSRF protection, it
is important to note that:
o Clients MUST ensure that the AS supports PKCE before using PKCE o Clients MUST ensure that the AS supports PKCE before using PKCE
for CSRF protection. If an authorization server does not support for CSRF protection. If an authorization server does not support
PKCE, "state" MUST be used for CSRF protection. PKCE, "state" or "nonce" MUST be used for CSRF protection.
o If "state" is used for carrying application state, and integrity o If "state" is used for carrying application state, and integrity
of its contents is a concern, clients MUST protect state against of its contents is a concern, clients MUST protect "state" against
tampering and swapping. This can be achieved by binding the tampering and swapping. This can be achieved by binding the
contents of state to the browser session and/or signed/encrypted contents of state to the browser session and/or signed/encrypted
state values [I-D.bradley-oauth-jwt-encoded-state]. state values [I-D.bradley-oauth-jwt-encoded-state].
The recommendation therefore is that AS publish their PKCE support AS therefore MUST provide a way to detect their support for PKCE
either in AS metadata according to [RFC8418] or provide a deployment- either via AS metadata according to [RFC8414] or provide a
specific way to ensure or determine PKCE support. deployment-specific way to ensure or determine PKCE support.
Additionally, standard CSRF defenses MAY be used to protect the
redirection endpoint, for example the Origin header.
For more details see [owasp_csrf].
4.8. Access Token Leakage at the Resource Server 4.8. Access Token Leakage at the Resource Server
Access tokens can leak from a resource server under certain Access tokens can leak from a resource server under certain
circumstances. circumstances.
4.8.1. Access Token Phishing by Counterfeit Resource Server 4.8.1. Access Token Phishing by Counterfeit Resource Server
An attacker may setup his own resource server and trick a client into 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 sending access tokens to it that are valid for other resource servers
skipping to change at page 24, line 45 skipping to change at page 26, line 21
that token to access other services on behalf of the resource owner. that token to access other services on behalf of the resource owner.
This attack assumes the client is not bound to one specific resource This attack assumes the client is not bound to one specific resource
server (and its URL) at development time, but client instances are server (and its URL) at development time, but client instances are
provided with the resource server URL at runtime. This kind of late provided with the resource server URL at runtime. This kind of late
binding is typical in situations where the client uses a service binding is typical in situations where the client uses a service
implementing a standardized API (e.g., for e-Mail, calendar, health, implementing a standardized API (e.g., for e-Mail, calendar, health,
or banking) and where the client is configured by a user or or banking) and where the client is configured by a user or
administrator for a service which this user or company uses. administrator for a service which this user or company uses.
4.8.1.1. Countermeasures
There are several potential mitigation strategies, which will be There are several potential mitigation strategies, which will be
discussed in the following sections. discussed in the following sections.
4.8.1.1. Metadata 4.8.1.1.1. Metadata
An authorization server could provide the client with additional An authorization server could provide the client with additional
information about the location where it is safe to use its access information about the location where it is safe to use its access
tokens. tokens.
In the simplest form, this would require the AS to publish a list of In the simplest form, this would require the AS to publish a list of
its known resource servers, illustrated in the following example its known resource servers, illustrated in the following example
using a metadata parameter "resource_servers": using a non-standard metadata parameter "resource_servers":
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/json Content-Type: application/json
{ {
"issuer":"https://server.somesite.example", "issuer":"https://server.somesite.example",
"authorization_endpoint": "authorization_endpoint":
"https://server.somesite.example/authorize", "https://server.somesite.example/authorize",
"resource_servers":[ "resource_servers":[
"email.somesite.example", "email.somesite.example",
skipping to change at page 25, line 23 skipping to change at page 27, line 4
"issuer":"https://server.somesite.example", "issuer":"https://server.somesite.example",
"authorization_endpoint": "authorization_endpoint":
"https://server.somesite.example/authorize", "https://server.somesite.example/authorize",
"resource_servers":[ "resource_servers":[
"email.somesite.example", "email.somesite.example",
"storage.somesite.example", "storage.somesite.example",
"video.somesite.example" "video.somesite.example"
] ]
... ...
} }
The AS could also return the URL(s) an access token is good for in The AS could also return the URL(s) an access token is good for in
the token response, illustrated by the example return parameter the token response, illustrated by the example and non-standard
"access_token_resource_server": return parameter "access_token_resource_server":
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8 Content-Type: application/json;charset=UTF-8
Cache-Control: no-store Cache-Control: no-store
Pragma: no-cache Pragma: no-cache
{ {
"access_token":"2YotnFZFEjr1zCsicMWpAA", "access_token":"2YotnFZFEjr1zCsicMWpAA",
"access_token_resource_server": "access_token_resource_server":
"https://hostedresource.somesite.example/path1", "https://hostedresource.somesite.example/path1",
skipping to change at page 26, line 5 skipping to change at page 27, line 34
large portion of client implementations do not or fail to properly large portion of client implementations do not or fail to properly
implement security controls, like "state" checks. So relying on implement security controls, like "state" checks. So relying on
clients to prevent access token phishing is likely to fail as well. clients to prevent access token phishing is likely to fail as well.
Moreover given the ratio of clients to authorization and resource Moreover given the ratio of clients to authorization and resource
servers, it is considered the more viable approach to move as much as servers, it is considered the more viable approach to move as much as
possible security-related logic to those entities. Clearly, the possible security-related logic to those entities. Clearly, the
client has to contribute to the overall security. But there are client has to contribute to the overall security. But there are
alternative countermeasures, as described in the next sections, which alternative countermeasures, as described in the next sections, which
provide a better balance between the involved parties. provide a better balance between the involved parties.
4.8.1.2. Sender-Constrained Access Tokens 4.8.1.1.2. Sender-Constrained Access Tokens
As the name suggests, sender-constrained access token scope the As the name suggests, sender-constrained access token scope the
applicability of an access token to a certain sender. This sender is applicability of an access token to a certain sender. This sender is
obliged to demonstrate knowledge of a certain secret as prerequisite obliged to demonstrate knowledge of a certain secret as prerequisite
for the acceptance of that token at a resource server. for the acceptance of that token at a resource server.
A typical flow looks like this: A typical flow looks like this:
1. The authorization server associates data with the access token 1. The authorization server associates data with the access token
which binds this particular token to a certain client. The that binds this particular token to a certain client. The
binding can utilize the client identity, but in most cases the AS binding can utilize the client identity, but in most cases the AS
utilizes key material (or data derived from the key material) utilizes key material (or data derived from the key material)
known to the client. known to the client.
2. This key material must be distributed somehow. Either the key 2. This key material must be distributed somehow. Either the key
material already exists before the AS creates the binding or the material already exists before the AS creates the binding or the
AS creates ephemeral keys. The way pre-existing key material is AS creates ephemeral keys. The way pre-existing key material is
distributed varies among the different approaches. For example, distributed varies among the different approaches. For example,
X.509 Certificates can be used in which case the distribution X.509 Certificates can be used in which case the distribution
happens explicitly during the enrollment process. Or the key happens explicitly during the enrollment process. Or the key
material is created and distributed at the TLS layer, in which material is created and distributed at the TLS layer, in which
case it might automatically happen during the setup of a TLS case it might automatically happen during the setup of a TLS
connection. connection.
3. The RS must implement the actual proof of possession check. This 3. The RS must implement the actual proof of possession check. This
is typically done on the application level, it may utilize is typically done on the application level, often tied to
capabilities of the transport layer (e.g., TLS). Note: replay specific material provided by transport layer (e.g., TLS). The
prevention is required as well! RS must also ensure that replay of the proof of possession is not
possible.
There exist several proposals to demonstrate the proof of possession There exist several proposals to demonstrate the proof of possession
in the scope of the OAuth working group: in the scope of the OAuth working group:
o *OAuth Token Binding* ([I-D.ietf-oauth-token-binding]): In this o *OAuth 2.0 Mutual-TLS Client Authentication and Certificate-Bound
approach, an access token is, via the so-called token binding id, Access Tokens* ([RFC8705]): The approach as specified in this
bound to key material representing a long term association between document allows the use of mutual TLS (mTLS) for both client
a client and a certain TLS host. Negotiation of the key material authentication and sender-constrained access tokens. For the
and proof of possession in the context of a TLS handshake is taken purpose of sender-constrained access tokens, the client is
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 [RFC8473]
(including federated token bindings) must be supported on all ends
(client, authorization server, resource server).
o *OAuth Mutual TLS* ([I-D.ietf-oauth-mtls]): 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 identified towards the resource server by the fingerprint of its
public key. During processing of an access token request, the public key. During processing of an access token request, the
authorization server obtains the client's public key from the TLS authorization server obtains the client's public key from the TLS
stack and associates its fingerprint with the respective access stack and associates its fingerprint with the respective access
tokens. The resource server in the same way obtains the public tokens. The resource server in the same way obtains the public
key from the TLS stack and compares its fingerprint with the key from the TLS stack and compares its fingerprint with the
fingerprint associated with the access token. fingerprint associated with the access token.
o *DPoP* ([I-D.fett-oauth-dpop]): DPoP (Demonstration of Proof-of-
Possession at the Application Layer) outlines an application-level
sender-constraining for access and refresh tokens that can be used
in cases where neither mTLS nor OAuth Token Binding (see below)
are available. It uses proof-of-possession based on a public/
private key pair and application-level signing. DPoP can be used
with public clients and, in case of confidential clients, can be
combined with any client authentication method.
o *OAuth Token Binding* ([I-D.ietf-oauth-token-binding]): In this
approach, an access token is, via the 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 [RFC8473] (including
federated token bindings) must be supported on all ends (client,
authorization server, resource server).
o *Signed HTTP Requests* ([I-D.ietf-oauth-signed-http-request]): o *Signed HTTP Requests* ([I-D.ietf-oauth-signed-http-request]):
This approach utilizes [I-D.ietf-oauth-pop-key-distribution] and This approach utilizes [I-D.ietf-oauth-pop-key-distribution] and
represents the elements of the signature in a JSON object. The represents the elements of the signature in a JSON object. The
signature is built using JWS. The mechanism has built-in support signature is built using JWS. The mechanism has built-in support
for signing of HTTP method, query parameters and headers. It also for signing of HTTP method, query parameters and headers. It also
incorporates a timestamp as basis for replay prevention. incorporates a timestamp as basis for replay prevention.
o *JWT Pop Tokens* ([I-D.sakimura-oauth-jpop]): This draft describes o *JWT Pop Tokens* ([I-D.sakimura-oauth-jpop]): This draft describes
different ways to constrain access token usage, namely TLS or different ways to constrain access token usage, namely TLS or
request signing. Note: Since the authors of this draft request signing. Note: Since the authors of this draft
contributed the TLS-related proposal to [I-D.ietf-oauth-mtls], contributed the TLS-related proposal to [RFC8705], this document
this document only considers the request signing part. For only considers the request signing part. For request signing, the
request signing, the draft utilizes draft utilizes [I-D.ietf-oauth-pop-key-distribution] and
[I-D.ietf-oauth-pop-key-distribution] and [RFC7800]. The [RFC7800]. The signature data is represented in a JWT and JWS is
signature data is represented in a JWT and JWS is used for used for signing. Replay prevention is provided by building the
signing. Replay prevention is provided by building the signature signature over a server-provided nonce, client-provided nonce and
over a server-provided nonce, client-provided nonce and a nonce a nonce counter.
counter.
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.
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,
[I-D.ietf-oauth-mtls] only requires widely deployed TLS features,
which means it might be easier to adopt in the short term.
Application level signing approaches, like At the time of writing, OAuth Mutual TLS is the most widely
[I-D.ietf-oauth-signed-http-request] and [I-D.sakimura-oauth-jpop] implemented and the only standardized sender-constraining method.
have been debated for a long time in the OAuth working group without The use of OAuth Mutual TLS therefore is RECOMMENDED.
a clear outcome.
As one advantage, application-level signing allows for end-to-end Note that the security of sender-constrained tokens is undermined
protection including non-repudiation even if the TLS connection is when an attacker gets access to the token and the key material. This
terminated between client and resource server. But deployment is in particular the case for corrupted client software and cross-
experiences have revealed challenges regarding robustness (e.g., site scripting attacks (when the client is running in the browser).
reproduction of the signature base string including correct URL) as If the key material is protected in a hardware or software security
well as state management (e.g., replay prevention). module or only indirectly accessible (like in a TLS stack), sender-
constrained tokens at least protect against a use of the token when
the client is offline, i.e., when the security module or interface is
not available to the attacker. This applies to access tokens as well
as to refresh tokens (see Section 4.12).
This document therefore recommends implementors to consider one of 4.8.1.1.3. Audience Restricted Access Tokens
TLS-based approaches wherever possible.
4.8.1.3. Audience Restricted Access Tokens Audience restriction essentially restricts access tokens to a
particular resource server. The authorization server associates the
access token with the particular resource server and the resource
server SHOULD verify the intended audience. If the access token
fails the intended audience validation, the resource server must
refuse to serve the respective request.
An audience restriction essentially restricts the resource server a In general, audience restrictions limit the impact of token leakage.
particular access token can be used at. The authorization server In the case of a counterfeit resource server, it may (as described
associates the access token with a certain resource server and every below) also prevent abuse of the phished access token at the
resource server is obliged to verify for every request, whether the legitimate resource server.
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.
The audience can basically be expressed using logical names or The audience can be expressed using logical names or physical
physical addresses (like URLs). In order to prevent phishing, it is addresses (like URLs). In order to prevent phishing, it is necessary
necessary to use the actual URL the client will send requests to. In to use the actual URL the client will send requests to. In the
the phishing case, this URL will point to the counterfeit resource phishing case, this URL will point to the counterfeit resource
server. If the attacker tries to use the access token at the server. If the attacker tries to use the access token at the
legitimate resource server (which has a different URL), the resource legitimate resource server (which has a different URL), the resource
server will detect the mismatch (wrong audience) and refuse to serve server will detect the mismatch (wrong audience) and refuse to serve
the request. the request.
In deployments where the authorization server knows the URLs of all In deployments where the authorization server knows the URLs of all
resource servers, the authorization server may just refuse to issue resource servers, the authorization server may just refuse to issue
access tokens for unknown resource server URLs. access tokens for unknown resource server URLs.
The client needs to tell the authorization server, at which URL it The client SHOULD tell the authorization server the intended resource
will use the access token it is requesting. It could use the server. The proposed mechanism [I-D.ietf-oauth-resource-indicators]
mechanism proposed [I-D.ietf-oauth-resource-indicators] or encode the could be used or by encoding the information in the scope value.
information in the scope value.
Instead of the URL, it is also possible to utilize the fingerprint of Instead of the URL, it is also possible to utilize the fingerprint of
the resource server's X.509 certificate as audience value. This the resource server's X.509 certificate as audience value. This
variant would also allow to detect an attempt to spoof the legit variant would also allow to detect an attempt to spoof the legitimate
resource server's URL by using a valid TLS certificate obtained from resource server's URL by using a valid TLS certificate obtained from
a different CA. It might also be considered a privacy benefit to a different CA. It might also be considered a privacy benefit to
hide the resource server URL from the authorization server. hide the resource server URL from the authorization server.
Audience restriction seems easy to use since it does not require any Audience restriction may seem easier to use since it does not require
crypto on the client side. But since every access token is bound to any crypto on the client-side. Still, since every access token is
a certain resource server, the client also needs to obtain different bound to a specific resource server, the client also needs to obtain
RS-specific access tokens, if it wants to access several resource a single RS-specific access token when accessing several resource
services. [I-D.ietf-oauth-token-binding] has the same property, servers. (Resource indicators, as specified in
since different token binding ids must be associated with the access [I-D.ietf-oauth-resource-indicators], can help to achieve this.)
token. [I-D.ietf-oauth-mtls] on the other hand allows a client to [I-D.ietf-oauth-token-binding] has the same property since different
use the access token at multiple resource servers. token binding ids must be associated with the access token. Using
[RFC8705], on the other hand, allows a client to use the access token
at multiple resource servers.
It shall be noted that audience restrictions, or generally speaking It shall be noted that audience restrictions, or generally speaking
an indication by the client to the authorization server where it an indication by the client to the authorization server where it
wants to use the access token, has additional benefits beyond the wants to use the access token, has additional benefits beyond the
scope of token leakage prevention. It allows the authorization scope of token leakage prevention. It allows the authorization
server to create different access token whose format and content is server to create different access token whose format and content is
specifically minted for the respective server. This has huge specifically minted for the respective server. This has huge
functional and privacy advantages in deployments using structured functional and privacy advantages in deployments using structured
access tokens. access tokens.
4.8.2. Compromised Resource Server 4.8.2. Compromised Resource Server
An attacker may compromise a resource server in order to get access An attacker may compromise a resource server to gain access to the
to its resources and other resources of the respective deployment. resources of the respective deployment. Such a compromise may range
Such a compromise may range from partial access to the system, e.g., from partial access to the system, e.g., its log files, to full
its logfiles, to full control of the respective server. control of the respective server.
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 "only" is able to access logfiles or databases
of the server system, it may get access to valid access tokens.
Preventing server breaches by way of hardening and monitoring server If the attacker were able to gain full control, including shell
systems is considered a standard operational procedure and therefore access, all controls can be circumvented and all resources be
out of scope of this document. This section will focus on the impact accessed. The attacker would also be able to obtain other access
of such breaches on OAuth-related parts of the ecosystem, which is tokens held on the compromised system that would potentially be valid
the replay of captured access tokens on the compromised resource to access other resource servers.
server and other resource servers of the respective deployment.
The following measures should be taken into account by implementors Preventing server breaches by hardening and monitoring server systems
in order to cope with access token replay: is considered a standard operational procedure and, therefore, out of
the scope of this document. This section focuses on the impact of
OAuth-related breaches and the replaying of captured access tokens.
o The resource server must treat access tokens like any other The following measures should be taken into account by implementers
credentials. It is considered good practice to not log them and in order to cope with access token replay by malicious actors:
not to store them in plain text.
o Sender-constrained access tokens as described in Section 4.8.1.2 o Sender-constrained access tokens as described in Section 4.8.1.1.2
will prevent the attacker from replaying the access tokens on SHOULD be used to prevent the attacker from replaying the access
other resource servers. Depending on the severity of the tokens on other resource servers. Depending on the severity of
penetration, it will also prevent replay on the compromised the penetration, sender-constrained access tokens will also
system. prevent replay on the compromised system.
o Audience restriction as described in Section 4.8.1.3 may be used o Audience restriction as described in Section 4.8.1.1.3 SHOULD be
to prevent replay of captured access tokens on other resource used to prevent replay of captured access tokens on other resource
servers. servers.
o The resource server MUST treat access tokens like any other
credentials. It is considered good practice to not log them and
not store them in plain text.
The first and second recommendation also apply to other scenarios
where access tokens leak (see Attacker A5).
4.9. Open Redirection 4.9. Open Redirection
The following attacks can occur when an AS or client has an open 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- redirector. An open redirector is an endpoint that forwards a user's
controlled web site. browser to an arbitrary URI obtained from a query parameter.
4.9.1. Authorization Server as Open Redirector 4.9.1. Client as Open Redirector
Attackers could try to utilize a user's trust in the authorization Clients MUST NOT expose open redirectors. Attackers may use open
server (and its URL in particular) for performing phishing attacks. redirectors to produce URLs pointing to the client and utilize them
to exfiltrate authorization codes and access tokens, as described in
Section 4.1.2. Another abuse case is to produce URLs that appear to
point to the client. This might trick users into trusting the URL
and follow it in their browser. This can be abused for phishing.
[RFC6749], Section 4.1.2.1, already prevents open redirects by In order to prevent open redirection, clients should only redirect if
stating the AS MUST NOT automatically redirect the user agent in case the target URLs are whitelisted or if the origin and integrity of a
of an invalid combination of client_id and redirect_uri. request can be authenticated. Countermeasures against open
redirection are described by OWASP [owasp_redir].
However, as described in [I-D.ietf-oauth-closing-redirectors], an 4.9.2. Authorization Server as Open Redirector
attacker could also utilize a correctly registered redirect URI to
perform phishing attacks. It could for example register a client via
dynamic client registration [RFC7591] 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.
The AS MUST take precautions to prevent this threat. Based on its Just as with clients, attackers could try to utilize a user's trust
risk assessment the AS needs to decide whether it can trust the in the authorization server (and its URL in particular) for
redirect URI or not and SHOULD only automatically redirect the user performing phishing attacks. OAuth authorization servers regularly
agent, if it trusts the redirect URI. If not, it MAY inform the user redirect users to other web sites (the clients), but must do so in a
that it is about to redirect her to the another site and rely on the safe way.
user to decide or MAY just inform the user about the error.
4.9.2. Clients as Open Redirector [RFC6749], Section 4.1.2.1, already prevents open redirects by
stating that the AS MUST NOT automatically redirect the user agent in
case of an invalid combination of "client_id" and "redirect_uri".
Client MUST NOT expose URLs which could be utilized as open However, an attacker could also utilize a correctly registered
redirector. Attackers may use an open redirector to produce URLs redirect URI to perform phishing attacks. The attacker could, for
which appear to point to the client, which might trick users to trust example, register a client via dynamic client registration [RFC7591]
the URL and follow it in her browser. Another abuse case is to and intentionally send an erroneous authorization request, e.g., by
produce URLs pointing to the client and utilize them to impersonate a using an invalid scope value, thus instructing the AS to redirect the
client with an authorization server. user agent to its phishing site.
In order to prevent open redirection, clients should only expose such The AS MUST take precautions to prevent this threat. Based on its
a function, if the target URLs are whitelisted or if the origin of a risk assessment, the AS needs to decide whether it can trust the
request can be authenticated. redirect URI and SHOULD only automatically redirect the user agent if
it trusts the redirect URI. If the URI is not trusted, the AS MAY
inform the user and rely on the user to make the correct decision.
4.10. 307 Redirect 4.10. 307 Redirect
At the authorization endpoint, a typical protocol flow is that the AS 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 prompts the user to enter her credentials in a form that is then
submitted (using the HTTP POST method) back to the authorization submitted (using the HTTP POST method) back to the authorization
server. The AS checks the credentials and, if successful, redirects server. The AS checks the credentials and, if successful, redirects
the user agent to the client's redirection endpoint. the user agent to the client's redirection endpoint.
In [RFC6749], the HTTP status code 302 is used for this purpose, but In [RFC6749], the HTTP status code 302 is used for this purpose, but
"any other method available via the user-agent to accomplish this "any other method available via the user-agent to accomplish this
redirection is allowed". However, when the status code 307 is used redirection is allowed". When the status code 307 is used for
for redirection, the user agent will send the form data (user redirection instead, the user agent will send the user credentials
credentials) via HTTP POST to the client since this status code does via HTTP POST to the client.
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.
In the HTTP standard [RFC6749], only the status code 303 This discloses the sensitive credentials to the client. If the
relying party is malicious, it can use the credentials to impersonate
the user at the AS.
The behavior might be unexpected for developers, but is defined in
[RFC7231], Section 6.4.7. This status code does not require the user
agent to rewrite the POST request to a GET request and thereby drop
the form data in the POST request body.
In the HTTP standard [RFC7231], only the status code 303
unambigiously enforces rewriting the HTTP POST request to an HTTP GET unambigiously enforces rewriting the HTTP POST request to an HTTP GET
request. For all other status codes, including the popular 302, user request. For all other status codes, including the popular 302, user
agents can opt not to rewrite POST to GET requests and therefore to agents can opt not to rewrite POST to GET requests and therefore to
reveal the user credentials to the client. (In practice, however, reveal the user credentials to the client. (In practice, however,
most user agents will only show this behaviour for 307 redirects.) most user agents will only show this behaviour for 307 redirects.)
AS which redirect a request that potentially contains user AS which redirect a request that potentially contains user
credentials therefore MUST NOT use the HTTP 307 status code for credentials therefore MUST NOT use the HTTP 307 status code for
redirection. If an HTTP redirection (and not, for example, redirection. If an HTTP redirection (and not, for example,
JavaScript) is used for such a request, AS SHOULD use HTTP status JavaScript) is used for such a request, AS SHOULD use HTTP status
code 303 "See Other". code 303 "See Other".
4.11. TLS Terminating Reverse Proxies 4.11. TLS Terminating Reverse Proxies
A common deployment architecture for HTTP applications is to have the A common deployment architecture for HTTP applications is to hide the
application server sitting behind a reverse proxy which terminates application server behind a reverse proxy that terminates the TLS
the TLS connection and dispatches the incoming requests to the connection and dispatches the incoming requests to the respective
respective application server nodes. application server nodes.
This section highlights some attack angles of this deployment This section highlights some attack angles of this deployment
architecture which are relevant to OAuth, and gives recommendations architecture with relevance to OAuth and gives recommendations for
for security controls. security controls.
In some situations, the reverse proxy needs to pass security-related In some situations, the reverse proxy needs to pass security-related
data to the upstream application servers for further processing. data to the upstream application servers for further processing.
Examples include the IP address of the request originator, token Examples include the IP address of the request originator, token
binding ids, and authenticated TLS client certificates. binding ids, and authenticated TLS client certificates. This data is
usually passed in custom HTTP headers added to the upstream request.
If the reverse proxy would pass through any header sent from the If the reverse proxy would pass through any header sent from the
outside, an attacker could try to directly send the faked header outside, an attacker could try to directly send the faked header
values through the proxy to the application server in order to values through the proxy to the application server in order to
circumvent security controls that way. For example, it is standard circumvent security controls that way. For example, it is standard
practice of reverse proxies to accept "forwarded_for" headers and practice of reverse proxies to accept "X-Forwarded-For" headers and
just add the origin of the inbound request (making it a list). just add the origin of the inbound request (making it a list).
Depending on the logic performed in the application server, the Depending on the logic performed in the application server, the
attacker could simply add a whitelisted IP address to the header and attacker could simply add a whitelisted IP address to the header and
render a IP whitelist useless. A reverse proxy must therefore render a IP whitelist useless.
sanitize any inbound requests to ensure the authenticity and
integrity of all header values relevant for the security of the A reverse proxy must therefore sanitize any inbound requests to
application servers. ensure the authenticity and integrity of all header values relevant
for the security of the application servers.
If an attacker was able to get access to the internal network between If an attacker was able to get access to the internal network between
proxy and application server, he could also try to circumvent proxy and application server, the attacker could also try to
security controls in place. It is therefore important to ensure the circumvent security controls in place. It is, therefore, essential
authenticity of the communicating entities. Furthermore, the to ensure the authenticity of the communicating entities.
communication link between reverse proxy and application server must Furthermore, the communication link between reverse proxy and
therefore be protected against eavesdropping, injection, and replay application server must be protected against eavesdropping,
of messages. injection, and replay of messages.
4.12. Refresh Token Protection 4.12. Refresh Token Protection
Refresh tokens are a convenient and UX-friendly way to obtain new Refresh tokens are a convenient and user-friendly way to obtain new
access tokens after the expiration of older access tokens. Refresh access tokens after the expiration of access tokens. Refresh tokens
tokens also add to the security of OAuth since they allow the also add to the security of OAuth since they allow the authorization
authorization server to issue access tokens with a short lifetime and server to issue access tokens with a short lifetime and reduced scope
reduced scope thus reducing the potential impact of access token thus reducing the potential impact of access token leakage.
leakage.
4.12.1. Discussion
Refresh tokens are an attractive target for attackers since they Refresh tokens are an attractive target for attackers since they
represent the overall grant a resource owner delegated to a certain represent the overall grant a resource owner delegated to a certain
client. If an attacker is able to exfiltrate and successfully replay client. If an attacker is able to exfiltrate and successfully replay
a refresh token, the attacker will be able to mint access tokens and 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. use them to access resource servers on behalf of the resource owner.
[RFC6749] already provides a robust baseline protection by requiring [RFC6749] already provides a robust baseline protection by requiring
o confidentiality of the refresh tokens in transit and storage, o confidentiality of the refresh tokens in transit and storage,
skipping to change at page 33, line 28 skipping to change at page 35, line 12
o authentication of this client during token refresh, if possible, o authentication of this client during token refresh, if possible,
and and
o that refresh tokens cannot be generated, modified, or guessed. o that refresh tokens cannot be generated, modified, or guessed.
[RFC6749] also lays the foundation for further (implementation [RFC6749] also lays the foundation for further (implementation
specific) security measures, such as refresh token expiration and specific) security measures, such as refresh token expiration and
revocation as well as refresh token rotation by defining respective revocation as well as refresh token rotation by defining respective
error codes and response behavior. error codes and response behavior.
This draft gives recommendations beyond the scope of [RFC6749] and This specification gives recommendations beyond the scope of
clarifications. [RFC6749] and clarifications.
Authorization servers MUST determine based on their risk assessment 4.12.2. Recommendations
Authorization servers SHOULD determine, based on a risk assessment,
whether to issue refresh tokens to a certain client. If the whether to issue refresh tokens to a certain client. If the
authorization server decides not to issue refresh tokens, the client authorization server decides not to issue refresh tokens, the client
may refresh access tokens by utilizing other grant types, such as the MAY refresh access tokens by utilizing other grant types, such as the
authorization code grant type. In such a case, the authorization authorization code grant type. In such a case, the authorization
server may utilize cookies and persistent grants to optimize the user server may utilize cookies and persistent grants to optimize the user
experience. experience.
If refresh tokens are issued, those refresh tokens MUST be bound to If refresh tokens are issued, those refresh tokens MUST be bound to
the scope and resource servers as consented by the resource owner. the scope and resource servers as consented by the resource owner.
This is to prevent privilege escalation by the legit client and This is to prevent privilege escalation by the legitimate client and
reduce the impact of refresh token leakage. reduce the impact of refresh token leakage.
Authorization server MUST utilize one of these methods to detect Authorization server MUST utilize one of these methods to detect
refresh token replay for public clients: refresh token replay by malicious actors for public clients:
o *Sender-constrained refresh tokens:* the authorization server o *Sender-constrained refresh tokens:* the authorization server
cryptographically binds the refresh token to a certain client cryptographically binds the refresh token to a certain client
instance by utilizing [I-D.ietf-oauth-token-binding] or instance by utilizing [I-D.ietf-oauth-token-binding] or [RFC8705].
[I-D.ietf-oauth-mtls].
o *Refresh token rotation:* the authorization server issues a new o *Refresh token rotation:* the authorization server issues a new
refresh token with every access token refresh response. The refresh token with every access token refresh response. The
previous refresh token is invalidated but information about the previous refresh token is invalidated but information about the
relationship is retained by the authorization server. If a relationship is retained by the authorization server. If a
refresh token is compromised and subsequently used by both the refresh token is compromised and subsequently used by both the
attacker and the legitimate client, one of them will present an attacker and the legitimate client, one of them will present an
invalidated refresh token, which will inform the authorization invalidated refresh token, which will inform the authorization
server of the breach. The authorization server cannot determine server of the breach. The authorization server cannot determine
which party submitted the invalid refresh token, but it can revoke which party submitted the invalid refresh token, but it will
the active refresh token. This stops the attack at the cost of revoke the active refresh token. This stops the attack at the
forcing the legit client to obtain a fresh authorization grant. cost of forcing the legitimate client to obtain a fresh
Implementation note: refresh tokens belonging to the same grant authorization grant.
may share a common id. If any of those refresh tokens is used at Implementation note: the grant to which a refresh token belongs
the authorization server, the authorization server uses this may be encoded into the refresh token itself. This can enable an
common id to look up the currently active refresh token and can authorization server to efficiently determine the grant to which a
revoke it. refresh token belongs, and by extension, all refresh tokens that
need to be revoked. Authorization servers MUST ensure the
integrity of the refresh token value in this case, for example,
using signatures.
Authorization servers may revoke refresh tokens automatically in case Authorization servers MAY revoke refresh tokens automatically in case
of a security event, such as: of a security event, such as:
o password change o password change
o logout at the authorization server o logout at the authorization server
Refresh tokens SHOULD expire if the client has been inactive for some 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 time, i.e., the refresh token has not been used to obtain fresh
access tokens for some time. The expiration time is at the access tokens for some time. The expiration time is at the
discretion of the authorization server. It might be a global value discretion of the authorization server. It might be a global value
or determined based on the client policy or the grant associated with or determined based on the client policy or the grant associated with
the refresh token (and its sensitivity). the refresh token (and its sensitivity).
4.13. Client Impersonating Resource Owner 4.13. Client Impersonating Resource Owner
Resource servers may make access control decisions based on the Resource servers may make access control decisions based on the
identity of the resource owner as communicated in the "sub" claim identity of the resource owner as communicated in the "sub" claim
returned by the authorization server in a token introspection returned by the authorization server in a token introspection
response [RFC7662] or other mechanism. If a client is able to choose response [RFC7662] or other mechanisms. If a client is able to
its own "client_id" during registration with the authorization choose its own "client_id" during registration with the authorization
server, then there is a risk that it can register with the same "sub" server, then there is a risk that it can register with the same "sub"
value as a privileged user. A subsequent access token obtained under value as a privileged user. A subsequent access token obtained under
the client credentials grant may be mistaken as an access token the client credentials grant may be mistaken for an access token
authorized by the privileged user if the resource server does not authorized by the privileged user if the resource server does not
perform additional checks. perform additional checks.
4.13.1. Proposed Countermeasures 4.13.1. Countermeasures
Authorization servers SHOULD NOT allow clients to influence their Authorization servers SHOULD NOT allow clients to influence their
"client_id" or "sub" value or any other claim that might cause "client_id" or "sub" value or any other claim if that can cause
confusion with a genuine resource owner. Where this cannot be confusion with a genuine resource owner. Where this cannot be
avoided, authorization servers MUST provide another means for the avoided, authorization servers MUST provide other means for the
resource server to distinguish between access tokens authorized by a resource server to distinguish between access tokens authorized by a
resource owner from access tokens authorized by the client itself. resource owner from access tokens authorized by the client itself.
4.14. Clickjacking
As described in Section 4.4.1.9 of [RFC6819], the authorization
request is susceptible to clickjacking. An attacker can use this
vector to obtain the user's authentication credentials, change the
scope of access granted to the client, and potentially access the
user's resources.
Authorization servers MUST prevent clickjacking attacks. Multiple
countermeasures are described in [RFC6819], including the use of the
X-Frame-Options HTTP response header field and frame-busting
JavaScript. In addition to those, authorization servers SHOULD also
use Content Security Policy (CSP) level 2 [CSP-2] or greater.
To be effective, CSP must be used on the authorization endpoint and,
if applicable, other endpoints used to authenticate the user and
authorize the client (e.g., the device authorization endpoint, login
pages, error pages, etc.). This prevents framing by unauthorized
origins in user agents that support CSP. The client MAY permit being
framed by some other origin than the one used in its redirection
endpoint. For this reason, authorization servers SHOULD allow
administrators to configure allowed origins for particular clients
and/or for clients to register these dynamically.
Using CSP allows authorization servers to specify multiple origins in
a single response header field and to constrain these using flexible
patterns (see [CSP-2] for details). Level 2 of this standard
provides a robust mechanism for protecting against clickjacking by
using policies that restrict the origin of frames (using "frame-
ancestors") together with those that restrict the sources of scripts
allowed to execute on an HTML page (by using "script-src"). A non-
normative example of such a policy is shown in the following listing:
HTTP/1.1 200 OK
Content-Security-Policy: frame-ancestors https://ext.example.org:8000
Content-Security-Policy: script-src 'self'
X-Frame-Options: ALLOW-FROM https://ext.example.org:8000
...
Because some user agents do not support [CSP-2], this technique
SHOULD be combined with others, including those described in
[RFC6819], unless such legacy user agents are explicitly unsupported
by the authorization server. Even in such cases, additional
countermeasures SHOULD still be employed.
5. Acknowledgements 5. Acknowledgements
We would like to thank Jim Manico, Phil Hunt, Nat Sakimura, Christian We would like to thank Jim Manico, Phil Hunt, Nat Sakimura, Christian
Mainka, Doug McDorman, Johan Peeters, Joseph Heenan, Brock Allen, Mainka, Doug McDorman, Johan Peeters, Joseph Heenan, Brock Allen,
Vittorio Bertocci, David Waite, Nov Matake, Tomek Stojecki, Dominick Vittorio Bertocci, David Waite, Nov Matake, Tomek Stojecki, Dominick
Baier, Neil Madden, William Dennis, Dick Hardt, Petteri Stenius, Baier, Neil Madden, William Dennis, Dick Hardt, Petteri Stenius,
Annabelle Richard Backman, Aaron Parecki, George Fletscher, Brian Annabelle Richard Backman, Aaron Parecki, George Fletscher, Brian
Campbell, Konstantin Lapine, and Tim Wuertele for their valuable Campbell, Konstantin Lapine, Tim Wuertele, Guido Schmitz, Hans
feedback. Zandbelt, Jared Jennings, Michael Peck, Pedram Hosseyni, Michael B.
Jones, and Travis Spencer for their valuable feedback.
6. IANA Considerations 6. IANA Considerations
This draft includes no request to IANA. This draft includes no request to IANA.
7. Security Considerations 7. Security Considerations
All relevant security considerations have been given in the All relevant security considerations have been given in the
functional specification. functional specification.
8. References 8. References
8.1. Normative References 8.1. Normative References
[oauth-v2-form-post-response-mode] [oauth-v2-form-post-response-mode]
Jones, M. and B. Campbell, "OAuth 2.0 Form Post Response Jones, M. and B. Campbell, "OAuth 2.0 Form Post Response
Mode", April 2015, <http://openid.net/specs/ Mode", April 2015, <http://openid.net/specs/oauth-v2-form-
oauth-v2-form-post-response-mode-1_0.html>. post-response-mode-1_0.html>.
[OpenID] Sakimura, N., Bradley, J., Jones, M., de Medeiros, B., and [OpenID] Sakimura, N., Bradley, J., Jones, M., de Medeiros, B., and
C. Mortimore, "OpenID Connect Core 1.0 incorporating C. Mortimore, "OpenID Connect Core 1.0 incorporating
errata set 1", Nov 2014, errata set 1", Nov 2014,
<http://openid.net/specs/openid-connect-core-1_0.html>. <http://openid.net/specs/openid-connect-core-1_0.html>.
[RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform
Resource Identifier (URI): Generic Syntax", STD 66, Resource Identifier (URI): Generic Syntax", STD 66,
RFC 3986, DOI 10.17487/RFC3986, January 2005, RFC 3986, DOI 10.17487/RFC3986, January 2005,
<https://www.rfc-editor.org/info/rfc3986>. <https://www.rfc-editor.org/info/rfc3986>.
skipping to change at page 36, line 19 skipping to change at page 38, line 47
[RFC6750] Jones, M. and D. Hardt, "The OAuth 2.0 Authorization [RFC6750] Jones, M. and D. Hardt, "The OAuth 2.0 Authorization
Framework: Bearer Token Usage", RFC 6750, Framework: Bearer Token Usage", RFC 6750,
DOI 10.17487/RFC6750, October 2012, DOI 10.17487/RFC6750, October 2012,
<https://www.rfc-editor.org/info/rfc6750>. <https://www.rfc-editor.org/info/rfc6750>.
[RFC6819] Lodderstedt, T., Ed., McGloin, M., and P. Hunt, "OAuth 2.0 [RFC6819] Lodderstedt, T., Ed., McGloin, M., and P. Hunt, "OAuth 2.0
Threat Model and Security Considerations", RFC 6819, Threat Model and Security Considerations", RFC 6819,
DOI 10.17487/RFC6819, January 2013, DOI 10.17487/RFC6819, January 2013,
<https://www.rfc-editor.org/info/rfc6819>. <https://www.rfc-editor.org/info/rfc6819>.
[RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
Protocol (HTTP/1.1): Semantics and Content", RFC 7231,
DOI 10.17487/RFC7231, June 2014,
<https://www.rfc-editor.org/info/rfc7231>.
[RFC7636] Sakimura, N., Ed., Bradley, J., and N. Agarwal, "Proof Key [RFC7636] Sakimura, N., Ed., Bradley, J., and N. Agarwal, "Proof Key
for Code Exchange by OAuth Public Clients", RFC 7636, for Code Exchange by OAuth Public Clients", RFC 7636,
DOI 10.17487/RFC7636, September 2015, DOI 10.17487/RFC7636, September 2015,
<https://www.rfc-editor.org/info/rfc7636>. <https://www.rfc-editor.org/info/rfc7636>.
[RFC7662] Richer, J., Ed., "OAuth 2.0 Token Introspection", [RFC7662] Richer, J., Ed., "OAuth 2.0 Token Introspection",
RFC 7662, DOI 10.17487/RFC7662, October 2015, RFC 7662, DOI 10.17487/RFC7662, October 2015,
<https://www.rfc-editor.org/info/rfc7662>. <https://www.rfc-editor.org/info/rfc7662>.
[RFC8414] Jones, M., Sakimura, N., and J. Bradley, "OAuth 2.0
Authorization Server Metadata", RFC 8414,
DOI 10.17487/RFC8414, June 2018,
<https://www.rfc-editor.org/info/rfc8414>.
[RFC8418] Housley, R., "Use of the Elliptic Curve Diffie-Hellman Key [RFC8418] Housley, R., "Use of the Elliptic Curve Diffie-Hellman Key
Agreement Algorithm with X25519 and X448 in the Agreement Algorithm with X25519 and X448 in the
Cryptographic Message Syntax (CMS)", RFC 8418, Cryptographic Message Syntax (CMS)", RFC 8418,
DOI 10.17487/RFC8418, August 2018, DOI 10.17487/RFC8418, August 2018,
<https://www.rfc-editor.org/info/rfc8418>. <https://www.rfc-editor.org/info/rfc8418>.
[RFC8705] Campbell, B., Bradley, J., Sakimura, N., and T.
Lodderstedt, "OAuth 2.0 Mutual-TLS Client Authentication
and Certificate-Bound Access Tokens", February 2020,
<https://www.rfc-editor.org/info/rfc8705>.
8.2. Informative References 8.2. Informative References
[arXiv.1508.04324v2] [arXiv.1508.04324v2]
Mladenov, V., Mainka, C., and J. Schwenk, "On the security Mladenov, V., Mainka, C., and J. Schwenk, "On the security
of modern Single Sign-On Protocols: Second-Order of modern Single Sign-On Protocols: Second-Order
Vulnerabilities in OpenID Connect", January 2016, Vulnerabilities in OpenID Connect", January 2016,
<http://arxiv.org/abs/1508.04324v2/>. <http://arxiv.org/abs/1508.04324v2/>.
[arXiv.1601.01229] [arXiv.1601.01229]
Fett, D., Kuesters, R., and G. Schmitz, "A Comprehensive Fett, D., Kuesters, R., and G. Schmitz, "A Comprehensive
skipping to change at page 37, line 16 skipping to change at page 40, line 11
Fett, D., Hosseyni, P., and R. Kuesters, "An Extensive Fett, D., Hosseyni, P., and R. Kuesters, "An Extensive
Formal Security Analysis of the OpenID Financial-grade Formal Security Analysis of the OpenID Financial-grade
API", January 2019, <http://arxiv.org/abs/1901.11520/>. API", January 2019, <http://arxiv.org/abs/1901.11520/>.
[bug.chromium] [bug.chromium]
"Referer header includes URL fragment when opening link "Referer header includes URL fragment when opening link
using New Tab", using New Tab",
<https://bugs.chromium.org/p/chromium/issues/ <https://bugs.chromium.org/p/chromium/issues/
detail?id=168213/>. detail?id=168213/>.
[fb_fragments] [CSP-2] West, M., Barth, A., and D. Veditz, "Content Security
"Facebook Developer Blog", Policy Level 2", July 2015, <https://www.w3.org/TR/CSP2>.
<https://developers.facebook.com/blog/post/552/>.
[I-D.bradley-oauth-jwt-encoded-state] [I-D.bradley-oauth-jwt-encoded-state]
Bradley, J., Lodderstedt, T., and H. Zandbelt, "Encoding Bradley, J., Lodderstedt, T., and H. Zandbelt, "Encoding
claims in the OAuth 2 state parameter using a JWT", draft- claims in the OAuth 2 state parameter using a JWT", draft-
bradley-oauth-jwt-encoded-state-09 (work in progress), bradley-oauth-jwt-encoded-state-09 (work in progress),
November 2018. November 2018.
[I-D.ietf-oauth-closing-redirectors] [I-D.fett-oauth-dpop]
Bradley, J., Sanso, A., and H. Tschofenig, "OAuth 2.0 Fett, D., Campbell, B., Bradley, J., Lodderstedt, T.,
Security: Closing Open Redirectors in OAuth", draft-ietf- Jones, M., and D. Waite, "OAuth 2.0 Demonstration of
oauth-closing-redirectors-00 (work in progress), February Proof-of-Possession at the Application Layer (DPoP)",
2016. draft-fett-oauth-dpop-03 (work in progress), October 2019.
[I-D.ietf-oauth-jwsreq] [I-D.ietf-oauth-jwsreq]
Sakimura, N. and J. Bradley, "The OAuth 2.0 Authorization Sakimura, N. and J. Bradley, "The OAuth 2.0 Authorization
Framework: JWT Secured Authorization Request (JAR)", Framework: JWT Secured Authorization Request (JAR)",
draft-ietf-oauth-jwsreq-19 (work in progress), June 2019. draft-ietf-oauth-jwsreq-20 (work in progress), October
2019.
[I-D.ietf-oauth-mix-up-mitigation]
Jones, M., Bradley, J., and N. Sakimura, "OAuth 2.0 Mix-Up
Mitigation", draft-ietf-oauth-mix-up-mitigation-01 (work
in progress), July 2016.
[I-D.ietf-oauth-mtls] [I-D.ietf-oauth-par]
Campbell, B., Bradley, J., Sakimura, N., and T. Lodderstedt, T., Campbell, B., Sakimura, N., Tonge, D.,
Lodderstedt, "OAuth 2.0 Mutual TLS Client Authentication and F. Skokan, "OAuth 2.0 Pushed Authorization Requests",
and Certificate-Bound Access Tokens", draft-ietf-oauth- draft-ietf-oauth-par-00 (work in progress), December 2019.
mtls-15 (work in progress), July 2019.
[I-D.ietf-oauth-pop-key-distribution] [I-D.ietf-oauth-pop-key-distribution]
Bradley, J., Hunt, P., Jones, M., Tschofenig, H., and M. Bradley, J., Hunt, P., Jones, M., Tschofenig, H., and M.
Meszaros, "OAuth 2.0 Proof-of-Possession: Authorization Meszaros, "OAuth 2.0 Proof-of-Possession: Authorization
Server to Client Key Distribution", draft-ietf-oauth-pop- Server to Client Key Distribution", draft-ietf-oauth-pop-
key-distribution-07 (work in progress), March 2019. key-distribution-07 (work in progress), March 2019.
[I-D.ietf-oauth-rar]
Lodderstedt, T., Richer, J., and B. Campbell, "OAuth 2.0
Rich Authorization Requests", draft-ietf-oauth-rar-00
(work in progress), January 2020.
[I-D.ietf-oauth-resource-indicators] [I-D.ietf-oauth-resource-indicators]
Campbell, B., Bradley, J., and H. Tschofenig, "Resource Campbell, B., Bradley, J., and H. Tschofenig, "Resource
Indicators for OAuth 2.0", draft-ietf-oauth-resource- Indicators for OAuth 2.0", draft-ietf-oauth-resource-
indicators-02 (work in progress), January 2019. indicators-08 (work in progress), September 2019.
[I-D.ietf-oauth-signed-http-request] [I-D.ietf-oauth-signed-http-request]
Richer, J., Bradley, J., and H. Tschofenig, "A Method for Richer, J., Bradley, J., and H. Tschofenig, "A Method for
Signing HTTP Requests for OAuth", draft-ietf-oauth-signed- Signing HTTP Requests for OAuth", draft-ietf-oauth-signed-
http-request-03 (work in progress), August 2016. http-request-03 (work in progress), August 2016.
[I-D.ietf-oauth-token-binding] [I-D.ietf-oauth-token-binding]
Jones, M., Campbell, B., Bradley, J., and W. Denniss, Jones, M., Campbell, B., Bradley, J., and W. Denniss,
"OAuth 2.0 Token Binding", draft-ietf-oauth-token- "OAuth 2.0 Token Binding", draft-ietf-oauth-token-
binding-08 (work in progress), October 2018. binding-08 (work in progress), October 2018.
[I-D.sakimura-oauth-jpop] [I-D.sakimura-oauth-jpop]
Sakimura, N., Li, K., and J. Bradley, "The OAuth 2.0 Sakimura, N., Li, K., and J. Bradley, "The OAuth 2.0
Authorization Framework: JWT Pop Token Usage", draft- Authorization Framework: JWT Pop Token Usage", draft-
sakimura-oauth-jpop-04 (work in progress), March 2017. sakimura-oauth-jpop-05 (work in progress), July 2019.
[oauth_security_cmu] [oauth_security_cmu]
Chen, E., Pei, Y., Chen, S., Tian, Y., Kotcher, R., and P. Chen, E., Pei, Y., Chen, S., Tian, Y., Kotcher, R., and P.
Tague, "OAuth Demystified for Mobile Application Tague, "OAuth Demystified for Mobile Application
Developers", November 2014. Developers", November 2014,
<http://css.csail.mit.edu/6.858/2012/readings/oauth-
sso.pdf>.
[oauth_security_jcs_14] [oauth_security_jcs_14]
Bansal, C., Bhargavan, K., Delignat-Lavaud, A., and S. Bansal, C., Bhargavan, K., Delignat-Lavaud, A., and S.
Maffeis, "Discovering concrete attacks on website Maffeis, "Discovering concrete attacks on website
authorization by formal analysis", April 2014. authorization by formal analysis", April 2014,
<https://www.doc.ic.ac.uk/~maffeis/papers/jcs14.pdf>.
[oauth_security_ubc] [oauth_security_ubc]
Sun, S. and K. Beznosov, "The Devil is in the Sun, S. and K. Beznosov, "The Devil is in the
(Implementation) Details: An Empirical Analysis of OAuth (Implementation) Details: An Empirical Analysis of OAuth
SSO Systems", October 2012, SSO Systems", October 2012,
<http://passwordresearch.com/papers/paper267.html>. <http://passwordresearch.com/papers/paper267.html>.
[owasp] "Open Web Application Security Project Home Page", [owasp_redir]
<https://www.owasp.org/>. "OWASP Cheat Sheet Series - Unvalidated Redirects and
Forwards",
[owasp_csrf] <https://cheatsheetseries.owasp.org/cheatsheets/
"Cross-Site Request Forgery (CSRF) Prevention Cheat Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html>.
Sheet", <https://www.owasp.org/index.php/
Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet>.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997, DOI 10.17487/RFC2119, March 1997,
<https://www.rfc-editor.org/info/rfc2119>. <https://www.rfc-editor.org/info/rfc2119>.
[RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
Protocol (HTTP/1.1): Semantics and Content", RFC 7231,
DOI 10.17487/RFC7231, June 2014,
<https://www.rfc-editor.org/info/rfc7231>.
[RFC7591] Richer, J., Ed., Jones, M., Bradley, J., Machulak, M., and [RFC7591] Richer, J., Ed., Jones, M., Bradley, J., Machulak, M., and
P. Hunt, "OAuth 2.0 Dynamic Client Registration Protocol", P. Hunt, "OAuth 2.0 Dynamic Client Registration Protocol",
RFC 7591, DOI 10.17487/RFC7591, July 2015, RFC 7591, DOI 10.17487/RFC7591, July 2015,
<https://www.rfc-editor.org/info/rfc7591>. <https://www.rfc-editor.org/info/rfc7591>.
[RFC7800] Jones, M., Bradley, J., and H. Tschofenig, "Proof-of- [RFC7800] Jones, M., Bradley, J., and H. Tschofenig, "Proof-of-
Possession Key Semantics for JSON Web Tokens (JWTs)", Possession Key Semantics for JSON Web Tokens (JWTs)",
RFC 7800, DOI 10.17487/RFC7800, April 2016, RFC 7800, DOI 10.17487/RFC7800, April 2016,
<https://www.rfc-editor.org/info/rfc7800>. <https://www.rfc-editor.org/info/rfc7800>.
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
May 2017, <https://www.rfc-editor.org/info/rfc8174>. May 2017, <https://www.rfc-editor.org/info/rfc8174>.
[RFC8414] Jones, M., Sakimura, N., and J. Bradley, "OAuth 2.0
Authorization Server Metadata", RFC 8414,
DOI 10.17487/RFC8414, June 2018,
<https://www.rfc-editor.org/info/rfc8414>.
[RFC8473] Popov, A., Nystroem, M., Balfanz, D., Ed., Harper, N., and [RFC8473] Popov, A., Nystroem, M., Balfanz, D., Ed., Harper, N., and
J. Hodges, "Token Binding over HTTP", RFC 8473, J. Hodges, "Token Binding over HTTP", RFC 8473,
DOI 10.17487/RFC8473, October 2018, DOI 10.17487/RFC8473, October 2018,
<https://www.rfc-editor.org/info/rfc8473>. <https://www.rfc-editor.org/info/rfc8473>.
[subdomaintakeover]
Liu, D., Hao, S., and H. Wang, "All Your DNS Records Point
to Us: Understanding the Security Threats of Dangling DNS
Records", October 2016,
<https://www.eecis.udel.edu/~hnw/paper/ccs16a.pdf>.
[webappsec-referrer-policy] [webappsec-referrer-policy]
Eisinger, J. and E. Stark, "Referrer Policy", April 2017, Eisinger, J. and E. Stark, "Referrer Policy", April 2017,
<https://w3c.github.io/webappsec-referrer-policy>. <https://w3c.github.io/webappsec-referrer-policy>.
[webauthn]
Balfanz, D., Czeskis, A., Hodges, J., Jones, J., Jones,
M., Kumar, A., Liao, A., Lindemann, R., and E. Lundberg,
"Web Authentication: An API for accessing Public Key
Credentials Level 1", March 2019,
<https://www.w3.org/TR/2019/REC-webauthn-1-20190304/>.
[webcrypto]
Watson, M., "Web Cryptography API", January 2017,
<https://www.w3.org/TR/2017/REC-WebCryptoAPI-20170126/>.
Appendix A. Document History Appendix A. Document History
[[ To be removed from the final specification ]] [[ To be removed from the final specification ]]
-15
o Added info about using CSP to prevent clickjacking
-14
o Changes from WGLC feedback
o Editorial changes
o AS MUST announce PKCE support either in metadata or using
deployment-specific ways (before: SHOULD)
-13 -13
o Discourage use of Resource Owner Password Credentials Grant o Discourage use of Resource Owner Password Credentials Grant
o Added text on client impersonating resource owner o Added text on client impersonating resource owner
o Recommend asymmetric methods for client authentication o Recommend asymmetric methods for client authentication
o Encourage use of PKCE mode "S256" o Encourage use of PKCE mode "S256"
skipping to change at page 42, line 46 skipping to change at page 46, line 19
yes.com yes.com
Email: torsten@lodderstedt.net Email: torsten@lodderstedt.net
John Bradley John Bradley
Yubico Yubico
Email: ve7jtb@ve7jtb.com Email: ve7jtb@ve7jtb.com
Andrey Labunets Andrey Labunets
Facebook
Email: isciurus@fb.com Email: isciurus@gmail.com
Daniel Fett Daniel Fett
yes.com yes.com
Email: mail@danielfett.de Email: mail@danielfett.de
 End of changes. 232 change blocks. 
861 lines changed or deleted 1007 lines changed or added

This html diff was produced by rfcdiff 1.47. The latest version is available from http://tools.ietf.org/tools/rfcdiff/