draft-ietf-oauth-security-topics-01.txt   draft-ietf-oauth-security-topics-02.txt 
Open Authentication Protocol T. Lodderstedt, Ed. Open Authentication Protocol T. Lodderstedt, Ed.
Internet-Draft YES Europe AG Internet-Draft YES Europe AG
Intended status: Best Current Practice J. Bradley Intended status: Best Current Practice J. Bradley
Expires: September 26, 2017 Ping Identity Expires: September 29, 2017 Ping Identity
A. Labunets A. Labunets
Facebook Facebook
March 27, 2017 March 30, 2017
OAuth Security Topics OAuth Security Topics
draft-ietf-oauth-security-topics-01 draft-ietf-oauth-security-topics-02
Abstract Abstract
This draft gives a comprehensive overview on open OAuth security This draft gives a comprehensive overview on open OAuth security
topics. It is intended to serve as a working document for the OAuth topics. It is intended to serve as a working document for the OAuth
working group to systematically capture and discuss these security working group to systematically capture and discuss these security
topics and respective mitigations and eventually recommend best topics and respective mitigations and eventually recommend best
current practice and also OAuth extensions needed to cope with the current practice and also OAuth extensions needed to cope with the
respective security threats. respective security threats.
skipping to change at page 1, line 38 skipping to change at page 1, line 38
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 http://datatracker.ietf.org/drafts/current/. Drafts is at http://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 September 26, 2017. This Internet-Draft will expire on September 29, 2017.
Copyright Notice Copyright Notice
Copyright (c) 2017 IETF Trust and the persons identified as the Copyright (c) 2017 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 (http://trustee.ietf.org/ Provisions Relating to IETF Documents (http://trustee.ietf.org/
license-info) in effect on the date of publication of this document. license-info) in effect on the date of publication of this document.
Please review these documents carefully, as they describe your rights Please review these documents carefully, as they describe your rights
and restrictions with respect to this document. Code Components and restrictions with respect to this document. Code Components
extracted from this document must include Simplified BSD License text extracted from this document must include Simplified BSD License text
as described in Section 4.e of the Trust Legal Provisions and are as described in Section 4.e of the Trust Legal Provisions and are
provided without warranty as described in the Simplified BSD License. provided without warranty as described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 2 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 2
2. OAuth Credentials Leakage . . . . . . . . . . . . . . . . . . 3 2. Recommended Best Practice . . . . . . . . . . . . . . . . . . 3
2.1. Insufficient redirect URI validation . . . . . . . . . . . 3 2.1. Protecting redirect-based flows . . . . . . . . . . . . . 4
2.1.1. Attacks on Authorization Code Grant . . . . . . . . . 3 2.2. TBD . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1.2. Attacks on Implicit Grant . . . . . . . . . . . . . . 4 3. Recommended modifications and extensions to OAuth . . . . . . 4
2.1.3. Proposed Countermeasures . . . . . . . . . . . . . . . 5 4. OAuth Credentials Leakage . . . . . . . . . . . . . . . . . . 5
2.2. Authorization code leakage via referrer headers . . . . . 7 4.1. Insufficient redirect URI validation . . . . . . . . . . . 5
2.2.1. Proposed Countermeasures . . . . . . . . . . . . . . . 7 4.1.1. Attacks on Authorization Code Grant . . . . . . . . . 5
2.3. Code in browser history (TBD) . . . . . . . . . . . . . . 7 4.1.2. Attacks on Implicit Grant . . . . . . . . . . . . . . 6
2.4. Access token in browser history (TBD) . . . . . . . . . . 7 4.1.3. Proposed Countermeasures . . . . . . . . . . . . . . . 7
2.5. Access token on bad resource servers (TBD) . . . . . . . . 8 4.2. Authorization code leakage via referrer headers . . . . . 9
2.6. Mix-Up (TBD) . . . . . . . . . . . . . . . . . . . . . . . 8 4.2.1. Proposed Countermeasures . . . . . . . . . . . . . . . 9
3. OAuth Credentials Injection . . . . . . . . . . . . . . . . . 9 4.3. Attacks in the Browser . . . . . . . . . . . . . . . . . . 9
3.1. Code Injection . . . . . . . . . . . . . . . . . . . . . . 9 4.3.1. Code in browser history (TBD) . . . . . . . . . . . . 9
3.1.1. Proposed Countermeasures . . . . . . . . . . . . . . . 11 4.3.2. Access token in browser history (TBD) . . . . . . . . 10
3.1.2. Access Token Injection (TBD) . . . . . . . . . . . . . 13 4.3.3. Javascript Code stealing Access Tokens (TBD) . . . . . 10
3.1.3. XSRF (TBD) . . . . . . . . . . . . . . . . . . . . . . 13 4.4. Dynamic OAuth Scenarios . . . . . . . . . . . . . . . . . 10
4. Other Attacks . . . . . . . . . . . . . . . . . . . . . . . . 13 4.4.1. Access Token Phishing by Counterfeit Resource Server . 10
5. Other Topics . . . . . . . . . . . . . . . . . . . . . . . . . 13 4.4.2. Mix-Up . . . . . . . . . . . . . . . . . . . . . . . . 11
6. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 14 5. OAuth Credentials Injection . . . . . . . . . . . . . . . . . 12
7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 14 5.1. Code Injection . . . . . . . . . . . . . . . . . . . . . . 12
8. Security Considerations . . . . . . . . . . . . . . . . . . . 14 5.1.1. Proposed Countermeasures . . . . . . . . . . . . . . . 14
9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 14 5.1.2. Access Token Injection (TBD) . . . . . . . . . . . . . 15
Appendix A. Document History . . . . . . . . . . . . . . . . . . . 14 5.1.3. XSRF (TBD) . . . . . . . . . . . . . . . . . . . . . . 16
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 15 6. Other Attacks . . . . . . . . . . . . . . . . . . . . . . . . 16
7. Other Topics . . . . . . . . . . . . . . . . . . . . . . . . . 16
8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 16
9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 16
10. Security Considerations . . . . . . . . . . . . . . . . . . . 16
11. References . . . . . . . . . . . . . . . . . . . . . . . . . . 16
11.1. Normative References . . . . . . . . . . . . . . . . . . 17
11.2. Informative References . . . . . . . . . . . . . . . . . 17
Appendix A. Document History . . . . . . . . . . . . . . . . . . . 17
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 18
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, identity providing.
While OAuth was used in a variety of scenarios and different kinds of While OAuth was used in a variety of scenarios and different kinds of
deployments, the following challenges could be observed: 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 RFC 6819
skipping to change at page 3, line 9 skipping to change at page 3, line 28
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].
The remainder of the document is organized as follows: The next The remainder of the document is organized as follows: The next
section describes various scenarios how OAuth credentials (namely section gives a summary of the set of security mechanisms and
access tokens and authorization codes) may be disclosed to attackers practices, the working group shall consider to recommend to OAuth
and proposes countermeasures. Afterwards, the document discusses implementers. This is followed by a section proposing modifications
to OAuth intended to either simplify its usage and to strengten its
security.
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. First,
various scenarios how OAuth credentials (namely access tokens and
authorization codes) may be disclosed to attackers and proposes
countermeasures are discussed. Afterwards, the document discusses
attacks possible with captured credential and how they may be attacks possible with captured credential and how they may be
prevented. The last sections discuss additional threats. prevented. The last sections discuss additional threats.
2. OAuth Credentials Leakage 2. Recommended Best Practice
This section describes the set of security mechanisms the authors
believe should be taken into consideration by the OAuth working group
to be recommended to OAuth implementers.
2.1. Protecting redirect-based flows
Authorization servers shall utilize exact matching of client redirect
URIs against pre-registered URIs. This measure contributes to the
prevention of leakage of authorization codes and access tokens
(depending on the grant type). It also helps to detect mix up
attacks.
Clients shall avoid any redirects or forwards, which can be
parameterized by URI query parameters, in order to provide a further
layer of defence against token leakage. If there is a need for this
kind of redirects, clients are advised to implement appropriate
counter measures against open redirection, e.g. as described by the
OWASP [owasp].
Clients shall ensure to only process redirect responses of the OAuth
authorization server they send the respective request to and in the
same user agent this request was initiated in. In particular,
clients shall implement appropriate XSRF prevention by utilizing one-
time use XSRF tokens carried in the STATE parameter, which are
securely bound to the user agent. Moreover, the client shall store
the authorization server's identity it send an authorization request
to in a transaction-specific manner, which is also bound to the
particular user agent. Furthermore, clients should use AS-specific
redirect URIs as a means to identify the AS a particular response
came from. Matching this with the before mentioned information
regarding the AS the client sent the request to helps to detect mix-
up attacks.
Note: [I-D.bradley-oauth-jwt-encoded-state] gives advice on how to
implement XSRF prevention and AS matching using signed JWTs in the
STATE parameter.
Clients shall use PKCE [RFC7636] in order to (with the help of the
authorization server) detect attempts to inject authorization codes
into the authorization response. The PKCE challenges must be
transaction-specific and securely bound to the user agent, in which
the transaction was started.
Note: although PKCE so far was recommended as mechanism to protect
native apps, this advice applies to all kinds of OAuth clients,
including web applications.
2.2. TBD
3. Recommended modifications and extensions to OAuth
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
4. OAuth Credentials Leakage
This section describes a couple of different ways how OAuth This section describes a couple of different ways how OAuth
credentials, namely authorization codes and access tokens, can be credentials, namely authorization codes and access tokens, can be
exposed to attackers. exposed to attackers.
2.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. 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
in the wild, which utilized flaws in the pattern matching in the wild, which utilized flaws in the pattern matching
implementation or concrete configurations. Such a flaw effectively implementation or concrete configurations. Such a flaw effectively
breaks client identification or authentication (depending on grant breaks client identification or authentication (depending on grant
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.
2.1.1. Attacks on Authorization Code Grant 4.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 manager 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".
skipping to change at page 4, line 40 skipping to change at page 6, line 39
(6 )Since the attacker impersonated a public client, it can directly (6 )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 client to redeem the code (e.g. by mounting a code injection
attack). This and other kinds of injections are covered in Section attack). This and other kinds of injections are covered in Section
OAuth Credentials Injection. OAuth Credentials Injection.
2.1.2. Attacks on Implicit Grant 4.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 described contain a fragment (see [RFC7231], section 9.5). The attack described
skipping to change at page 5, line 55 skipping to change at page 8, line 5
in the Location header, the user agent will re-attach the original in the Location header, the user agent will re-attach the original
fragment 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&...
(8 )The attacker's page at client.evil.com can access the fragment (8 )The attacker's page at client.evil.com can access the fragment
and obtain the access token. and obtain the access token.
2.1.3. Proposed Countermeasures 4.1.3. Proposed Countermeasures
The complexitity of implementing and managing pattern matching The complexitity 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:
o This change will require all OAuth clients to maintain the o This change will require all OAuth clients to maintain the
transaction state (and XSRF tokens) in the "state" parameter. transaction state (and XSRF tokens) in the "state" parameter.
This is a normative change to RFC 6749 since section 3.1.2.2 This is a normative change to RFC 6749 since section 3.1.2.2
allows for dynamic URI query parameters in the redirect URI. In allows for dynamic URI query parameters in the redirect URI. In
order to assess the practical impact, the working group needs to order to assess the practical impact, the working group needs to
collect data whether this feature is used in deployed reality collect data on whether this feature is realy used in deployments
today. today.
o The working group might also consider this change as a step o The working group may also consider this change as a step towards
towards improved interoperability for OAuth implementations since improved interoperability for OAuth implementations since RFC 6749
RFC 6749 is somehow vague on redirect URI validation. There is is somewhat vague on redirect URI validation. Notably there are
especially no rule for pattern matching. So one may assume all no rules for pattern matching. One may therefore assume all
clients utilizing pattern matching will do so in a deployment clients utilizing pattern matching will do so in a deployment
specific way. On the other hand, RFC 6749 already recommends specific way. On the other hand, RFC 6749 already recommends
exact matching if the full URL had been registered. exact matching if the full URL had been registered.
o Clients with multiple redirect URIs need to register all of them o Clients with multiple redirect URIs need to register all of them
explicitly. explicitly.
Note: clients with just a single redirect URI would not even need to Note: clients with just a single redirect URI would not even need to
send a redirect URI with the authorization request. Does it make send a redirect URI with the authorization request. Does it make
sense to emphasize this option? Would that further simplify use of sense to emphasize this option? Would that further simplify use of
the protocol and foster security? the protocol and foster security?
o Exact redirect matching does not work for native apps utilizing a o Exact redirect matching does not work for native apps utilizing a
local web server due to dynamic port numbers - at least wild cards local web server due to dynamic port numbers - at least wild cards
for port numbers are required. for port numbers are required.
Question: Does redirect uri validation solve any problem for native Question: Does redirect uri validation solve any problem for native
apps? Effective against impersonation when used in conjunction with apps? Effective against impersonation when used in conjunction with
claimed HTTPS redirect URIs only. claimed HTTPS redirect URIs only.
For Windows token broker exact redirect URI matching is impotant as
the redirect URI encodes the app identity. For custom scheme
redirects there is a question however it is probably a usfull part 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 respective section).
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? https:// o authenticate client using digital signatures (JAR? https://
tools.ietf.org/html/draft-ietf-oauth-jwsreq-09) tools.ietf.org/html/draft-ietf-oauth-jwsreq-09)
2.2. Authorization code leakage via referrer headers 4.2. Authorization code leakage via referrer headers
The section above already discussed use of the referrer header for It is possible authorization codes are unintentionally disclosed to
one kind of attack to obtain OAuth credentials. It is also possible attackers, if a OAuth client renders a page containing links to other
authorization codes are unintentionally disclosed to attackers, if a pages (ads, faq, ...) as result of a successful authorization
OAuth client renders a page containing links to other pages (ads, request.
faq, ...) as result of a successful authorization 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> (f.e. if this is blog web site
etc.): the implication is obviously the same - loading this content etc.): 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.
2.2.1. Proposed Countermeasures 4.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 Use of the HTML link attribute rel="noreferrer" (Chrome
52.0.2743.116, FF 49.0.1, Edge 38.14393.0.0, IE/Win10) 52.0.2743.116, FF 49.0.1, Edge 38.14393.0.0, IE/Win10)
o Use of the "referrer" meta link attribute (possible values e.g. o Use of the "referrer" meta link attribute (possible values e.g.
noreferrer, origin, ...) (cf. https://w3c.github.io/webappsec- noreferrer, origin, ...) (cf. https://w3c.github.io/webappsec-
referrer-policy/ - work in progress (seems Google, Chrome and Edge referrer-policy/ - work in progress (seems Google, Chrome and Edge
support it)) support it))
skipping to change at page 7, line 49 skipping to change at page 9, line 52
o Use form post mode instead of redirect for authorization response o Use form post mode instead of redirect for authorization response
(don't transport credentials via URL parameters and GET) (don't transport credentials via URL parameters and GET)
Note: There shouldn't be a referer header when loading HTTP content Note: There shouldn't be a referer header when loading HTTP content
from a HTTPS -loaded page (e.g. help/faq pages) from a HTTPS -loaded page (e.g. help/faq pages)
Note: This kind of attack is not applicable to the implicit grant Note: This kind of attack is not applicable to the implicit grant
since fragments are not be included in referrer headers (cf. https:/ since fragments are not be included in referrer headers (cf. https:/
/tools.ietf.org/html/rfc7231#section-5.5.2) /tools.ietf.org/html/rfc7231#section-5.5.2)
2.3. Code in browser history (TBD) 4.3. Attacks in the Browser
4.3.1. Code in browser history (TBD)
When browser navigates to "client.com/redirection_endpoint?code=abcd" When browser navigates to "client.com/redirection_endpoint?code=abcd"
as a result of a redirect from a provider's authorization endpoint. as a result of a redirect from a provider's authorization endpoint.
Proposed countermeasures: code is one time use, has limited duration, Proposed countermeasures: code is one time use, has limited duration,
is bound to client id/secret (confidential clients only) is bound to client id/secret (confidential clients only)
2.4. Access token in browser history (TBD) 4.3.2. Access token in browser history (TBD)
When a client or just a web site which already has a token When a client or just a web site which already has a token
deliberately navigates to a page like provider.com/ deliberately navigates to a page like provider.com/
get_user_profile?access_token=abcdef.. Actually RFC6750 discourages get_user_profile?access_token=abcdef.. Actually RFC6750 discourages
this practice and asks to transfer tokens via a header, but in this practice and asks to transfer tokens via a header, but in
practice web sites often just pass access token in query practice web sites often just pass access token in query
When browser navigates to client.com/ When browser navigates to client.com/
redirection_endpoint#access_token=abcef as a result of a redirect redirection_endpoint#access_token=abcef as a result of a redirect
from a provider's authorization endpoint. from a provider's authorization endpoint.
Proposal: replace implicit flow with postmessage communication Proposal: replace implicit flow with postmessage communication
2.5. Access token on bad resource servers (TBD) 4.3.3. Javascript Code stealing Access Tokens (TBD)
In the beginning, the basic assumption of OAuth 2.0 was that the sandboxing using service workers
OAuth client is implemented for and tightly bound to a certain
deployment. It therefore knows the URLs of the authorization and
resource servers upfront, at development/deployment time. So well-
known URLs to resource servers serve as trust anchor. The validation
whether the client talks to a legitimate resource server is based on
TLS server authentication (see [RFC6819], Section 4.5.4).
As OAuth clients nowadays more and more bind dynamically at runtime 4.4. Dynamic OAuth Scenarios
to authorization and resource servers, there need to be alternative
solutions to ensure clients do not deliver access tokens to bad
resource servers.
... OAuth initially assumed a static relationship between client,
authorization server and resource servers. The URLs of AS and RS
were know to the client at deployment time and built an anchor for
the trust relationsship among those parties. The validation whether
the client talks to a legitimate server is based on TLS server
authentication (see [RFC6819], Section 4.5.4).
Potential mitigations: With the increasing adoption of OAuth, this simple model dissolved
and, in several scenarios, was replaced by a dynamic establishment of
the relationship between clients on one side and the authorization
and resource servers of a particular deployment on the other side.
This way the same client can be used to access services of different
providers (in case of standard APIs, such as e-Mail or OpenID
Connect) or serves as a frontend to a particular tenant in a multi-
tenancy.
o PoP (https://tools.ietf.org/html/draft-ietf-oauth-pop- Extensions of OAuth, such as [RFC7591] and [I-D.ietf-oauth-discovery]
architecture-08) were developed in order to support the usage of OAuth in dynamic
scenarios.
o Token Binding (https://tools.ietf.org/html/draft-jones-oauth- As a challenge to the community, such usage scenarios open up new
token-binding-00) attack angles, which are discussed in this section.
o OAuth Response Metadata (https://tools.ietf.org/html/draft- 4.4.1. Access Token Phishing by Counterfeit Resource Server
sakimura-oauth-meta-07) An attacker may pretend to be a particular resource server and to
accept tokens from a particular authorization server. If the client
sends a valid access token to this counterfeit resource server, the
server in turn may use that token to access other services on behalf
of the resource owner.
o Resource Indicators (https://tools.ietf.org/html/draft-campbell- Potential mitigation strategies:
oauth-resource-indicators-01)
o ... o AS may publish information about its legitimate resource servers,
clients must only send access tokens to this servers
2.6. Mix-Up (TBD) o Clients indicate resource server they intend to use the access
token for at AS, AS may refuse to issue tokens for ressource
servers it does not know
o AS indicates resource servers a particular access token is good
for to client - client enforced audience restriction - prevents
disclosure (e.g. OAuth Response Metadata (https://tools.ietf.org/
html/draft-sakimura-oauth-meta-07)
o Access tokens are audience restricted - prevents replay if the
audience is a URL determined by the client, reduces impact in case
of legitimate resource server uses token at other resource server
(e.g. https://tools.ietf.org/html/draft-campbell-oauth-resource-
indicators-01)
o Access Token is sender restricted - sender is cryptographically
verified
* https://tools.ietf.org/html/draft-ietf-oauth-pop-
architecture-08
* https://tools.ietf.org/html/draft-jones-oauth-token-binding-00
* https://datatracker.ietf.org/doc/draft-campbell-oauth-mtls
* https://datatracker.ietf.org/doc/html/draft-sakimura-oauth-jpop
4.4.2. 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 cf. https://tools.ietf.org/html/draft-ietf-oauth-mix-up-
mitigation-01. mitigation-01.
Potential mitigations: Potential mitigations:
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 (so requires OpenID Connect) carries client id and issuer o ID token carries client id and issuer (requires OpenID Connect)
o register AS-specific redirect URIs, bind transaction to AS
o ... 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)
3. OAuth Credentials Injection 5. OAuth Credentials Injection
Credential injection means an attacker somehow obtained a valid OAuth Credential injection means an attacker somehow obtained a valid OAuth
credential (code or token) and is able to utilize this to impersonate credential (code or token) and is able to utilize this to impersonate
the legitimate resource owner or to cause a victim to access the legitimate resource owner or to cause a victim to access
resources under the attacker's control (XSRF). resources under the attacker's control (XSRF).
3.1. Code Injection 5.1. 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. Example are:
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 and/or
skipping to change at page 11, line 24 skipping to change at page 14, line 14
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.
3.1.1. Proposed Countermeasures 5.1.1. Proposed Countermeasures
The general proposal is to bind every particular authorization code The general proposal is to bind every particular authorization code
to a certain client on a certain device (or in a certain user agent) to a certain client on a certain device (or in a certain user agent)
in the context of a certain transaction. There are multiple in the context of a certain transaction. There are multiple
technical solutions to achieve this goal: technical solutions to achieve this goal:
Nonce OpenID Connect's existing "nonce" parameter is used for this Nonce OpenID Connect's existing "nonce" parameter is used for this
purpose. The nonce value is one time use and created by the purpose. The nonce value is one time use and created by the
client. The client is supposed to bind it to the user agent client. The client is supposed to bind it to the user agent
session and sends it with the initial request to the OpenId session and sends it with the initial request to the OpenId
skipping to change at page 12, line 48 skipping to change at page 15, line 31
tbpkce). tbpkce).
pro: pro:
- highly secure - highly secure
con: con:
- highly sophisticated, requires browser support, will it - highly sophisticated, requires browser support, will it
work for native apps? work for native apps?
per instance client id/secret ... per instance client id/secret ...
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 the countermeasures described above if he is able to create or capture
respective secret on a device under his control, which is then used the respective secret or code_challenge on a device under his
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, 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 What about other native apps? Treat nonce or PKCE challenge as
replay detection tokens (needs to ensure cluster-wide one-time use)? replay detection tokens (needs to ensure cluster-wide one-time use)?
3.1.2. Access Token Injection (TBD) 5.1.2. Access Token Injection (TBD)
Note: An attacker in possession of an access token can access any Note: An attacker in possession of an access token can access any
resources the access token gives him the permission to. This kind of resources the access token gives him the permission to. This kind of
attacks simply illustrates the fact that bearer tokens utilized by attacks simply illustrates the fact that bearer tokens utilized by
OAuth are reusable similar to passwords unless they are protected by OAuth are reusable similar to passwords unless they are protected by
further means. further means.
(where do we treat access token replay/use at the resource server? (where do we treat access token replay/use at the resource server?
https://tools.ietf.org/html/rfc6819#section-4.6.4 has some text about https://tools.ietf.org/html/rfc6819#section-4.6.4 has some text about
it but is it sufficient?) it but is it sufficient?)
The attack described in this section is about injecting a stolen The attack described in this section is about injecting a stolen
access token into a legitimate client on a device under the access token into a legitimate client on a device under the
adversaries control. The attacker wants to impersonate a victim and adversaries control. The attacker wants to impersonate a victim and
cannot use his own client, since he wants to access certain functions cannot use his own client, since he wants to access certain functions
in this particular client. in this particular client.
Proposal: token binding, hybrid flow+nonce(OIDC), other Proposal: token binding, hybrid flow+nonce(OIDC), other
cryptographical binding between access token and user agent instance cryptographical binding between access token and user agent instance
3.1.3. XSRF (TBD) 5.1.3. XSRF (TBD)
injection of code or access token on a victim's device (e.g. to injection of code or access token on a victim's device (e.g. to
cause client to access resources under the attacker's control) cause client to access resources under the attacker's control)
mitigation: XSRF tokens (one time use) w/ user agent binding (cf. mitigation: XSRF tokens (one time use) w/ user agent binding (cf.
https://www.owasp.org/index.php/ https://www.owasp.org/index.php/
CrossSite_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet) CrossSite_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet)
4. Other Attacks 6. Other Attacks
Using the AS as Open Redirector - error handling AS (redirects) Using the AS as Open Redirector - error handling AS (redirects)
(draft-ietf-oauth-closing-redirectors-00) (draft-ietf-oauth-closing-redirectors-00)
Using the Client as Open Redirector Using the Client as Open Redirector
redirect via status code 307 - use 302 redirect via status code 307 - use 302
5. Other Topics 7. Other Topics
why to rotate refresh tokens why to rotate refresh tokens
why audience restriction
how to support multi AS per RS how to support multi AS per RS
... ...
differentiate native, JS and web clients differentiate native, JS and web clients
federated login to apps (code flow to own AS in browser and federated federated login to apps (code flow to own AS in browser and federated
login to 3rd party IDP in browser) login to 3rd party IDP in browser)
do not put sensitive data in URL/GET parameters (Jim Manico) do not put sensitive data in URL/GET parameters (Jim Manico)
6. Acknowledgements 8. Acknowledgements
We would like to thank Jim Manico and Phil Hunt for their valuable We would like to thank Jim Manico and Phil Hunt for their valuable
feedback. feedback.
7. IANA Considerations 9. IANA Considerations
This draft includes no request to IANA. This draft includes no request to IANA.
8. Security Considerations 10. Security Considerations
All relevant security considerations have been given in the All relevant security considerations have been given in the
functional specification. functional specification.
9. References 11. References
11.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, RFC Resource Identifier (URI): Generic Syntax", STD 66, RFC
3986, DOI 10.17487/RFC3986, January 2005, <http://www.rfc- 3986, DOI 10.17487/RFC3986, January 2005, <http://www.rfc-
editor.org/info/rfc3986>. 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, <http://www RFC 6749, DOI 10.17487/RFC6749, October 2012, <http://www
.rfc-editor.org/info/rfc6749>. .rfc-editor.org/info/rfc6749>.
skipping to change at page 14, line 45 skipping to change at page 17, line 30
[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, DOI Threat Model and Security Considerations", RFC 6819, DOI
10.17487/RFC6819, January 2013, <http://www.rfc-editor.org 10.17487/RFC6819, January 2013, <http://www.rfc-editor.org
/info/rfc6819>. /info/rfc6819>.
[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, DOI Protocol (HTTP/1.1): Semantics and Content", RFC 7231, DOI
10.17487/RFC7231, June 2014, <http://www.rfc-editor.org/ 10.17487/RFC7231, June 2014, <http://www.rfc-editor.org/
info/rfc7231>. info/rfc7231>.
[RFC7591] Richer, J., Ed., Jones, M., Bradley, J., Machulak, M. and
P. Hunt, "OAuth 2.0 Dynamic Client Registration Protocol",
RFC 7591, DOI 10.17487/RFC7591, July 2015, <http://www
.rfc-editor.org/info/rfc7591>.
11.2. Informative References
[I-D.bradley-oauth-jwt-encoded-state]
Bradley, J., Lodderstedt, T. and H. Zandbelt, "Encoding
claims in the OAuth 2 state parameter using a JWT",
Internet-Draft draft-bradley-oauth-jwt-encoded-state-07,
March 2017.
[I-D.ietf-oauth-discovery]
Jones, M., Sakimura, N. and J. Bradley, "OAuth 2.0
Authorization Server Metadata", Internet-Draft draft-ietf-
oauth-discovery-04, August 2016.
[RFC7636] Sakimura, N., Ed., Bradley, J. and N. Agarwal, "Proof Key
for Code Exchange by OAuth Public Clients", RFC 7636, DOI
10.17487/RFC7636, September 2015, <http://www.rfc-
editor.org/info/rfc7636>.
[owasp] "Open Web Application Security Project Home Page", ,
<https://www.owasp.org/>.
Appendix A. Document History Appendix A. Document History
[[ To be removed from the final specification ]] [[ To be removed from the final specification ]]
-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. 50 change blocks. 
95 lines changed or deleted 246 lines changed or added

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