draft-ietf-oauth-security-topics-04.txt   draft-ietf-oauth-security-topics-05.txt 
Open Authentication Protocol T. Lodderstedt, Ed. Open Authentication Protocol T. Lodderstedt, Ed.
Internet-Draft YES.com AG Internet-Draft YES.com AG
Intended status: Best Current Practice J. Bradley Intended status: Best Current Practice J. Bradley
Expires: May 17, 2018 Yubico Expires: September 19, 2018 Yubico
A. Labunets A. Labunets
Facebook Facebook
November 13, 2017 March 18, 2018
OAuth Security Topics OAuth 2.0 Security Best Current Practice
draft-ietf-oauth-security-topics-04 draft-ietf-oauth-security-topics-05
Abstract Abstract
This draft gives a comprehensive overview on open OAuth security This document describes best current security practices for OAuth
topics. It is intended to serve as a working document for the OAuth 2.0.. It updates and extends the OAuth 2.0 Security Threat Model to
working group to systematically capture and discuss these security incorporate practical experiences gathered since OAuth 2.0 was
topics and respective mitigations and eventually recommend best published and cover new threats relevant due to the broader
current practice and also OAuth extensions needed to cope with the application of OAuth 2.0.
respective security threats.
Status of This Memo Status of This Memo
This Internet-Draft is submitted in full conformance with the This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79. provisions of BCP 78 and BCP 79.
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 May 17, 2018. This Internet-Draft will expire on September 19, 2018.
Copyright Notice Copyright Notice
Copyright (c) 2017 IETF Trust and the persons identified as the Copyright (c) 2018 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 . . . . . . . . . . . . . . . . . . . . . . . . 2
2. Best Practices . . . . . . . . . . . . . . . . . . . . . . . 4 2. Recommendations . . . . . . . . . . . . . . . . . . . . . . . 4
2.1. Protecting redirect-based flows . . . . . . . . . . . . . 4 2.1. Protecting redirect-based flows . . . . . . . . . . . . . 4
2.2. Token Leakage Prevention . . . . . . . . . . . . . . . . 5 2.2. Token Replay Prevention . . . . . . . . . . . . . . . . . 5
3. Recommended Changes to OAuth . . . . . . . . . . . . . . . . 5 3. Attacks and Mitigations . . . . . . . . . . . . . . . . . . . 5
4. Attacks and Mitigations . . . . . . . . . . . . . . . . . . . 5 3.1. Insufficient redirect URI validation . . . . . . . . . . 5
4.1. Insufficient redirect URI validation . . . . . . . . . . 5 3.1.1. Attacks on Authorization Code Grant . . . . . . . . . 5
4.1.1. Attacks on Authorization Code Grant . . . . . . . . . 6 3.1.2. Attacks on Implicit Grant . . . . . . . . . . . . . . 6
4.1.2. Attacks on Implicit Grant . . . . . . . . . . . . . . 7 3.1.3. Proposed Countermeasures . . . . . . . . . . . . . . 8
4.1.3. Proposed Countermeasures . . . . . . . . . . . . . . 8 3.2. Authorization code leakage via referrer headers . . . . . 9
4.2. Authorization code leakage via referrer headers . . . . . 9 3.2.1. Proposed Countermeasures . . . . . . . . . . . . . . 9
4.2.1. Proposed Countermeasures . . . . . . . . . . . . . . 10 3.3. Attacks in the Browser . . . . . . . . . . . . . . . . . 10
4.3. Attacks in the Browser . . . . . . . . . . . . . . . . . 10 3.3.1. Code in browser history . . . . . . . . . . . . . . . 10
4.3.1. Code in browser history (TBD) . . . . . . . . . . . . 10 3.3.2. Access token in browser history . . . . . . . . . . . 10
4.3.2. Access token in browser history (TBD) . . . . . . . . 10 3.4. Mix-Up . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.3.3. Javascript Code stealing Access Tokens (TBD) . . . . 11 3.5. Code Injection . . . . . . . . . . . . . . . . . . . . . 11
4.4. Mix-Up . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.5.1. Proposed Countermeasures . . . . . . . . . . . . . . 13
4.5. Code Injection . . . . . . . . . . . . . . . . . . . . . 11 3.6. Cross Site Request Forgery . . . . . . . . . . . . . . . 15
4.5.1. Proposed Countermeasures . . . . . . . . . . . . . . 13 3.7. Access Token Leakage at the Resource Server . . . . . . . 15
4.6. XSRF (TBD) . . . . . . . . . . . . . . . . . . . . . . . 15 3.7.1. Access Token Phishing by Counterfeit Resource Server 15
4.7. Access Token Leakage at the Resource Server . . . . . . . 15 3.7.1.1. Metadata . . . . . . . . . . . . . . . . . . . . 16
4.7.1. Access Token Phishing by Counterfeit Resource Server 15 3.7.1.2. Sender Constrained Access Tokens . . . . . . . . 17
4.7.1.1. Metadata . . . . . . . . . . . . . . . . . . . . 16 3.7.1.3. Audience Restricted Access Tokens . . . . . . . . 19
4.7.1.2. Sender Constrained Access Tokens . . . . . . . . 17 3.7.2. Compromised Resource Server . . . . . . . . . . . . . 20
4.7.1.3. Audience Restricted Access Tokens . . . . . . . . 19 3.8. Open Redirection . . . . . . . . . . . . . . . . . . . . 21
4.7.2. Compromised Resource Server . . . . . . . . . . . . . 20 3.8.1. Authorization Server as Open Redirector . . . . . . . 21
4.8. Refresh Token Leakage (TBD) . . . . . . . . . . . . . . . 21 3.8.2. Clients as Open Redirector . . . . . . . . . . . . . 21
4.9. Open Redirection (TBD) . . . . . . . . . . . . . . . . . 21 3.9. TLS Terminating Reverse Proxies . . . . . . . . . . . . . 22
4.10. TLS Terminating Reverse Proxies . . . . . . . . . . . . . 22 4. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 23
4.11. Other Topics . . . . . . . . . . . . . . . . . . . . . . 22 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 23
5. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 23 6. Security Considerations . . . . . . . . . . . . . . . . . . . 23
6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 23 7. References . . . . . . . . . . . . . . . . . . . . . . . . . 23
7. Security Considerations . . . . . . . . . . . . . . . . . . . 23 7.1. Normative References . . . . . . . . . . . . . . . . . . 23
8. References . . . . . . . . . . . . . . . . . . . . . . . . . 23 7.2. Informative References . . . . . . . . . . . . . . . . . 24
8.1. Normative References . . . . . . . . . . . . . . . . . . 23 Appendix A. Document History . . . . . . . . . . . . . . . . . . 26
8.2. Informative References . . . . . . . . . . . . . . . . . 24 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 27
Appendix A. Document History . . . . . . . . . . . . . . . . . . 25
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 26
1. Introduction 1. Introduction
It's been a while since OAuth has been published in RFC 6749 It's been a while since OAuth has been published in RFC 6749
[RFC6749] and RFC 6750 [RFC6750]. Since publication, OAuth 2.0 has [RFC6749] and RFC 6750 [RFC6750]. Since publication, OAuth 2.0 has
gotten massive traction in the market and became the standard for API gotten massive traction in the market and became the standard for API
protection and, as foundation of OpenID Connect, identity providing. protection and, as foundation of OpenID Connect [OpenID], identity
While OAuth was used in a variety of scenarios and different kinds of providing. While OAuth was used in a variety of scenarios and
deployments, the following challenges could be observed: different kinds of deployments, the following challenges could be
observed:
o OAuth implementations are being attacked through known o OAuth implementations are being attacked through known
implementation weaknesses and anti-patterns (XSRF, referrer implementation weaknesses and anti-patterns (XSRF, referrer
header). Although most of these threats are discussed in RFC 6819 header). Although most of these threats are discussed in the
[RFC6819], continued exploitation demonstrates there may be a need OAuth 2.0 Threat Model and Security Considerations [RFC6819],
for more specific recommendations or that the existing mitigations continued exploitation demonstrates there may be a need for more
are too difficult to deploy. specific recommendations or that the existing mitigations are too
difficult to deploy.
o Technology has changed, e.g. the way browsers treat fragments in o Technology has changed, e.g. the way browsers treat fragments in
some situations, which may change the implicit grant's underlying some situations, which may change the implicit grant's underlying
security model. security model.
o OAuth is used in much more dynamic setups than originally o OAuth is 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 RFC 6749 Those challenges go beyond the original scope of RFC 6749
[RFC6749], RFC 6750 [RFC6749], and RFC 6819 [RFC6819]. [RFC6749], RFC 6750 [RFC6749], and RFC 6819 [RFC6819].
skipping to change at page 3, line 50 skipping to change at page 3, line 46
way the same client could be used to access services of different way the same client could be used to access services of different
providers (in case of standard APIs, such as e-Mail or OpenID providers (in case of standard APIs, such as e-Mail or OpenID
Connect) or serves as a frontend to a particular tenant in a multi- Connect) or serves as a frontend to a particular tenant in a multi-
tenancy. Extensions of OAuth, such as [RFC7591] and tenancy. Extensions of OAuth, such as [RFC7591] and
[I-D.ietf-oauth-discovery] were developed in order to support the [I-D.ietf-oauth-discovery] were developed in order to support the
usage of OAuth in dynamic scenarios. As a challenge to the usage of OAuth in dynamic scenarios. As a challenge to the
community, such usage scenarios open up new attack angles, which are community, such usage scenarios open up new attack angles, which are
discussed in this document. discussed in this document.
The remainder of the document is organized as follows: The next The remainder of the document is organized as follows: The next
section gives a summary of the set of security mechanisms and section summarizes the most important recommendations of the OAuth
practices, the working group shall consider to recommend to OAuth working group for every OAuth implementor. Afterwards, a detailed
implementers. This is followed by a section proposing modifications analyses of the threats and implementation issues, which can be found
to OAuth intended to either simplify its usage and to strengthen its in the wild today, is given along with a discussion of potential
security. counter measures.
The remainder of the draft gives a detailed analyses of the
weaknesses and implementation issues, which can be found in the wild
today, along with a discussion of potential counter measures.
2. Best Practices 2. Recommendations
This section describes the set of security mechanisms the authors This section describes the set of security mechanisms the authors
believe should be taken into consideration by the OAuth working group believe should be taken into consideration by the OAuth working group
to be recommended to OAuth implementers. to be recommended to OAuth implementers.
2.1. Protecting redirect-based flows 2.1. Protecting redirect-based flows
Authorization servers shall utilize exact matching of client redirect Authorization servers shall utilize exact matching of client redirect
URIs against pre-registered URIs. This measure contributes to the URIs against pre-registered URIs. This measure contributes to the
prevention of leakage of authorization codes and access tokens prevention of leakage of authorization codes and access tokens
skipping to change at page 4, line 37 skipping to change at page 4, line 31
layer of defence against token leakage. If there is a need for this layer of defence against token leakage. If there is a need for this
kind of redirects, clients are advised to implement appropriate kind of redirects, clients are advised to implement appropriate
counter measures against open redirection, e.g. as described by the counter measures against open redirection, e.g. as described by the
OWASP [owasp]. OWASP [owasp].
Clients shall ensure to only process redirect responses of the OAuth Clients shall ensure to only process redirect responses of the OAuth
authorization server they send the respective request to and in the authorization server they send the respective request to and in the
same user agent this request was initiated in. In particular, same user agent this request was initiated in. In particular,
clients shall implement appropriate XSRF prevention by utilizing one- clients shall implement appropriate XSRF prevention by utilizing one-
time use XSRF tokens carried in the STATE parameter, which are time use XSRF tokens carried in the STATE parameter, which are
securely bound to the user agent. Moreover, the client shall store securely bound to the user agent. Moreover, the client shall
the authorization server's identity it sends an authorization request memorize which authorization server it sent an authorization request
to in a transaction-specific manner, which is also bound to the to and bind this information to the user agent and ensure any sub-
particular user agent. Furthermore, clients should use AS-specific sequent messages are sent to the same authorization server.
redirect URIs as a means to identify the AS a particular response Furthermore, clients should use AS-specific redirect URIs as a means
came from. Matching this with the before mentioned information to identify the AS a particular response came from. Matching this
regarding the AS the client sent the request to helps to detect mix- with the before mentioned information regarding the AS the client
up attacks. sent the request to helps to detect mix-up attacks.
Note: [I-D.bradley-oauth-jwt-encoded-state] gives advice on how to Note: [I-D.bradley-oauth-jwt-encoded-state] gives advice on how to
implement XSRF prevention and AS matching using signed JWTs in the implement XSRF prevention and AS matching using signed JWTs in the
STATE parameter. STATE parameter.
Clients shall use PKCE [RFC7636] in order to (with the help of the Clients shall use PKCE [RFC7636] in order to (with the help of the
authorization server) detect attempts to inject authorization codes authorization server) detect and prevent attempts to inject (replay)
into the authorization response. The PKCE challenges must be authorization codes into the authorization response. The PKCE
transaction-specific and securely bound to the user agent, in which challenges must be transaction-specific and securely bound to the
the transaction was started. user agent, in which the transaction was started. OpenID Connect
clients may use the "nonce" parameter of the OpenID Connect
authentication request as specified in [OpenID] in conjunction with
the corresponding ID Token claim of the for the same purpose.
Note: although PKCE so far was recommended as mechanism to protect Note: although PKCE so far was recommended as 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.
2.2. Token Leakage Prevention Authorization servers shall consider the recommendations given in
[RFC6819], section 4.4.1.1, on authorization code replay prevention.
2.2. Token Replay Prevention
Authorization servers shall use TLS-based methods for sender Authorization servers shall use TLS-based methods for sender
constraint access tokens as described in section Section 4.7.1.2, constraint access tokens as described in section Section 3.7.1.2,
such as token binding [I-D.ietf-oauth-token-binding] or Mutual TLS such as token binding [I-D.ietf-oauth-token-binding] or Mutual TLS
for OAuth 2.0 [I-D.ietf-oauth-mtls]. It is also recommend to use for OAuth 2.0 [I-D.ietf-oauth-mtls]. It is also recommend to use
end-to-end TLS whenever possible. end-to-end TLS whenever possible.
3. Recommended Changes to OAuth 3. Attacks and Mitigations
This section describes the set of modifications and extensions the
authors believe should be taken into consideration by the OAuth
working group change and extend OAuth in order to strengthen its
security and make it simpler to implement. It also recommends some
changes to the OAuth set of specs.
Remove requirement to check actual redirect URI at token endpoint -
seems to be complicated to implement properly and could be
compromised. The protection goal is achieved even more effective by
utilizing PKCE as recommended in Section 2.1.
4. Attacks and Mitigations
4.1. Insufficient redirect URI validation 3.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. In those cases, the
authorization server, at runtime, matches the actual redirect URI authorization server, at runtime, matches the actual redirect URI
parameter value at the authorization endpoint against this pattern. parameter value at the authorization endpoint against this pattern.
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 just a single
pattern for multiple redirect URIs. As a downside, it turned out to pattern for multiple redirect URIs. As a downside, it turned out to
be more complex to implement and error prone to manage than exact be more complex to implement and error prone to manage than exact
redirect URI matching. Several successful attacks have been observed redirect URI matching. Several successful attacks have been observed
skipping to change at page 6, line 12 skipping to change at page 5, line 46
and client type) and allows the attacker to obtain an authorization and client type) and allows the attacker to obtain an authorization
code or access token, either: 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.
4.1.1. Attacks on Authorization Code Grant 3.1.1. Attacks on Authorization Code Grant
For a public client using the grant type code, an attack would look For a public client using the grant type code, an attack would look
as follows: as follows:
Let's assume the redirect URL pattern "https://*.example.com/*" had Let's assume the redirect URL pattern "https://*.example.com/*" had
been registered for the client "s6BhdRkqt3". This pattern allows been registered for the client "s6BhdRkqt3". This pattern allows
redirect URIs from any host residing in the domain example.com. So redirect URIs from any host residing in the domain example.com. So
if an attacker manager to establish a host or subdomain in if an attacker manages to establish a host or subdomain in
"example.com" he can impersonate the legitimate client. Assume the "example.com" he can impersonate the legitimate client. Assume the
attacker sets up the host "evil.example.com". attacker sets up the host "evil.example.com".
(1) The attacker needs to trick the user into opening a tampered URL (1) The attacker needs to trick the user into opening a tampered URL
in his browser, which launches a page under the attacker's in his browser, which launches a page under the attacker's
control, say "https://www.evil.com". control, say "https://www.evil.com".
(2) This URL initiates an authorization request with the client id (2) This URL initiates an authorization request with the client id
of a legitimate client to the authorization endpoint. This is of a legitimate client to the authorization endpoint. This is
the example authorization request (line breaks are for display the example authorization request (line breaks are for display
skipping to change at page 7, line 8 skipping to change at page 6, line 40
(2) If the user does not recognize the attack, the code is issued (2) If the user does not recognize the attack, the code is issued
and directly sent to the attacker's client. and directly sent to the attacker's client.
(3) Since the attacker impersonated a public client, it can directly (3) Since the attacker impersonated a public client, it can directly
exchange the code for tokens at the respective token endpoint. exchange the code for tokens at the respective token endpoint.
Note: This attack will not directly work for confidential clients, Note: This attack will not directly work for confidential clients,
since the code exchange requires authentication with the legitimate since the code exchange requires authentication with the legitimate
client's secret. The attacker will need to utilize the legitimate client's secret. The attacker will need to utilize the legitimate
client to redeem the code (e.g. by mounting a code injection attack). client to redeem the code (e.g. by performing a code injection
This kind of injections is covered in Section Code Injection. attack). This kind of injections is covered in
Section Code Injection.
4.1.2. Attacks on Implicit Grant 3.1.2. 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
attacks. It utilizes the fact that user agents re-attach fragments attacks. It utilizes the fact that user agents re-attach fragments
to the destination URL of a redirect if the location header does not to 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
skipping to change at page 8, line 30 skipping to change at page 8, line 16
in the Location header, the user agent will re-attach the in the Location header, the user agent will re-attach the
original fragment original fragment
"#access_token=2YotnFZFEjr1zCsicMWpAA&..." to the URL and will "#access_token=2YotnFZFEjr1zCsicMWpAA&..." to the URL and will
navigate to the following URL: navigate to the following URL:
https://client.evil.com/cb#access_token=2YotnFZFEjr1zCsicMWpAA&... https://client.evil.com/cb#access_token=2YotnFZFEjr1zCsicMWpAA&...
(4) The attacker's page at client.evil.com can access the fragment (4) The attacker's page at client.evil.com can access the fragment
and obtain the access token. and obtain the access token.
4.1.3. Proposed Countermeasures 3.1.3. Proposed 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 proposes 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 shall compare the two URIs using simple string comparison as server shall compare the two URIs using simple string comparison as
defined in [RFC3986], Section 6.2.1.. defined in [RFC3986], Section 6.2.1..
This would cause the following impacts: This would cause the following impacts:
skipping to change at page 9, line 30 skipping to change at page 9, line 16
native apps? Effective against impersonation when used in native apps? Effective against impersonation when used in
conjunction with claimed HTTPS redirect URIs only. conjunction with claimed HTTPS redirect URIs only.
For Windows token broker exact redirect URI matching is important For Windows token broker exact redirect URI matching is important
as the redirect URI encodes the app identity. For custom scheme as the redirect URI encodes the app identity. For custom scheme
redirects there is a question however it is probably a useful part redirects there is a question however it is probably a useful part
of defense in depth. of defense in depth.
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 respective section). redirectors (see Section 3.8).
o Clients may drop fragments via intermediary URLs with "fix o Clients may drop fragments via intermediary URLs with "fix
fragments" (e.g. https://developers.facebook.com/blog/post/552/) fragments" (e.g. https://developers.facebook.com/blog/post/552/)
to prevent the user agent from appending any unintended fragments. to prevent the user agent from appending any unintended fragments.
Alternatives to exact redirect URI matching: Alternatives to exact redirect URI matching:
o authenticate client using digital signatures (JAR? o Authenticate clients using digital signatures (see
https://tools.ietf.org/html/draft-ietf-oauth-jwsreq-09) [I-D.ietf-oauth-jwsreq])
4.2. Authorization code leakage via referrer headers 3.2. Authorization code leakage via referrer headers
It is possible authorization codes are unintentionally disclosed to It is possible authorization codes are unintentionally disclosed to
attackers, if a OAuth client renders a page containing links to other attackers, if a OAuth client renders a page containing links to other
pages (ads, faq, ...) as result of a successful authorization pages (ads, faq, ...) as result of a successful authorization
request. request.
If the user clicks onto one of those links and the target is under If the user clicks onto one of those links and the target is under
the control of an attacker, it can get access to the response URL in the control of an attacker, it can get access to the response URL in
the referrer header. the referrer header.
It is also possible that an attacker injects cross-domain content It is also possible that an attacker injects cross-domain content
somehow into the page, such as <img> (f.e. if this is blog web site somehow into the page, such as <img> (e.g if this is a blog web
etc.): the implication is obviously the same - loading this content site). The implication is obviously the same: loading this content
by browser results in leaking referrer with a code. by browser results in leaking referrer with a code.
4.2.1. Proposed Countermeasures 3.2.1. Proposed Countermeasures
There are some means to prevent leakage as described above: There are some means to prevent leakage as described above:
o Use of the HTML link attribute rel="noreferrer" (Chrome o Make authorization codes one-time use. For example, if the
52.0.2743.116, FF 49.0.1, Edge 38.14393.0.0, IE/Win10) legitimate client redeemed and invalidated the code in the above
scenario, the attacker would fail exchanging this code later.
o Use of the "referrer" meta link attribute (possible values e.g. o Bind authorization code to a confidential client or PKCE
noreferrer, origin, ...) (cf. https://w3c.github.io/webappsec- challenge. In this case, the attacker lacks the secret to request
referrer-policy/ - work in progress (seems Google, Chrome and Edge the code exchange.
support it))
o Redirect to intermediate page (sanitize history) before sending o Don't include links to external sites into the page rendered as
user agent to other pages result of a OAuth authorization response
Note: double check redirect/referrer header behavior
o Use form post mode instead of redirect for authorization response o Use of the HTML link attribute rel="noreferrer" to suppress
(don't transport credentials via URL parameters and GET) referrer header
Note: There shouldn't be a referer header when loading HTTP content o Use of the "referrer" meta link attribute to suppress referrer
from a HTTPS -loaded page (e.g. help/faq pages) header (see [webappsec-referrer-policy])
Note: This kind of attack is not applicable to the implicit grant o Use form post response mode instead of redirect for authorization
since fragments are not be included in referrer headers (cf. response (see [oauth-v2-form-post-response-mode])
https://tools.ietf.org/html/rfc7231#section-5.5.2)
4.3. Attacks in the Browser 3.3. Attacks in the Browser
4.3.1. Code in browser history (TBD) 3.3.1. Code in browser history
When browser navigates to "client.com/redirection_endpoint?code=abcd" When a browser navigates to "client.com/
as a result of a redirect from a provider's authorization endpoint. redirection_endpoint?code=abcd" as a result of a redirect from a
provider's authorization endpoint, the URL including the
authorization code may end up in the browser's history. An attacker
with access to the device could obtain the code and try to replay it.
Proposed countermeasures: code is one time use, has limited duration, Proposed countermeasures:
is bound to client id/secret (confidential clients only)
4.3.2. Access token in browser history (TBD) o Authorization code replay prevention as described in [RFC6819],
section 4.4.1.1, and Section 3.5
When a client or just a web site which already has a token o Use form post response mode instead of redirect for authorization
deliberately navigates to a page like provider.com/ response (see [oauth-v2-form-post-response-mode])
get_user_profile?access_token=abcdef.. Actually RFC6750 discourages
this practice and asks to transfer tokens via a header, but in
practice web sites often just pass access token in query
When browser navigates to client.com/
redirection_endpoint#access_token=abcef as a result of a redirect
from a provider's authorization endpoint.
Proposal: replace implicit flow with postmessage communication 3.3.2. Access token in browser history
4.3.3. Javascript Code stealing Access Tokens (TBD) An access token may end up in the browser history if a a client or
just a web site, which already has a token, deliberately navigates to
a page like "provider.com/get_user_profile?access_token=abcdef.".
Actually [RFC6750]discourages this practice and asks to transfer
tokens via a header, but in practice web sites often just pass access
token in query parameters.
sandboxing using service workers In case of implicit grant, a URL like "client.com/
redirection_endpoint#access_token=abcdef" may also end up in the
browser history as a result of a redirect from a provider's
authorization endpoint.
4.4. Mix-Up Proposed countermeasures:
o Replace implicit flow with postmessage communication or the
authorization code grant
o Never pass access tokens in URL query parameters
3.4. Mix-Up
Mix-up is another kind of attack on more dynamic OAuth scenarios (or Mix-up is another kind of attack on more dynamic OAuth scenarios (or
at least scenarios where a OAuth client interacts with multiple at least scenarios where a OAuth client interacts with multiple
authorization servers). The goal of the attack is to obtain an authorization servers). The goal of the attack is to obtain an
authorization code or an access token by tricking the client into authorization code or an access token by tricking the client into
sending those credentials to the attacker (which acts as MITM between sending those credentials to the attacker (which acts as MITM between
client and authorization server) client and authorization server)
A detailed description of the attack and potential countermeasures is A detailed description of the attack and potential countermeasures is
given in cf. https://tools.ietf.org/html/draft-ietf-oauth-mix-up- given in [I-D.ietf-oauth-mix-up-mitigation].
mitigation-01.
Potential mitigations: Potential mitigations:
o Clients use AS-specific redirect URIs and, for every authorization
request, store intended AS and compare intention with actual
redirect URI where the response was received
o AS returns client_id and its iss in the response. Client compares o AS returns client_id and its iss in the response. Client compares
this data to AS it believed it sent the user agent to. this data to AS it believed it sent the user agent to.
o ID token carries client id and issuer (requires OpenID Connect) o ID token carries client id and issuer (OpenID Connect specific)
o Clients use AS-specific redirect URIs, for every authorization
request store intended AS and compare intention with actual
redirect URI where the response was received (no change to OAuth
required)
4.5. Code Injection 3.5. Code Injection
In such an attack, the adversary attempts to inject a stolen In such an attack, the adversary attempts to inject a stolen
authorization code into a legitimate client on a device under his authorization code into a legitimate client on a device under his
control. In the simplest case, the attacker would want to use the control. In the simplest case, the attacker would want to use the
code in his own client. But there are situations where this might code in his own client. But there are situations where this might
not be possible or intended. Example are: not be possible or intended. Examples are:
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 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 and/or redeem the code himself.
o The attacker wants to access certain functions in this particular
client. As an example, the attacker potentially wants to
impersonate his victim in a certain app.
o Another example could be that access to the authorization and o The authorization or resource servers are limited to certain
resource servers is some how limited to networks, the attackers is networks, the attackers is unable to access directly.
unable to access directly.
How does an attack look like? How does an attack look like?
(1) The attacker obtains an authorization code by executing any of (1) The attacker obtains an authorization code by performing any of
the attacks described above. the attacks described above.
(2) It performs an OAuth authorization process with the legitimate (2) It performs a regular OAuth authorization process with the
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.
(4) The client sends the code to the authorization server's token (4) The client sends the code to the authorization server's token
endpoint, along with client id, client secret and actual endpoint, along with client id, client secret and actual
redirect_uri. 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. redirect URI matches the redirect_uri parameter (see [RFC6749]).
(6) If all checks succeed, the authorization server issues access (6) If all checks succeed, the authorization server issues access
and other tokens to the client. and other tokens to the client, so now the attacker is able to
impersonate the legitimate user.
(7) The attacker just impersonated the victim.
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. another client id, e.g. a client set up by the attacker. The check
will also fail if the authorization code was already redeemed by the
legitimate user and was one-time use only.
An attempt to inject a code obtained via a malware pretending to be An attempt to inject a code obtained via a malware pretending to be
the legitimate client should also be detected, if the authorization the legitimate client should also be detected, if the authorization
server stored the complete redirect URI used in the authorization server stored the complete redirect URI used in the authorization
request and compares it with the redirect_uri parameter. request and compares 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 attempt to inject a code, which Note: this check could also detect attempt to inject a code, which
had been obtained from another instance of the same client on another had been obtained from another instance of the same client on another
device, if certain conditions are fulfilled: device, if certain conditions are fulfilled:
skipping to change at page 13, line 41 skipping to change at page 13, line 35
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 memorize or re-construct the correct redirect URI for the
call to the tokens endpoint. call to the tokens endpoint.
The authors therefore propose to the working group to drop this The authors therefore propose to the working group to drop this
feature in favor of more effective and (hopefully) simpler approaches feature in favor of more effective and (hopefully) simpler approaches
to code injection prevention as described in the following section. to code injection prevention as described in the following section.
4.5.1. Proposed Countermeasures 3.5.1. Proposed Countermeasures
The general proposal is to bind every particular authorization code The general proposal is to bind every authorization code to a certain
to a certain client on a certain device (or in a certain user agent) client instance on a certain device (or in a certain user agent) in
in the context of a certain transaction. There are multiple the context of a certain transaction. There are multiple technical
technical solutions to achieve this goal: solutions to achieve this goal:
Nonce OpenID Connect's existing "nonce" parameter is used for this Nonce OpenID Connect's existing "nonce" parameter could be used for
purpose. The nonce value is one time use and created by the this purpose. The nonce value is one-time use and created by
client. The client is supposed to bind it to the user agent the client. The client is supposed to bind it to the user
session and sends it with the initial request to the OpenId agent session and sends it with the initial request to the
Provider (OP). The OP associates the nonce to the OpenId Provider (OP). The OP associates the nonce to the
authorization code and attests this binding in the ID token, authorization code and attests this binding in the ID token,
which is issued as part of the code exchange at the token which is issued as part of the code exchange at the token
endpoint. If an attacker injected an authorization code in endpoint. If an attacker injected an authorization code in
the authorization response, the nonce value in the client the authorization response, the nonce value in the client
session and the nonce value in the ID token will not match session and the nonce value in the ID token will not match
and the attack is detected. assumption: attacker cannot get and the attack is detected. assumption: attacker cannot get
hold of the user agent state on the victims device, where he hold of the user agent state on the victims device, where he
has stolen the respective authorization code. has stolen the respective authorization code. The main
pro: advantage of this option is that Nonce is an existing feature
- existing feature, used in the wild used in the wild. On the other hand, leveraging Nonce by the
con: broader OAuth community would require AS and client to adopt
- OAuth does not have an ID Token - would need to push that ID Tokens.
down the stack
Code-bound State It has been discussed in the security workshop in Code-bound State The "state" parameter as specified in [RFC6749]
December to use the OAuth state value much similar in the way could be used similarly to the way as described above. This
as described above. In the case of the state value, the idea would require to add a further parameter "state" to the code
is to add a further parameter state to the code exchange exchange token endpoint request. The authorization server
request. The authorization server then compares the state would then compares the state value it associated with the
value it associated with the code and the state value in the code and the state value in the parameter. If those values
parameter. If those values do not match, it is considered an do not match, it is considered an attack and the request
attack and the request fails. Note: a variant of this fails. The advantage of this approach would be to utilize an
solution would be send a hash of the state (in order to existing OAuth parameter. But it would also mean to re-
prevent bulky requests and DoS). interpret the purpose of state and to extend the token
pro: endpoint request.
- use existing concept
con:
- state needs to fulfil certain requirements (one time use,
complexity)
- new parameter means normative spec change
PKCE Basically, the PKCE challenge/verifier could be used in the PKCE The PKCE parameter "challenge" along with the corresponding
same way as Nonce or State. In contrast to its original "verifier" as specified in [RFC7636] could be used in the
same way as "nonce" or "state". In contrast to its original
intention, the verifier check would fail although the client intention, the verifier check would fail although the client
uses its correct verifier but the code is associated with a uses its correct verifier but the code is associated with a
challenge, which does not match. challenge, which does not match. PKCE is a deployed OAuth
pro: feature, even so it is today used to secure native apps,
- existing and deployed OAuth feature only.
con:
- currently used and recommended for native apps, not web
apps
Token Binding Code must be bind to UA-AS and UA-Client legs - Token Binding Token binding [I-D.ietf-oauth-token-binding] could
requires further data (extension to response) to manifest also be used. In this case, the code would need to be bound
binding id for particular code. to two legs, between user agent and AS and the user agent and
the client. This requires further data (extension to
response) to manifest binding id for particular code. Token
binding is promising as a secure and convenient mechanism
(due to its browser integration). As a challenge, it
requires broad browser support and use with native apps still
under discussion.
Note: token binding could be used in conjunction with PKCE as per instance client id/secret One could use per instance client_id
an option (https://tools.ietf.org/html/draft-ietf-oauth- and secrets and bind the code to the respective client_id.
token-binding-02#section-4). Unfortunately, this does not fit into the web application
pro: programming model (would need to use per user client ids).
- highly secure
con:
- highly sophisticated, requires browser support, will it
work for native apps?
per instance client id/secret ... PKCE seem to be the most obvious solution for OAuth clients as it
available and effectively used today for similar purposes for OAuth
native apps whereas "nonce" is appropriate for OpenId Connect
clients.
Note on pre-warmed secrets: An attacker can circumvent the Note on pre-warmed secrets: An attacker can circumvent the
countermeasures described above if he is able to create or capture countermeasures described above if he is able to create or capture
the respective secret or code_challenge on a device under his the respective secret or code_challenge on a device under his
control, which is then used in the victim's authorization request. control, which is then used in the victim's authorization request.
Exact redirect URI matching of authorization requests can prevent the Exact redirect URI matching of authorization requests can prevent the
attacker from using the pre-warmed secret in the faked authorization attacker from using the pre-warmed secret in the faked authorization
transaction on the victim's device. transaction on the victim's device.
Unfortunately it does not work for all kinds of OAuth clients. It is Unfortunately it does not work for all kinds of OAuth clients. It is
effective for web and JS apps and for native apps with claimed URLs. effective for web and JS apps and for native apps with claimed URLs.
What about other native apps? Treat nonce or PKCE challenge as Attacks on native apps using custom schemes or redirect URIs on
replay detection tokens (needs to ensure cluster-wide one-time use)? localhost cannot be prevented this way, except if the AS enforces
one-time use for PKCE verifier or Nonce values.
4.6. XSRF (TBD) 3.6. Cross Site Request Forgery
injection of code or access token on a victim's device (e.g. to cause An attacker might attempt to inject a request to the redirect URI of
client to access resources under the attacker's control) the legitimate client on the victim's device, e.g. to cause the
client to access resources under the attacker's control.
mitigation: XSRF tokens (one time use) w/ user agent binding (cf. Proposed mitigation: use of XSRF tokens (one-time use), which are
https://www.owasp.org/index.php/ bound to the user agent and passed in the state parameter to the
CrossSite_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet) authorization server. For more details see [owasp_csrf].
4.7. Access Token Leakage at the Resource Server 3.7. Access Token Leakage at the Resource Server
4.7.1. Access Token Phishing by Counterfeit Resource Server 3.7.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, which are valid for other resource sending access tokens to it, which are valid for other resource
servers. If the client sends a valid access token to this servers. If the client sends a valid access token to this
counterfeit resource server, the attacker in turn may use that token counterfeit resource server, the attacker in turn may use that token
to access other services on behalf of the resource owner. to access other services on behalf of the resource owner.
This attack assumes the client is not bound to a certain resource This attack assumes the client is not bound to a certain resource
server (and the respective URL) at development time, but client server (and the respective URL) at development time, but client
instances are configured with an resource server's URL at runtime. instances are configured with an resource server's URL at runtime.
This kind of late binding is typical in situations, where the client This kind of late binding is typical in situations, where the client
uses a standard API, e.g. for e-Mail, calendar, health, or banking uses a standard API, e.g. for e-Mail, calendar, health, or banking
and is configured by an user or administrator for the standard-based and is configured by an user or administrator for the standard-based
service, this particular user or company uses. service, this particular user or company uses.
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.7.1.1. Metadata 3.7.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 metadata parameter "resource_servers":
HTTP/1.1 200 OK HTTP/1.1 200 OK
skipping to change at page 17, line 6 skipping to change at page 16, line 49
"access_token_resource_server":"https://hostedresource.example.com/path1", "access_token_resource_server":"https://hostedresource.example.com/path1",
... ...
} }
This mitigation strategy would rely on the client to enforce the This mitigation strategy would rely on the client to enforce the
security policy and to only send access tokens to legitimate security policy and to only send access tokens to legitimate
destinations. Results of OAuth related security research (see for destinations. Results of OAuth related security research (see for
example [oauth_security_ubc] and [oauth_security_cmu]) indicate a example [oauth_security_ubc] and [oauth_security_cmu]) indicate a
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 detect and properly handle access token phishing is likely clients to prevent access token phishing is likely to fail as well.
to fail as well. Moreover given the ratio of clients to Moreover given the ratio of clients to authorization and resource
authorization and resource servers, it is considered the more viable servers, it is considered the more viable approach to move as much as
approach to move as much as possible security-related logic to those possible security-related logic to those entities. Clearly, the
entities. Clearly, the client has to contribute to the overall client has to contribute to the overall security. But there are
security. But there are alternative counter measures, as described alternative counter measures, as described in the next sections,
in the next sections, which provide a better balance between the which provide a better balance between the involved parties.
involved parties.
4.7.1.2. Sender Constrained Access Tokens 3.7.1.2. Sender Constrained Access Tokens
As the name suggests, sender constraint access token scope the As the name suggests, sender constraint 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 bind this particular token to a certain client. The which bind this particular token to a certain client. The
skipping to change at page 17, line 43 skipping to change at page 17, line 36
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 happens during the setup of a TLS case it might automatically happens 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, it may utilize
capabilities of the transport layer (e.g. TLS). Note: replay capabilities of the transport layer (e.g. TLS). Note: replay
detection is required as well! prevention is required as well!
There exists several proposals to demonstrate the proof of possession There exists 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 [I-D.ietf-oauth-token-binding]: In this approach, an access tokens o [I-D.ietf-oauth-token-binding]: In this approach, an access tokens
is, via the so-called token binding id, bound to key material is, via the so-called token binding id, bound to key material
representing a long term association between a client and a representing a long term association between a client and a
certain TLS host. Negotiation of the key material and proof of certain TLS host. Negotiation of the key material and proof of
possession in the context of a TLS handshake is taken care of by 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 the TLS stack. The client needs to determine the token binding id
skipping to change at page 18, line 35 skipping to change at page 18, line 28
fingerprint with the respective access tokens. The resource fingerprint with the respective access tokens. The resource
server in the same way obtains the public key from the TLS stack server in the same way obtains the public key from the TLS stack
and compares its fingerprint with the fingerprint associated with and compares its fingerprint with the fingerprint associated with
the access token. the access token.
o [I-D.ietf-oauth-signed-http-request] specifies an approach to sign o [I-D.ietf-oauth-signed-http-request] specifies an approach to sign
HTTP requests. It utilizes [I-D.ietf-oauth-pop-key-distribution] HTTP requests. It utilizes [I-D.ietf-oauth-pop-key-distribution]
and represents the elements of the signature in a JSON object. and represents the elements of the signature in a JSON object.
The signature is built using JWS. The mechanism has built-in The signature is built using JWS. The mechanism has built-in
support for signing of HTTP method, query parameters and headers. support for signing of HTTP method, query parameters and headers.
It also incorporates a timestamp as basis for replay detection. It also incorporates a timestamp as basis for replay prevention.
o [I-D.sakimura-oauth-jpop]: this draft describes different ways to o [I-D.sakimura-oauth-jpop]: this draft describes different ways to
constrain access token usage, namely TLS or request signing. constrain access token usage, namely TLS or request signing.
Note: Since the authors of this draft contributed the TLS-related Note: Since the authors of this draft contributed the TLS-related
proposal to [I-D.ietf-oauth-mtls], this document only considers proposal to [I-D.ietf-oauth-mtls], this document only considers
the request signing part. For request signing, the draft utilizes the request signing part. For request signing, the draft utilizes
[I-D.ietf-oauth-pop-key-distribution] and RFC 7800 [RFC7800]. The [I-D.ietf-oauth-pop-key-distribution] and RFC 7800 [RFC7800]. The
signature data is represented in a JWT and JWS is used for signature data is represented in a JWT and JWS is used for
signing. Replay detection is provided by building the signature signing. Replay prevention is provided by building the signature
over a server-provided nonce, client-provided nonce and a nonce over a server-provided nonce, client-provided nonce and a nonce
counter. counter.
[I-D.ietf-oauth-mtls] and [I-D.ietf-oauth-token-binding] are built on [I-D.ietf-oauth-mtls] and [I-D.ietf-oauth-token-binding] are built on
top of TLS and this way continue the successful OAuth 2.0 philosophy top of TLS and this way continue the successful OAuth 2.0 philosophy
to leverage TLS to secure OAuth wherever possible. Both mechanisms to leverage TLS to secure OAuth wherever possible. Both mechanisms
allow prevention of access token leakage in a fairly client developer allow prevention of access token leakage in a fairly client developer
friendly way. friendly way.
There are some differences between both approaches: To start with, in There are some differences between both approaches: To start with, in
skipping to change at page 19, line 29 skipping to change at page 19, line 21
Application level signing approaches, like Application level signing approaches, like
[I-D.ietf-oauth-signed-http-request] and [I-D.sakimura-oauth-jpop] [I-D.ietf-oauth-signed-http-request] and [I-D.sakimura-oauth-jpop]
have been debated for a long time in the OAuth working group without have been debated for a long time in the OAuth working group without
a clear outcome. a clear outcome.
As one advantage, application-level signing allows for end-to-end As one advantage, application-level signing allows for end-to-end
protection including non-repudiation even if the TLS connection is protection including non-repudiation even if the TLS connection is
terminated between client and resource server. But deployment terminated between client and resource server. But deployment
experiences have revealed challenges regarding robustness (e.g. experiences have revealed challenges regarding robustness (e.g.
reproduction of the signature base string including correct URL) as reproduction of the signature base string including correct URL) as
well as state management (e.g. replay detection). well as state management (e.g. replay prevention).
This document therefore recommends implementors to consider one of This document therefore recommends implementors to consider one of
TLS-based approaches wherever possible. TLS-based approaches wherever possible.
4.7.1.3. Audience Restricted Access Tokens 3.7.1.3. Audience Restricted Access Tokens
An audience restriction essentially restricts the resource server a An audience restriction essentially restricts the resource server a
particular access token can be used at. The authorization server particular access token can be used at. The authorization server
associates the access token with a certain resource server and every associates the access token with a certain resource server and every
resource server is obliged to verify for every request, whether the resource server is obliged to verify for every request, whether the
access token send with that request was meant to be used at the access token send with that request was meant to be used at the
particular resource server. If not, the resource server must refuse particular resource server. If not, the resource server must refuse
to serve the respective request. In the general case, audience to serve the respective request. In the general case, audience
restrictions limit the impact of a token leakage. In the case of a restrictions limit the impact of a token leakage. In the case of a
counterfeit resource server, it may (as described see below) also counterfeit resource server, it may (as described see below) also
prevent abuse of the phished access token at the legitimate resource prevent abuse of the phished access token at the legitimate resource
server. server.
The audience can basically be expressed using logical names or The audience can basically be expressed using logical names or
physical addresses (like URLs). In order to detect phishing, it is physical addresses (like URLs). In order to prevent phishing, it is
necessary to use the actual URL the client will send requests to. In necessary to use the actual URL the client will send requests to. In
the phishing case, this URL will point to the counterfeit resource the 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.
skipping to change at page 20, line 43 skipping to change at page 20, line 35
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.7.2. Compromised Resource Server 3.7.2. Compromised Resource Server
An attacker may compromise a resource server in order to get access An attacker may compromise a resource server in order to get access
to its resources and other resources of the respective deployment. to its resources and other resources of the respective deployment.
Such a compromise may range from partial access to the system, e.g. Such a compromise may range from partial access to the system, e.g.
its logfiles, to full control of the respective server. its logfiles, to full control of the respective server.
If the attacker was able to take over full control including shell 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 access it will be able to circumvent all controls in place and access
resources without access control. It will also get access to access resources without access control. It will also get access to access
tokens, which are sent to the compromised system and which tokens, which are sent to the compromised system and which
potentially are valid for access to other resource servers as well. potentially are valid for access to other resource servers as well.
Even if the attacker "only" is able to access logfiles or databases Even if the attacker "only" is able to access logfiles or databases
of the server system, it may get access to valid access tokens. of the server system, it may get access to valid access tokens.
Preventing and detecting server breaches by way of hardening and Preventing server breaches by way of hardening and monitoring server
monitoring server systems is considered a standard operational systems is considered a standard operational procedure and therefore
procedure and therefore out of scope of this document. This section out of scope of this document. This section will focus on the impact
will focus on the impact of such breaches on OAuth-related parts of of such breaches on OAuth-related parts of the ecosystem, which is
the ecosystem, which is the replay of captured access tokens on the the replay of captured access tokens on the compromised resource
compromised resource server and other resource servers of the server and other resource servers of the respective deployment.
respective deployment.
The following measures shall be taken into account by implementors in The following measures shall be taken into account by implementors in
order to cope with access token replay: order to cope with access token replay:
o The resource server must treat access tokens like any other o The resource server must treat access tokens like any other
credentials. It is considered good practice to not log them and credentials. It is considered good practice to not log them and
not to store them in plain text. not to store them in plain text.
o Sender constraint access tokens as described in Section 4.7.1.2 o Sender constraint access tokens as described in Section 3.7.1.2
will prevent the attacker from replaying the access tokens on will prevent the attacker from replaying the access tokens on
other resource servers. Depending on the severity of the other resource servers. Depending on the severity of the
penetration, it will also prevent replay on the compromised penetration, it will also prevent replay on the compromised
system. system.
o Audience restriction as described in Section 4.7.1.3 may be used o Audience restriction as described in Section 3.7.1.3 may be used
to prevent replay of captured access tokens on other resource to prevent replay of captured access tokens on other resource
servers. servers.
4.8. Refresh Token Leakage (TBD) 3.8. Open Redirection
mitm, log files on the device, ... 3.8.1. Authorization Server as Open Redirector
refresh token rotation, mutual TLS authentication at the token Attackers could try to utilize a user's trust in the authorization
endpoint server (and its URL in particular) for performing phishing attacks.
The attacker could send an authorization request with an invalid
combination of client_id and redirect_uri. [RFC6749], section
4.1.2.1, already states that the AS MUST NOT automatically redirect
the user agent in this case to prevent open redirection.
4.9. Open Redirection (TBD) But as described in [I-D.ietf-oauth-closing-redirectors], the
attacker could also attempt to register a client and intentionally
send an erroneous authorization request, e.g. by using an invalid
scope value. According to [RFC6749], the AS would send the user
agent to the redirect_uri with an "invalid_request" error response.
This is dangerous because the authorization server would serve as an
open redirector. Therefore this draft recommends that every invalid
authorization request MUST NOT automatically redirect the user agent
to the client's redirect URI.
Using the AS as Open Redirector - error handling AS (redirects) 3.8.2. Clients as Open Redirector
(draft-ietf-oauth-closing-redirectors-00)
Using the Client as Open Redirector Client MUST not expose URLs which could be utilized as open
redirector. An open redirector is a way to cause the recipient of a
HTTP request to issue a redirect to a target URL that is passed as a
parameter. Attackers may utilize such a mechanism to produce URLs,
which appear to point to the client, which might trick users to trust
the URL and follow it in her browser. Another abuse case is to
produce URLs pointing to the client and utilize them to impersonate a
client with an authorization server.
4.10. TLS Terminating Reverse Proxies In order to prevent open redirection, clients should only expose such
a function, if the target URLs are whitelisted or if the origin of a
request can be authenticated.
3.9. TLS Terminating Reverse Proxies
A common deployment architecture for HTTP applications is to have the A common deployment architecture for HTTP applications is to have the
application server sitting behind a reverse proxy, which terminates application server sitting behind a reverse proxy, which terminates
the TLS connection and dispatches the incoming requests to the the TLS connection and dispatches the incoming requests to the
respective application server nodes. respective 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 give recommendations architecture, which are relevant to OAuth, and give recommendations
for security controls. for security controls.
skipping to change at page 22, line 42 skipping to change at page 23, line 5
application servers. application servers.
If an attacker would be able to get access to the internal network If an attacker would be able to get access to the internal network
between proxy and application server, it could also try to circumvent between proxy and application server, it could also try to circumvent
security controls in place. It is therefore important to ensure the security controls in place. It is therefore important to ensure the
authenticity of the communicating entities. Furthermore, the authenticity of the communicating entities. Furthermore, the
communication link between reverse proxy and application server must communication link between reverse proxy and application server must
therefore be protected against tapping and injection (including therefore be protected against tapping and injection (including
replay prevention). replay prevention).
4.11. Other Topics 4. Acknowledgements
o redirect via status code 307 - use 302
o why to rotate refresh tokens
o how to support multi AS per RS
o differentiate native, JS and web clients
o do not put sensitive data in URL/GET parameters (Jim Manico)
o Incorporate Christian Mainka's feedback
o WPAD attack - https://www.blackhat.com/docs/us-16/materials/us-16-
Kotler-Crippling-HTTPS-With-Unholy-PAC.pdf
5. Acknowledgements
We would like to thank Jim Manico, Phil Hunt, and Brian Campbell for We would like to thank Jim Manico, Phil Hunt, Nat Sakimura, Christian
their valuable feedback. Mainka, and Brian Campbell for their valuable feedback.
6. IANA Considerations 5. IANA Considerations
This draft includes no request to IANA. This draft includes no request to IANA.
7. Security Considerations 6. 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 7. References
8.1. Normative References 7.1. Normative References
[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>.
[RFC6749] Hardt, D., Ed., "The OAuth 2.0 Authorization Framework", [RFC6749] Hardt, D., Ed., "The OAuth 2.0 Authorization Framework",
RFC 6749, DOI 10.17487/RFC6749, October 2012, RFC 6749, DOI 10.17487/RFC6749, October 2012,
<https://www.rfc-editor.org/info/rfc6749>. <https://www.rfc-editor.org/info/rfc6749>.
skipping to change at page 24, line 10 skipping to change at page 24, line 5
[RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
Protocol (HTTP/1.1): Semantics and Content", RFC 7231, Protocol (HTTP/1.1): Semantics and Content", RFC 7231,
DOI 10.17487/RFC7231, June 2014, DOI 10.17487/RFC7231, June 2014,
<https://www.rfc-editor.org/info/rfc7231>. <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>.
8.2. Informative References 7.2. Informative References
[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-07 (work in progress), bradley-oauth-jwt-encoded-state-08 (work in progress),
March 2017. January 2018.
[I-D.campbell-oauth-resource-indicators] [I-D.campbell-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-campbell-oauth-resource- Indicators for OAuth 2.0", draft-campbell-oauth-resource-
indicators-02 (work in progress), November 2016. indicators-02 (work in progress), November 2016.
[I-D.ietf-oauth-closing-redirectors]
Bradley, J., Sanso, A., and H. Tschofenig, "OAuth 2.0
Security: Closing Open Redirectors in OAuth", draft-ietf-
oauth-closing-redirectors-00 (work in progress), February
2016.
[I-D.ietf-oauth-discovery] [I-D.ietf-oauth-discovery]
Jones, M., Sakimura, N., and J. Bradley, "OAuth 2.0 Jones, M., Sakimura, N., and J. Bradley, "OAuth 2.0
Authorization Server Metadata", draft-ietf-oauth- Authorization Server Metadata", draft-ietf-oauth-
discovery-07 (work in progress), September 2017. discovery-10 (work in progress), March 2018.
[I-D.ietf-oauth-jwsreq]
Sakimura, N. and J. Bradley, "The OAuth 2.0 Authorization
Framework: JWT Secured Authorization Request (JAR)",
draft-ietf-oauth-jwsreq-15 (work in progress), July 2017.
[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-mtls]
Campbell, B., Bradley, J., Sakimura, N., and T. Campbell, B., Bradley, J., Sakimura, N., and T.
Lodderstedt, "Mutual TLS Profile for OAuth 2.0", draft- Lodderstedt, "OAuth 2.0 Mutual TLS Client Authentication
ietf-oauth-mtls-05 (work in progress), November 2017. and Certificate Bound Access Tokens", draft-ietf-oauth-
mtls-07 (work in progress), January 2018.
[I-D.ietf-oauth-pop-key-distribution] [I-D.ietf-oauth-pop-key-distribution]
Bradley, J., Hunt, P., Jones, M., and H. Tschofenig, Bradley, J., Hunt, P., Jones, M., and H. Tschofenig,
"OAuth 2.0 Proof-of-Possession: Authorization Server to "OAuth 2.0 Proof-of-Possession: Authorization Server to
Client Key Distribution", draft-ietf-oauth-pop-key- Client Key Distribution", draft-ietf-oauth-pop-key-
distribution-03 (work in progress), February 2017. distribution-03 (work in progress), February 2017.
[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-05 (work in progress), October 2017. binding-06 (work in progress), March 2018.
[I-D.ietf-tokbind-https] [I-D.ietf-tokbind-https]
Popov, A., Nystrom, M., Balfanz, D., Langley, A., Harper, Popov, A., Nystrom, M., Balfanz, D., Langley, A., Harper,
N., and J. Hodges, "Token Binding over HTTP", draft-ietf- N., and J. Hodges, "Token Binding over HTTP", draft-ietf-
tokbind-https-10 (work in progress), July 2017. tokbind-https-12 (work in progress), January 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-04 (work in progress), March 2017.
[oauth-v2-form-post-response-mode]
Microsoft and Ping Identity, "OAuth 2.0 Form Post Response
Mode", April 2015, <http://openid.net/specs/
oauth-v2-form-post-response-mode-1_0.html>.
[oauth_security_cmu] [oauth_security_cmu]
Carnegie Mellon University, Carnegie Mellon University, Carnegie Mellon University, Carnegie Mellon University,
Microsoft Research, Carnegie Mellon University, Carnegie Microsoft Research, Carnegie Mellon University, Carnegie
Mellon University, and Carnegie Mellon University, "OAuth Mellon University, and Carnegie Mellon University, "OAuth
Demystified for Mobile Application Developers", November Demystified for Mobile Application Developers", November
2014. 2014.
[oauth_security_ubc] [oauth_security_ubc]
University of British Columbia and University of British University of British Columbia and University of British
Columbia, "The Devil is in the (Implementation) Details: Columbia, "The Devil is in the (Implementation) Details:
An Empirical Analysis of OAuth SSO Systems", October 2012, An Empirical Analysis of OAuth SSO Systems", October 2012,
<http://passwordresearch.com/papers/paper267.html>. <http://passwordresearch.com/papers/paper267.html>.
[OpenID] NRI, Ping Identity, Microsoft, Google, and Salesforce,
"OpenID Connect Core 1.0 incorporating errata set 1", Nov
2014,
<http://openid.net/specs/openid-connect-core-1_0.html>.
[owasp] "Open Web Application Security Project Home Page", [owasp] "Open Web Application Security Project Home Page",
<https://www.owasp.org/>. <https://www.owasp.org/>.
[owasp_csrf]
"Cross-Site Request Forgery (CSRF) Prevention Cheat
Sheet", <https://www.owasp.org/index.php/
Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet>.
[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>.
[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>.
[webappsec-referrer-policy]
Google Inc. and Google Inc., "Referrer Policy", April
2017, <https://w3c.github.io/webappsec-referrer-policy>.
Appendix A. Document History Appendix A. Document History
[[ To be removed from the final specification ]] [[ To be removed from the final specification ]]
-05
o Completed sections on code leakage via referrer header, attacks in
browser, mix-up, and CSRF
o Reworked Code Injection Section
o Added reference to OpenID Connect spec
o removed refresh token leakage as respective considerations have
been given in section 10.4 of RFC 6749
o first version on open redirection
o incorporated Christian Mainka's review feedback
-04 -04
o Restructured document for better readability o Restructured document for better readability
o Added best practices on Token Leakage prevention o Added best practices on Token Leakage prevention
-03 -03
o Added section on Access Token Leakage at Resource Server o Added section on Access Token Leakage at Resource Server
o incorporated Brian Campbell's findings o incorporated Brian Campbell's findings
-02 -02
o Folded Mix up and Access Token leakage through a bad AS into new o Folded Mix up and Access Token leakage through a bad AS into new
section for dynamic OAuth threats section for dynamic OAuth threats
o reworked dynamic OAuth section o reworked dynamic OAuth section
-01 -01
o Added references to mitigation methods for token leakage o Added references to mitigation methods for token leakage
o Added reference to Token Binding for Authorization Code o Added reference to Token Binding for Authorization Code
 End of changes. 114 change blocks. 
300 lines changed or deleted 352 lines changed or added

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