idnits 2.17.1 draft-ietf-oauth-security-topics-13.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (July 8, 2019) is 1753 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Best Current Practice ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Missing Reference: 'I-D.draft-ietf-oauth-mtls' is mentioned on line 434, but not defined == Missing Reference: 'OIDC' is mentioned on line 435, but not defined -- Possible downref: Non-RFC (?) normative reference: ref. 'OpenID' ** Downref: Normative reference to an Informational RFC: RFC 6819 == Outdated reference: A later version (-34) exists of draft-ietf-oauth-jwsreq-19 == Outdated reference: A later version (-17) exists of draft-ietf-oauth-mtls-15 == Outdated reference: A later version (-08) exists of draft-ietf-oauth-resource-indicators-02 == Outdated reference: A later version (-05) exists of draft-sakimura-oauth-jpop-04 -- Obsolete informational reference (is this intentional?): RFC 7231 (Obsoleted by RFC 9110) Summary: 1 error (**), 0 flaws (~~), 7 warnings (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Web Authorization Protocol T. Lodderstedt 3 Internet-Draft yes.com 4 Intended status: Best Current Practice J. Bradley 5 Expires: January 9, 2020 Yubico 6 A. Labunets 7 Facebook 8 D. Fett 9 yes.com 10 July 8, 2019 12 OAuth 2.0 Security Best Current Practice 13 draft-ietf-oauth-security-topics-13 15 Abstract 17 This document describes best current security practice for OAuth 2.0. 18 It updates and extends the OAuth 2.0 Security Threat Model to 19 incorporate practical experiences gathered since OAuth 2.0 was 20 published and covers new threats relevant due to the broader 21 application of OAuth 2.0. 23 Status of This Memo 25 This Internet-Draft is submitted in full conformance with the 26 provisions of BCP 78 and BCP 79. 28 Internet-Drafts are working documents of the Internet Engineering 29 Task Force (IETF). Note that other groups may also distribute 30 working documents as Internet-Drafts. The list of current Internet- 31 Drafts is at https://datatracker.ietf.org/drafts/current/. 33 Internet-Drafts are draft documents valid for a maximum of six months 34 and may be updated, replaced, or obsoleted by other documents at any 35 time. It is inappropriate to use Internet-Drafts as reference 36 material or to cite them other than as "work in progress." 38 This Internet-Draft will expire on January 9, 2020. 40 Copyright Notice 42 Copyright (c) 2019 IETF Trust and the persons identified as the 43 document authors. All rights reserved. 45 This document is subject to BCP 78 and the IETF Trust's Legal 46 Provisions Relating to IETF Documents 47 (https://trustee.ietf.org/license-info) in effect on the date of 48 publication of this document. Please review these documents 49 carefully, as they describe your rights and restrictions with respect 50 to this document. Code Components extracted from this document must 51 include Simplified BSD License text as described in Section 4.e of 52 the Trust Legal Provisions and are provided without warranty as 53 described in the Simplified BSD License. 55 Table of Contents 57 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 58 1.1. Structure . . . . . . . . . . . . . . . . . . . . . . . . 4 59 1.2. Conventions and Terminology . . . . . . . . . . . . . . . 4 60 2. The Updated OAuth 2.0 Attacker Model . . . . . . . . . . . . 4 61 3. Recommendations . . . . . . . . . . . . . . . . . . . . . . . 6 62 3.1. Protecting Redirect-Based Flows . . . . . . . . . . . . . 6 63 3.1.1. Authorization Code Grant . . . . . . . . . . . . . . 7 64 3.1.2. Implicit Grant . . . . . . . . . . . . . . . . . . . 8 65 3.2. Token Replay Prevention . . . . . . . . . . . . . . . . . 8 66 3.3. Access Token Privilege Restriction . . . . . . . . . . . 9 67 3.4. Resource Owner Password Credentials Grant . . . . . . . . 9 68 3.5. Client Authentication . . . . . . . . . . . . . . . . . . 10 69 3.6. Other Recommendations . . . . . . . . . . . . . . . . . . 10 70 4. Attacks and Mitigations . . . . . . . . . . . . . . . . . . . 10 71 4.1. Insufficient Redirect URI Validation . . . . . . . . . . 10 72 4.1.1. Redirect URI Validation Attacks on Authorization Code 73 Grant . . . . . . . . . . . . . . . . . . . . . . . . 11 74 4.1.2. Redirect URI Validation Attacks on Implicit Grant . . 12 75 4.1.3. Proposed Countermeasures . . . . . . . . . . . . . . 13 76 4.2. Credential Leakage via Referrer Headers . . . . . . . . . 14 77 4.2.1. Leakage from the OAuth Client . . . . . . . . . . . . 14 78 4.2.2. Leakage from the Authorization Server . . . . . . . . 14 79 4.2.3. Consequences . . . . . . . . . . . . . . . . . . . . 14 80 4.2.4. Proposed Countermeasures . . . . . . . . . . . . . . 14 81 4.3. Attacks through the Browser History . . . . . . . . . . . 15 82 4.3.1. Code in Browser History . . . . . . . . . . . . . . . 16 83 4.3.2. Access Token in Browser History . . . . . . . . . . . 16 84 4.4. Mix-Up . . . . . . . . . . . . . . . . . . . . . . . . . 16 85 4.4.1. Attack Description . . . . . . . . . . . . . . . . . 17 86 4.4.2. Countermeasures . . . . . . . . . . . . . . . . . . . 18 87 4.5. Authorization Code Injection . . . . . . . . . . . . . . 19 88 4.5.1. Attack Description . . . . . . . . . . . . . . . . . 19 89 4.5.2. Discussion . . . . . . . . . . . . . . . . . . . . . 20 90 4.5.3. Proposed Countermeasures . . . . . . . . . . . . . . 21 91 4.6. Access Token Injection . . . . . . . . . . . . . . . . . 23 92 4.6.1. Proposed Countermeasures . . . . . . . . . . . . . . 23 93 4.7. Cross Site Request Forgery . . . . . . . . . . . . . . . 23 94 4.7.1. Proposed Countermeasures . . . . . . . . . . . . . . 23 95 4.8. Access Token Leakage at the Resource Server . . . . . . . 24 96 4.8.1. Access Token Phishing by Counterfeit Resource Server 24 97 4.8.2. Compromised Resource Server . . . . . . . . . . . . . 29 98 4.9. Open Redirection . . . . . . . . . . . . . . . . . . . . 30 99 4.9.1. Authorization Server as Open Redirector . . . . . . . 30 100 4.9.2. Clients as Open Redirector . . . . . . . . . . . . . 31 101 4.10. 307 Redirect . . . . . . . . . . . . . . . . . . . . . . 31 102 4.11. TLS Terminating Reverse Proxies . . . . . . . . . . . . . 32 103 4.12. Refresh Token Protection . . . . . . . . . . . . . . . . 32 104 4.13. Client Impersonating Resource Owner . . . . . . . . . . . 34 105 4.13.1. Proposed Countermeasures . . . . . . . . . . . . . . 35 106 5. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 35 107 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 35 108 7. Security Considerations . . . . . . . . . . . . . . . . . . . 35 109 8. References . . . . . . . . . . . . . . . . . . . . . . . . . 35 110 8.1. Normative References . . . . . . . . . . . . . . . . . . 35 111 8.2. Informative References . . . . . . . . . . . . . . . . . 36 112 Appendix A. Document History . . . . . . . . . . . . . . . . . . 39 113 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 42 115 1. Introduction 117 Since its publication in [RFC6749] and [RFC6750], OAuth 2.0 has 118 gotten massive traction in the market and became the standard for API 119 protection and, as the foundation of OpenID Connect [OpenID], 120 identity providing. While OAuth was used in a variety of scenarios 121 and different kinds of deployments, the following challenges could be 122 observed: 124 o OAuth implementations are being attacked through known 125 implementation weaknesses and anti-patterns (CSRF, referrer 126 header). Although most of these threats are discussed in the 127 OAuth 2.0 Threat Model and Security Considerations [RFC6819], 128 continued exploitation demonstrates there may be a need for more 129 specific recommendations, that the existing mitigations may be too 130 difficult to deploy, and that more defense in depth is needed. 132 o Technology has changed, e.g., the way browsers treat fragments in 133 some situations, which changes the implicit grant's underlying 134 security model. 136 o OAuth is being used in environments with higher security 137 requirements than considered initially, such as Open Banking, 138 eHealth, eGovernment, and Electronic Signatures. Those use cases 139 call for stricter guidelines and additional protection. 141 o OAuth is being used in much more dynamic setups than originally 142 anticipated, creating new challenges with respect to security. 143 Those challenges go beyond the original scope of [RFC6749], 144 [RFC6750], and [RFC6819]. 146 OAuth initially assumed a static relationship between client, 147 authorization server and resource servers. The URLs of AS and RS 148 were known to the client at deployment time and built an anchor for 149 the trust relationship among those parties. The validation whether 150 the client talks to a legitimate server was based on TLS server 151 authentication (see [RFC6819], Section 4.5.4). With the increasing 152 adoption of OAuth, this simple model dissolved and, in several 153 scenarios, was replaced by a dynamic establishment of the 154 relationship between clients on one side and the authorization and 155 resource servers of a particular deployment on the other side. This 156 way the same client could be used to access services of different 157 providers (in case of standard APIs, such as e-mail or OpenID 158 Connect) or serves as a frontend to a particular tenant in a multi- 159 tenancy. Extensions of OAuth, such as [RFC7591] and [RFC8414] were 160 developed in order to support the usage of OAuth in dynamic 161 scenarios. As a challenge to the community, such usage scenarios 162 open up new attack angles, which are discussed in this document. 164 1.1. Structure 166 The remainder of the document is organized as follows: The next 167 section updates the OAuth attacker model. Afterwards, the most 168 important recommendations of the OAuth working group for every OAuth 169 implementor are summarized. Subsequently, a detailed analysis of the 170 threats and implementation issues which can be found in the wild 171 today is given along with a discussion of potential countermeasures. 173 1.2. Conventions and Terminology 175 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 176 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 177 "OPTIONAL" in this document are to be interpreted as described in BCP 178 14 [RFC2119] [RFC8174] when, and only when, they appear in all 179 capitals, as shown here. 181 2. The Updated OAuth 2.0 Attacker Model 183 In [RFC6819], an attacker model was laid out that described the 184 capabilities of attackers against which OAuth deployments must 185 defend. In the following, this attacker model is updated to account 186 for the potentially dynamic relationships involving multiple parties 187 (as described above), to include new types of attackers, and to 188 define the attacker model more clearly. 190 OAuth 2.0 MUST ensure that the authorization of the resource owner 191 (RO) (with a user agent) at an authorization server (AS) and the 192 subsequent usage of the access token at the resource server (RS) is 193 protected at least against the following attackers: 195 o (A1) Web Attackers that control an arbitrary number of network 196 endpoints (except for the concrete RO, AS, and RS). Web attackers 197 may set up web sites that are visited by the RO, operate their own 198 user agents, participate in the protocol using their own user 199 credentials, etc. 200 Web attackers may, in particular, operate OAuth clients that are 201 registered at AS, and operate their own authorization and resource 202 servers that can be used (in parallel) by ROs. 203 It must also be assumed that web attackers can lure the user to 204 open arbitrary attacker-chosen URIs at any time. This can be 205 achieved through many ways, for example, by injecting malicious 206 advertisements into advertisement networks, or by sending legit- 207 looking emails. 209 o (A2) Network Attackers that additionally have full control over 210 the network over which protocol participants communicate. They 211 can eavesdrop on, manipulate, and spoof messages, except when 212 these are properly protected by cryptographic methods (e.g., TLS). 213 Network attackers can also block arbitrary messages. 215 These attackers conform to the attacker model that was used in formal 216 analysis efforts for OAuth [arXiv.1601.01229]. Previous attacks on 217 OAuth have shown that OAuth deployments SHOULD protect against an 218 even stronger attacker model that is described as follows: 220 o (A3) Attackers that can read, but not modify, the contents of the 221 authorization response (i.e., the authorization response can leak 222 to an attacker). 223 Examples for such attacks include open redirector attacks, 224 problems existing on mobile operating systems (where different 225 apps can register themselves on the same URI), so-called mix-up 226 attacks, where the client is tricked into sending credentials to a 227 attacker-controlled AS, and the fact that URLs are often stored/ 228 logged by browsers (history), proxy servers, and operating 229 systems. 231 o (A4) Attackers that can read, but not modify, the contents of the 232 authorization request (i.e., the authorization request can leak, 233 in the same manner as above, to an attacker). 235 o (A5) Attackers that control a resource server used by RO with an 236 access token issued by AS. For example, a resource server can be 237 compromised by an attacker, an access token may be sent to an 238 attacker-controlled resource server due to a misconfiguration, or 239 an RO is social-engineered into using a attacker-controlled RS. 241 Note that in this attacker model, an attacker (see A1) can be a RO or 242 act as one. For example, an attacker can use his own browser to 243 replay tokens or authorization codes obtained by any of the attacks 244 described above at the client or RS. 246 This document discusses the additional threats resulting from these 247 attackers in detail and recommends suitable mitigations. Attacks in 248 an even stronger attacker model are discussed, for example, in 249 [arXiv.1901.11520]. 251 This is a minimal attacker model. Implementers MUST take into 252 account all possible attackers in the environment in which their 253 OAuth implementations are expected to run. 255 3. Recommendations 257 This section describes the set of security mechanisms the OAuth 258 working group recommends to OAuth implementers. 260 3.1. Protecting Redirect-Based Flows 262 Authorization servers MUST utilize exact matching of client redirect 263 URIs against pre-registered URIs. This measure contributes to the 264 prevention of leakage of authorization codes and access tokens 265 (depending on the grant type). It also helps to detect mix-up 266 attacks. 268 Clients SHOULD avoid forwarding the user's browser to a URI obtained 269 from a query parameter since such a function could be utilized to 270 exfiltrate authorization codes and access tokens. If there is a 271 strong need for this kind of redirects, clients are advised to 272 implement appropriate countermeasures against open redirection, e.g., 273 as described by OWASP [owasp]. 275 Clients MUST prevent CSRF. One-time use CSRF tokens carried in the 276 "state" parameter, which are securely bound to the user agent, SHOULD 277 be used for that purpose. If PKCE [RFC7636] is used by the client 278 and the authorization server supports PKCE, clients MAY opt to not 279 use "state" for CSRF protection, as such protection is provided by 280 PKCE. In this case, "state" MAY be used again for its original 281 purpose, namely transporting data about the application state of the 282 client (see Section 4.7.1). 284 In order to prevent mix-up attacks, clients MUST only process 285 redirect responses of the OAuth authorization server they sent the 286 respective request to and from the same user agent this authorization 287 request was initiated with. Clients MUST memorize which 288 authorization server they sent an authorization request to and bind 289 this information to the user agent and ensure any sub-sequent 290 messages are sent to the same authorization server. Clients SHOULD 291 use AS-specific redirect URIs as a means to identify the AS a 292 particular response came from. 294 Note: [I-D.bradley-oauth-jwt-encoded-state] gives advice on how to 295 implement CSRF prevention and AS matching using signed JWTs in the 296 "state" parameter. 298 AS which redirect a request that potentially contains user 299 credentials MUST avoid forwarding these user credentials accidentally 300 (see Section 4.10). 302 3.1.1. Authorization Code Grant 304 Clients utilizing the authorization grant type MUST use PKCE 305 [RFC7636] in order to (with the help of the authorization server) 306 detect and prevent attempts to inject (replay) authorization codes 307 into the authorization response. The PKCE challenges must be 308 transaction-specific and securely bound to the user agent in which 309 the transaction was started and the respective client. OpenID 310 Connect clients MAY use the "nonce" parameter of the OpenID Connect 311 authentication request as specified in [OpenID] in conjunction with 312 the corresponding ID Token claim for the same purpose. 314 Note: although PKCE so far was recommended as a mechanism to protect 315 native apps, this advice applies to all kinds of OAuth clients, 316 including web applications. 318 Clients SHOULD use PKCE code challenge methods that do not expose the 319 PKCE verifier in the authorization request. (Otherwise, the attacker 320 A4 can trivially break the security provided by PKCE.) Currently, 321 "S256" is the only such method. 323 AS MUST support PKCE [!@RFC7636]. 325 AS SHOULD provide a way to detect their support for PKCE. To this 326 end, they SHOULD either (a) publish, in their AS metadata 327 ([!@RFC8418]), the element "code_challenge_methods_supported" 328 containing the supported PKCE challenge methods (which can be used by 329 the client to detect PKCE support) or (b) provide a deployment- 330 specific way to ensure or determine PKCE support by the AS. 332 Authorization servers SHOULD furthermore consider the recommendations 333 given in [RFC6819], Section 4.4.1.1, on authorization code replay 334 prevention. 336 3.1.2. Implicit Grant 338 The implicit grant (response type "token") and other response types 339 causing the authorization server to issue access tokens in the 340 authorization response are vulnerable to access token leakage and 341 access token replay as described in Section 4.1, Section 4.2, 342 Section 4.3, and Section 4.6. 344 Moreover, no viable mechanism exists to cryptographically bind access 345 tokens issued in the authorization response to a certain client as it 346 is recommended in Section 3.2. This makes replay detection for such 347 access tokens at resource servers impossible. 349 In order to avoid these issues, clients SHOULD NOT use the implicit 350 grant (response type "token") or any other response type issuing 351 access tokens in the authorization response, such as "token id_token" 352 and "code token id_token", unless the issued access tokens are 353 sender-constrained and access token injection in the authorization 354 response is prevented. 356 A sender-constrained access token scopes the applicability of an 357 access token to a certain sender. This sender is obliged to 358 demonstrate knowledge of a certain secret as prerequisite for the 359 acceptance of that token at the recipient (e.g., a resource server). 361 Clients SHOULD instead use the response type "code" (aka 362 authorization code grant type) as specified in Section 3.1.1 or any 363 other response type that causes the authorization server to issue 364 access tokens in the token response. This allows the authorization 365 server to detect replay attempts and generally reduces the attack 366 surface since access tokens are not exposed in URLs. It also allows 367 the authorization server to sender-constrain the issued tokens. 369 3.2. Token Replay Prevention 371 Authorization servers SHOULD use TLS-based methods for sender- 372 constrained access tokens as described in Section 4.8.1.2, such as 373 token binding [I-D.ietf-oauth-token-binding] or Mutual TLS for OAuth 374 2.0 [I-D.ietf-oauth-mtls] in order to prevent token replay. Refresh 375 tokens MUST be sender-constrained or use refresh token rotation as 376 described in Section 4.12. 378 It is recommended to use end-to-end TLS whenever possible. If TLS 379 traffic needs to be terminated at an intermediary, refer to 380 Section 4.11 for further security advice. 382 3.3. Access Token Privilege Restriction 384 The privileges associated with an access token SHOULD be restricted 385 to the minimum required for the particular application or use case. 386 This prevents clients from exceeding the privileges authorized by the 387 resource owner. It also prevents users from exceeding their 388 privileges authorized by the respective security policy. Privilege 389 restrictions also limit the impact of token leakage although more 390 effective counter-measures are described in Section 3.2. 392 In particular, access tokens SHOULD be restricted to certain resource 393 servers, preferably to a single resource server. To put this into 394 effect, the authorization server associates the access token with 395 certain resource servers and every resource server is obliged to 396 verify for every request, whether the access token sent with that 397 request was meant to be used for that particular resource server. If 398 not, the resource server MUST refuse to serve the respective request. 399 Clients and authorization servers MAY utilize the parameters "scope" 400 or "resource" as specified in [RFC6749] and 401 [I-D.ietf-oauth-resource-indicators], respectively, to determine the 402 resource server they want to access. 404 Additionally, access tokens SHOULD be restricted to certain resources 405 and actions on resource servers or resources. To put this into 406 effect, the authorization server associates the access token with the 407 respective resource and actions and every resource server is obliged 408 to verify for every request, whether the access token sent with that 409 request was meant to be used for that particular action on the 410 particular resource. If not, the resource server must refuse to 411 serve the respective request. Clients and authorization servers MAY 412 utilize the parameter "scope" as specified in [RFC6749] to determine 413 those resources and/or actions. 415 3.4. Resource Owner Password Credentials Grant 417 The resource owner password credentials grant MUST NOT be used. This 418 grant type insecurely exposes the credentials of the resource owner 419 to the client. Even if the client is benign, this results in an 420 increased attack surface (credentials can leak in more places than 421 just the AS) and users are trained to enter their credentials in 422 places other than the AS. 424 Furthermore, adapting the resource owner password credentials grant 425 to two-factor authentication, authentication with cryptographic 426 credentials, and authentication processes that require multiple steps 427 can be hard or impossible (WebCrypto, WebAuthn). 429 3.5. Client Authentication 431 Authorization servers SHOULD use client authentication if possible. 433 It is RECOMMENDED to use asymmetric (public key based) methods for 434 client authentication such as MTLS [I-D.draft-ietf-oauth-mtls] or 435 "private_key_jwt" [OIDC]. When asymmetric methods for client 436 authentication are used, authorization servers do not need to store 437 sensitive symmetric keys, making these methods more robust against a 438 number of attacks. Additionally, these methods enable non-repudation 439 and work well with sender-constrained access tokens (without 440 requiring additional keys to be distributed). 442 3.6. Other Recommendations 444 Authorization servers SHOULD NOT allow clients to influence their 445 "client_id" or "sub" value or any other claim that might cause 446 confusion with a genuine resource owner (see Section 4.13). 448 4. Attacks and Mitigations 450 This section gives a detailed description of attacks on OAuth 451 implementations, along with potential countermeasures. This section 452 complements and enhances the description given in [RFC6819]. 454 4.1. Insufficient Redirect URI Validation 456 Some authorization servers allow clients to register redirect URI 457 patterns instead of complete redirect URIs. In those cases, the 458 authorization server, at runtime, matches the actual redirect URI 459 parameter value at the authorization endpoint against this pattern. 460 This approach allows clients to encode transaction state into 461 additional redirect URI parameters or to register just a single 462 pattern for multiple redirect URIs. As a downside, it turned out to 463 be more complex to implement and error prone to manage than exact 464 redirect URI matching. Several successful attacks, utilizing flaws 465 in the pattern matching implementation or concrete configurations, 466 have been observed in the wild. Insufficient validation of the 467 redirect URI effectively breaks client identification or 468 authentication (depending on grant and client type) and allows the 469 attacker to obtain an authorization code or access token, either 471 o by directly sending the user agent to a URI under the attackers 472 control, or 474 o by exposing the OAuth credentials to an attacker by utilizing an 475 open redirector at the client in conjunction with the way user 476 agents handle URL fragments. 478 4.1.1. Redirect URI Validation Attacks on Authorization Code Grant 480 For a public client using the grant type code, an attack would look 481 as follows: 483 Let's assume the redirect URL pattern "https://*.somesite.example/*" 484 had been registered for the client "s6BhdRkqt3". This pattern allows 485 redirect URIs pointing to any host residing in the domain 486 somesite.example. So if an attacker manages to establish a host or 487 subdomain in somesite.example he can impersonate the legitimate 488 client. Assume the attacker sets up the host 489 "evil.somesite.example". 491 The attack can then be conducted as follows: 493 First, the attacker needs to trick the user into opening a tampered 494 URL in his browser, which launches a page under the attacker's 495 control, say "https://www.evil.example". (See Attacker A1.) 497 This URL initiates an authorization request with the client id of a 498 legitimate client to the authorization endpoint. This is the example 499 authorization request (line breaks are for display purposes only): 501 GET /authorize?response_type=code&client_id=s6BhdRkqt3&state=9ad67f13 502 &redirect_uri=https%3A%2F%2Fevil.somesite.example%2Fcb HTTP/1.1 503 Host: server.somesite.example 505 Afterwards, the authorization server validates the redirect URI in 506 order to identify the client. Since the pattern allows arbitrary 507 host names in "somesite.example", the authorization request is 508 processed under the legitimate client's identity. This includes the 509 way the request for user consent is presented to the user. If auto- 510 approval is allowed (which is not recommended for public clients 511 according to [RFC6749]), the attack can be performed even easier. 513 If the user does not recognize the attack, the code is issued and 514 immediately sent to the attacker's client. 516 Since the attacker impersonated a public client, it can exchange the 517 code for tokens at the respective token endpoint. 519 Note: This attack will not work as easily for confidential clients, 520 since the code exchange requires authentication with the legitimate 521 client's secret. The attacker will need to impersonate or utilize 522 the legitimate client to redeem the code (e.g., by performing a code 523 injection attack). This kind of injections is covered in 524 Section 4.5. 526 4.1.2. Redirect URI Validation Attacks on Implicit Grant 528 The attack described above works for the implicit grant as well. If 529 the attacker is able to send the authorization response to a URI 530 under his control, he will directly get access to the fragment 531 carrying the access token. 533 Additionally, implicit clients can be subject to a further kind of 534 attack. It utilizes the fact that user agents re-attach fragments to 535 the destination URL of a redirect if the location header does not 536 contain a fragment (see [RFC7231], Section 9.5). The attack 537 described here combines this behavior with the client as an open 538 redirector in order to get access to access tokens. This allows 539 circumvention even of very narrow redirect URI patterns (but not 540 strict URL matching!). 542 Assume the pattern for client "s6BhdRkqt3" is 543 "https://client.somesite.example/cb?*", i.e., any parameter is 544 allowed for redirects to "https://client.somesite.example/cb". 545 Unfortunately, the client exposes an open redirector. This endpoint 546 supports a parameter "redirect_to" which takes a target URL and will 547 send the browser to this URL using an HTTP Location header redirect 548 303. 550 The attack can now be conducted as follows: 552 First, and as above, the attacker needs to trick the user into 553 opening a tampered URL in his browser, which launches a page under 554 the attacker's control, say "https://www.evil.example". 556 Afterwards, the website initiates an authorization request, which is 557 very similar to the one in the attack on the code flow. Different to 558 above, it utilizes the open redirector by encoding 559 "redirect_to=https://client.evil.example" into the redirect URI and 560 it uses the response type "token" (line breaks are for display 561 purposes only): 563 GET /authorize?response_type=token&state=9ad67f13 564 &client_id=s6BhdRkqt3 565 &redirect_uri=https%3A%2F%2Fclient.somesite.example 566 %2Fcb%26redirect_to%253Dhttps%253A%252F 567 %252Fclient.evil.example%252Fcb HTTP/1.1 568 Host: server.somesite.example 570 Now, since the redirect URI matches the registered pattern, the 571 authorization server allows the request and sends the resulting 572 access token with a 303 redirect (some response parameters are 573 omitted for better readability) 574 HTTP/1.1 303 See Other 575 Location: https://client.somesite.example/cb? 576 redirect_to%3Dhttps%3A%2F%2Fclient.evil.example%2Fcb 577 #access_token=2YotnFZFEjr1zCsicMWpAA&... 579 At example.com, the request arrives at the open redirector. It will 580 read the redirect parameter and will issue an HTTP 303 Location 581 header redirect to the URL "https://client.evil.example/cb". 583 HTTP/1.1 303 See Other 584 Location: https://client.evil.example/cb 586 Since the redirector at client.somesite.example does not include a 587 fragment in the Location header, the user agent will re-attach the 588 original fragment "#access_token=2YotnFZFEjr1zCsicMWpAA&..." to 589 the URL and will navigate to the following URL: 591 https://client.evil.example/cb#access_token=2YotnFZFEjr1z... 593 The attacker's page at "client.evil.example" can now access the 594 fragment and obtain the access token. 596 4.1.3. Proposed Countermeasures 598 The complexity of implementing and managing pattern matching 599 correctly obviously causes security issues. This document therefore 600 proposes to simplify the required logic and configuration by using 601 exact redirect URI matching only. This means the authorization 602 server must compare the two URIs using simple string comparison as 603 defined in [RFC3986], Section 6.2.1. 605 Additional recommendations: 607 o Servers on which callbacks are hosted must not expose open 608 redirectors (see Section 4.9). 610 o Clients MAY drop fragments via intermediary URLs with "fix 611 fragments" (see [fb_fragments]) to prevent the user agent from 612 appending any unintended fragments. 614 o Clients SHOULD use the authorization code response type instead of 615 response types causing access token issuance at the authorization 616 endpoint. This offers countermeasures against reuse of leaked 617 credentials through the exchange process with the authorization 618 server and token replay through certificate binding of the access 619 tokens. 621 As an alternative to exact redirect URI matching, the AS could also 622 authenticate clients, e.g., using [I-D.ietf-oauth-jwsreq]. 624 4.2. Credential Leakage via Referrer Headers 626 Authorization codes or values of "state" can unintentionally be 627 disclosed to attackers through the referrer header, by leaking either 628 from a client's web site or from an AS's web site. Note: even if 629 specified otherwise in [RFC7231], Section 5.5.2, the same may happen 630 to access tokens conveyed in URI fragments due to browser 631 implementation issues as illustrated by Chromium Issue 168213 632 [bug.chromium]. 634 4.2.1. Leakage from the OAuth Client 636 Leakage from the OAuth client requires that the client, as a result 637 of a successful authorization request, renders a page that 639 o contains links to other pages under the attacker's control (ads, 640 faq, ...) and a user clicks on such a link, or 642 o includes third-party content (iframes, images, etc.), for example 643 if the page contains user-generated content (blog). 645 As soon as the browser navigates to the attacker's page or loads the 646 third-party content, the attacker receives the authorization response 647 URL and can extract "code", "access token", or "state". 649 4.2.2. Leakage from the Authorization Server 651 In a similar way, an attacker can learn "state" if the authorization 652 endpoint at the authorization server contains links or third-party 653 content as above. 655 4.2.3. Consequences 657 An attacker that learns a valid code or access token through a 658 referrer header can perform the attacks as described in 659 Section 4.1.1, Section 4.5, and Section 4.6. If the attacker learns 660 "state", the CSRF protection achieved by using "state" is lost, 661 resulting in CSRF attacks as described in [RFC6819], Section 4.4.1.8. 663 4.2.4. Proposed Countermeasures 665 The page rendered as a result of the OAuth authorization response and 666 the authorization endpoint SHOULD NOT include third-party resources 667 or links to external sites. 669 The following measures further reduce the chances of a successful 670 attack: 672 o Bind authorization code to a confidential client or PKCE 673 challenge. In this case, the attacker lacks the secret to request 674 the code exchange. 676 o As described in [RFC6749], Section 4.1.2, authorization codes MUST 677 be invalidated by the AS after their first use at the token 678 endpoint. For example, if an AS invalidated the code after the 679 legitimate client redeemed it, the attacker would fail exchanging 680 this code later. 681 This does not mitigate the attack if the attacker manages to 682 exchange the code for a token before the legitimate client does 683 so. Therefore, [RFC6749] further recommends that, when an attempt 684 is made to redeem a code twice, the AS SHOULD revoke all tokens 685 issued previously based on that code. 687 o The "state" value SHOULD be invalidated by the client after its 688 first use at the redirection endpoint. If this is implemented, 689 and an attacker receives a token through the referrer header from 690 the client's web site, the "state" was already used, invalidated 691 by the client and cannot be used again by the attacker. (This 692 does not help if the "state" leaks from the AS's web site, since 693 then the "state" has not been used at the redirection endpoint at 694 the client yet.) 696 o Suppress the referrer header by adding the attribute 697 "rel="noreferrer"" to HTML links or by applying an appropriate 698 Referrer Policy [webappsec-referrer-policy] to the document 699 (either as part of the "referrer" meta attribute or by setting a 700 Referrer-Policy header). 702 o Use authorization code instead of response types causing access 703 token issuance from the authorization endpoint. This provides 704 countermeasures against leakage on the OAuth protocol level 705 through the code exchange process with the authorization server. 707 o Additionally, one might use the form post response mode instead of 708 redirect for authorization response (see 709 [oauth-v2-form-post-response-mode]). 711 4.3. Attacks through the Browser History 713 Authorization codes and access tokens can end up in the browser's 714 history of visited URLs, enabling the attacks described in the 715 following. 717 4.3.1. Code in Browser History 719 When a browser navigates to "client.example/ 720 redirection_endpoint?code=abcd" as a result of a redirect from a 721 provider's authorization endpoint, the URL including the 722 authorization code may end up in the browser's history. An attacker 723 with access to the device could obtain the code and try to replay it. 725 Proposed countermeasures: 727 o Authorization code replay prevention as described in [RFC6819], 728 Section 4.4.1.1, and Section 4.5 730 o Use form post response mode instead of redirect for authorization 731 response (see [oauth-v2-form-post-response-mode]) 733 4.3.2. Access Token in Browser History 735 An access token may end up in the browser history if a client or just 736 a web site, which already has a token, deliberately navigates to a 737 page like "provider.com/get_user_profile?access_token=abcdef.". 738 Actually [RFC6750] discourages this practice and asks to transfer 739 tokens via a header, but in practice web sites often just pass access 740 token in query parameters. 742 In case of implicit grant, a URL like "client.example/ 743 redirection_endpoint#access_token=abcdef" may also end up in the 744 browser history as a result of a redirect from a provider's 745 authorization endpoint. 747 Proposed countermeasures: 749 o Replace implicit flow with postmessage communication or the 750 authorization code grant 752 o Never pass access tokens in URL query parameters 754 4.4. Mix-Up 756 Mix-up is an attack on scenarios where an OAuth client interacts with 757 multiple authorization servers, as is usually the case when dynamic 758 registration is used. The goal of the attack is to obtain an 759 authorization code or an access token by tricking the client into 760 sending those credentials to the attacker instead of using them at 761 the respective endpoint at the authorization/resource server. 763 4.4.1. Attack Description 765 For a detailed attack description, refer to [arXiv.1601.01229] and 766 [I-D.ietf-oauth-mix-up-mitigation]. The description here closely 767 follows [arXiv.1601.01229], with variants of the attack outlined 768 below. 770 Preconditions: For the attack to work, we assume that 772 o the implicit or authorization code grant are used with multiple AS 773 of which one is considered "honest" (H-AS) and one is operated by 774 the attacker (A-AS), 776 o the client stores the AS chosen by the user in a session bound to 777 the user's browser and uses the same redirection endpoint URI for 778 each AS, and 780 o the attacker can manipulate the first request/response pair from a 781 user's browser to the client (in which the user selects a certain 782 AS and is then redirected by the client to that AS), as in 783 Attacker A2. 785 Some of the attack variants described below require different 786 preconditions. 788 In the following, we assume that the client is registered with H-AS 789 (URI: "https://honest.as.example", client id: "7ZGZldHQ") and with 790 A-AS (URI: "https://attacker.example", client id: "666RVZJTA"). 792 Attack on the authorization code grant: 794 1. The user selects to start the grant using H-AS (e.g., by clicking 795 on a button at the client's website). 797 2. The attacker intercepts this request and changes the user's 798 selection to "A-AS". 800 3. The client stores in the user's session that the user selected 801 "A-AS" and redirects the user to A-AS's authorization endpoint by 802 sending the response code "303 See Other" with a Location header 803 containing the URL "https://attacker.example/ 804 authorize?response_type=code&client_id=666RVZJTA". 806 4. Now the attacker intercepts this response and changes the 807 redirection such that the user is being redirected to H-AS. The 808 attacker also replaces the client id of the client at A-AS with 809 the client's id at H-AS. Therefore, the browser receives a 810 redirection ("303 See Other") with a Location header pointing to 811 "https://honest.as.example/ 812 authorize?response_type=code&client_id=7ZGZldHQ" 814 5. Now, the user authorizes the client to access her resources at 815 H-AS. H-AS issues a code and sends it (via the browser) back to 816 the client. 818 6. Since the client still assumes that the code was issued by A-AS, 819 it will try to redeem the code at A-AS's token endpoint. 821 7. The attacker therefore obtains code and can either exchange the 822 code for an access token (for public clients) or perform a code 823 injection attack as described in Section 4.5. 825 Variants: 827 o *Implicit Grant*: In the implicit grant, the attacker receives an 828 access token instead of the code; the rest of the attack works as 829 above. 831 o *Mix-Up Without Interception*: A variant of the above attack works 832 even if the first request/response pair cannot be intercepted (for 833 example, because TLS is used to protect these messages): Here, we 834 assume that the user wants to start the grant using A-AS (and not 835 H-AS, see Attacker A1). After the client redirected the user to 836 the authorization endpoint at A-AS, the attacker immediately 837 redirects the user to H-AS (changing the client id to "7ZGZldHQ"). 838 (A vigilant user might at this point detect that she intended to 839 use A-AS instead of H-AS.) The attack now proceeds exactly as in 840 Steps 3ff. of the attack description above. 842 o *Per-AS Redirect URIs*: If clients use different redirect URIs for 843 different ASs, do not store the selected AS in the user's session, 844 and ASs do not check the redirect URIs properly, attackers can 845 mount an attack called "Cross-Social Network Request Forgery". 846 Refer to [oauth_security_jcs_14] for details. 848 o *OpenID Connect*: There are several variants that can be used to 849 attack OpenID Connect. They are described in detail in 850 [arXiv.1704.08539], Appendix A, and [arXiv.1508.04324v2], 851 Section 6 ("Malicious Endpoints Attacks"). 853 4.4.2. Countermeasures 855 In scenarios where an OAuth client interacts with multiple 856 authorization servers, clients MUST prevent mix-up attacks. 858 Potential countermeasures: 860 o Configure authorization servers to return an AS identitifier 861 ("iss") and the "client_id" for which a code or token was issued 862 in the authorization response. This enables clients to compare 863 this data to their own client id and the "iss" identifier of the 864 AS it believed it sent the user agent to. This mitigation is 865 discussed in detail in [I-D.ietf-oauth-mix-up-mitigation]. In 866 OpenID Connect, if an ID token is returned in the authorization 867 response, it carries client id and issuer. It can be used for 868 this mitigation. 870 o As it can be seen in the preconditions of the attacks above, 871 clients can prevent mix-up attack by (1) using AS-specific 872 redirect URIs with exact redirect URI matching, (2) storing, for 873 each authorization request, the intended AS, and (3) comparing the 874 intended AS with the actual redirect URI where the authorization 875 response was received. 877 4.5. Authorization Code Injection 879 In such an attack, the adversary attempts to inject a stolen 880 authorization code into a legitimate client on a device under his 881 control. In the simplest case, the attacker would want to use the 882 code in his own client. But there are situations where this might 883 not be possible or intended. Examples are: 885 o The attacker wants to access certain functions in this particular 886 client. As an example, the attacker wants to impersonate his 887 victim in a certain app or on a certain web site. 889 o The code is bound to a particular confidential client and the 890 attacker is unable to obtain the required client credentials to 891 redeem the code himself. 893 o The authorization or resource servers are limited to certain 894 networks that the attacker is unable to access directly. 896 In the following attack description and discussion, we assume the 897 presence of a web or network attacker, but not of an attacker with 898 advanced capabilities (A3-A5). 900 4.5.1. Attack Description 902 The attack works as follows: 904 1. The attacker obtains an authorization code by performing any of 905 the attacks described above. 907 2. He performs a regular OAuth authorization process with the 908 legitimate client on his device. 910 3. The attacker injects the stolen authorization code in the 911 response of the authorization server to the legitimate client. 913 4. The client sends the code to the authorization server's token 914 endpoint, along with client id, client secret and actual 915 "redirect_uri". 917 5. The authorization server checks the client secret, whether the 918 code was issued to the particular client and whether the actual 919 redirect URI matches the "redirect_uri" parameter (see 920 [RFC6749]). 922 6. If all checks succeed, the authorization server issues access and 923 other tokens to the client, so now the attacker is able to 924 impersonate the legitimate user. 926 4.5.2. Discussion 928 Obviously, the check in step (5.) will fail if the code was issued to 929 another client id, e.g., a client set up by the attacker. The check 930 will also fail if the authorization code was already redeemed by the 931 legitimate user and was one-time use only. 933 An attempt to inject a code obtained via a manipulated redirect URI 934 should also be detected if the authorization server stored the 935 complete redirect URI used in the authorization request and compares 936 it with the "redirect_uri" parameter. 938 [RFC6749], Section 4.1.3, requires the AS to "... ensure that the 939 "redirect_uri" parameter is present if the "redirect_uri" parameter 940 was included in the initial authorization request as described in 941 Section 4.1.1, and if included ensure that their values are 942 identical.". In the attack scenario described above, the legitimate 943 client would use the correct redirect URI it always uses for 944 authorization requests. But this URI would not match the tampered 945 redirect URI used by the attacker (otherwise, the redirect would not 946 land at the attackers page). So the authorization server would 947 detect the attack and refuse to exchange the code. 949 Note: this check could also detect attempts to inject a code which 950 had been obtained from another instance of the same client on another 951 device, if certain conditions are fulfilled: 953 o the redirect URI itself needs to contain a nonce or another kind 954 of one-time use, secret data and 956 o the client has bound this data to this particular instance. 958 But this approach conflicts with the idea to enforce exact redirect 959 URI matching at the authorization endpoint. Moreover, it has been 960 observed that providers very often ignore the "redirect_uri" check 961 requirement at this stage, maybe because it doesn't seem to be 962 security-critical from reading the specification. 964 Other providers just pattern match the "redirect_uri" parameter 965 against the registered redirect URI pattern. This saves the 966 authorization server from storing the link between the actual 967 redirect URI and the respective authorization code for every 968 transaction. But this kind of check obviously does not fulfill the 969 intent of the spec, since the tampered redirect URI is not 970 considered. So any attempt to inject a code obtained using the 971 "client_id" of a legitimate client or by utilizing the legitimate 972 client on another device won't be detected in the respective 973 deployments. 975 It is also assumed that the requirements defined in [RFC6749], 976 Section 4.1.3, increase client implementation complexity as clients 977 need to memorize or re-construct the correct redirect URI for the 978 call to the tokens endpoint. 980 This document therefore recommends to instead bind every 981 authorization code to a certain client instance on a certain device 982 (or in a certain user agent) in the context of a certain transaction. 984 4.5.3. Proposed Countermeasures 986 There are multiple technical solutions to achieve this goal: 988 o *Nonce*: OpenID Connect's existing "nonce" parameter can be used 989 for the purpose of detecting authorization code injection attacks. 990 The "nonce" value is one-time use and created by the client. The 991 client is supposed to bind it to the user agent session and sends 992 it with the initial request to the OpenId Provider (OP). The OP 993 binds "nonce" to the authorization code and attests this binding 994 in the ID token, which is issued as part of the code exchange at 995 the token endpoint. If an attacker injected an authorization code 996 in the authorization response, the nonce value in the client 997 session and the nonce value in the ID token will not match and the 998 attack is detected. The assumption is that an attacker cannot get 999 hold of the user agent state on the victim's device, where he has 1000 stolen the respective authorization code. The main advantage of 1001 this option is that "nonce" is an existing feature used in the 1002 wild. On the other hand, leveraging "nonce" by the broader OAuth 1003 community would require AS and clients to adopt ID Tokens. 1005 o *Code-bound State*: The "state" parameter as specified in 1006 [RFC6749] could be used similarly to what is described above. 1007 This would require to add a further parameter "state" to the code 1008 exchange token endpoint request. The authorization server would 1009 then compare the "state" value it associated with the code and the 1010 "state" value in the parameter. If those values do not match, it 1011 is considered an attack and the request fails. The advantage of 1012 this approach would be to utilize an existing OAuth parameter. 1013 But it would also mean to re-interpret the purpose of "state" and 1014 to extend the token endpoint request. 1016 o *PKCE*: The PKCE parameter "code_challenge" along with the 1017 corresponding "code_verifier" as specified in [RFC7636] could be 1018 used in the same way as "nonce" or "state". In contrast to its 1019 original intention, the verifier check would fail although the 1020 client uses its correct verifier but the code is associated with a 1021 challenge, which does not match. PKCE is a deployed OAuth 1022 feature, even though it is used today to secure native apps only. 1024 o *Token Binding*: Token binding [I-D.ietf-oauth-token-binding] 1025 could also be used. In this case, the code would need to be bound 1026 to two legs, between user agent and AS and the user agent and the 1027 client. This requires further data (extension to response) to 1028 manifest binding id for particular code. Token binding is 1029 promising as a secure and convenient mechanism (due to its browser 1030 integration). As a challenge, it requires broad browser support 1031 and use with native apps is still under discussion. 1033 o *Per-instance client id/secret*: One could use per instance 1034 "client_id" and secrets and bind the code to the respective 1035 "client_id". Unfortunately, this does not fit into the web 1036 application programming model (would need to use per-user client 1037 IDs). 1039 PKCE seems to be the most obvious solution for OAuth clients as it is 1040 available and effectively used today for similar purposes for OAuth 1041 native apps whereas "nonce" is appropriate for OpenId Connect 1042 clients. 1044 Note on pre-warmed secrets: An attacker can circumvent the 1045 countermeasures described above if he is able to create or capture 1046 the respective secret or code_challenge on a device under his 1047 control, which is then used in the victim's authorization request. 1049 Exact redirect URI matching of authorization requests can prevent the 1050 attacker from using the pre-warmed secret in the faked authorization 1051 transaction on the victim's device. 1053 Unfortunately, it does not work for all kinds of OAuth clients. It 1054 is effective for web and JS apps and for native apps with claimed 1055 URLs. Attacks on native apps using custom schemes or redirect URIs 1056 on localhost cannot be prevented this way, except if the AS enforces 1057 one-time use for PKCE verifier or "nonce" values. 1059 4.6. Access Token Injection 1061 In such an attack, the adversary attempts to inject a stolen access 1062 token into a legitimate client on a device under his control. This 1063 will typically happen if the attacker wants to utilize a leaked 1064 access token to impersonate a user in a certain client. 1066 To conduct the attack, the adversary starts an OAuth flow with the 1067 client and modifies the authorization response by replacing the 1068 access token issued by the authorization server or directly makes up 1069 an authorization server response including the leaked access token. 1070 Since the response includes the state value generated by the client 1071 for this particular transaction, the client does not treat the 1072 response as a CSRF and will use the access token injected by the 1073 attacker. 1075 4.6.1. Proposed Countermeasures 1077 There is no way to detect such an injection attack on the OAuth 1078 protocol level, since the token is issued without any binding to the 1079 transaction or the particular user agent. 1081 The recommendation is therefore to use the authorization code grant 1082 type instead of relying on response types issuing acess tokens at the 1083 authorization endpoint. Code injection can be detected using one of 1084 the countermeasures discussed in Section 4.5. 1086 4.7. Cross Site Request Forgery 1088 An attacker might attempt to inject a request to the redirect URI of 1089 the legitimate client on the victim's device, e.g., to cause the 1090 client to access resources under the attacker's control. 1092 4.7.1. Proposed Countermeasures 1094 Use of CSRF tokens which are bound to the user agent and passed in 1095 the "state" parameter to the authorization server as described in 1096 [!@RFC6819]. Alternatively, PKCE provides CSRF protection. 1098 It is important to note that: 1100 o Clients MUST ensure that the AS supports PKCE before using PKCE 1101 for CSRF protection. If an authorization server does not support 1102 PKCE, "state" MUST be used for CSRF protection. 1104 o If "state" is used for carrying application state, and integrity 1105 of its contents is a concern, clients MUST protect state against 1106 tampering and swapping. This can be achieved by binding the 1107 contents of state to the browser session and/or signed/encrypted 1108 state values [I-D.bradley-oauth-jwt-encoded-state]. 1110 The recommendation therefore is that AS publish their PKCE support 1111 either in AS metadata according to [RFC8418] or provide a deployment- 1112 specific way to ensure or determine PKCE support. 1114 Additionally, standard CSRF defenses MAY be used to protect the 1115 redirection endpoint, for example the Origin header. 1117 For more details see [owasp_csrf]. 1119 4.8. Access Token Leakage at the Resource Server 1121 Access tokens can leak from a resource server under certain 1122 circumstances. 1124 4.8.1. Access Token Phishing by Counterfeit Resource Server 1126 An attacker may setup his own resource server and trick a client into 1127 sending access tokens to it that are valid for other resource servers 1128 (see Attackers A1 and A5). If the client sends a valid access token 1129 to this counterfeit resource server, the attacker in turn may use 1130 that token to access other services on behalf of the resource owner. 1132 This attack assumes the client is not bound to one specific resource 1133 server (and its URL) at development time, but client instances are 1134 provided with the resource server URL at runtime. This kind of late 1135 binding is typical in situations where the client uses a service 1136 implementing a standardized API (e.g., for e-Mail, calendar, health, 1137 or banking) and where the client is configured by a user or 1138 administrator for a service which this user or company uses. 1140 There are several potential mitigation strategies, which will be 1141 discussed in the following sections. 1143 4.8.1.1. Metadata 1145 An authorization server could provide the client with additional 1146 information about the location where it is safe to use its access 1147 tokens. 1149 In the simplest form, this would require the AS to publish a list of 1150 its known resource servers, illustrated in the following example 1151 using a metadata parameter "resource_servers": 1153 HTTP/1.1 200 OK 1154 Content-Type: application/json 1156 { 1157 "issuer":"https://server.somesite.example", 1158 "authorization_endpoint": 1159 "https://server.somesite.example/authorize", 1160 "resource_servers":[ 1161 "email.somesite.example", 1162 "storage.somesite.example", 1163 "video.somesite.example" 1164 ] 1165 ... 1166 } 1168 The AS could also return the URL(s) an access token is good for in 1169 the token response, illustrated by the example return parameter 1170 "access_token_resource_server": 1172 HTTP/1.1 200 OK 1173 Content-Type: application/json;charset=UTF-8 1174 Cache-Control: no-store 1175 Pragma: no-cache 1177 { 1178 "access_token":"2YotnFZFEjr1zCsicMWpAA", 1179 "access_token_resource_server": 1180 "https://hostedresource.somesite.example/path1", 1181 ... 1182 } 1184 This mitigation strategy would rely on the client to enforce the 1185 security policy and to only send access tokens to legitimate 1186 destinations. Results of OAuth related security research (see for 1187 example [oauth_security_ubc] and [oauth_security_cmu]) indicate a 1188 large portion of client implementations do not or fail to properly 1189 implement security controls, like "state" checks. So relying on 1190 clients to prevent access token phishing is likely to fail as well. 1191 Moreover given the ratio of clients to authorization and resource 1192 servers, it is considered the more viable approach to move as much as 1193 possible security-related logic to those entities. Clearly, the 1194 client has to contribute to the overall security. But there are 1195 alternative countermeasures, as described in the next sections, which 1196 provide a better balance between the involved parties. 1198 4.8.1.2. Sender-Constrained Access Tokens 1200 As the name suggests, sender-constrained access token scope the 1201 applicability of an access token to a certain sender. This sender is 1202 obliged to demonstrate knowledge of a certain secret as prerequisite 1203 for the acceptance of that token at a resource server. 1205 A typical flow looks like this: 1207 1. The authorization server associates data with the access token 1208 which binds this particular token to a certain client. The 1209 binding can utilize the client identity, but in most cases the AS 1210 utilizes key material (or data derived from the key material) 1211 known to the client. 1213 2. This key material must be distributed somehow. Either the key 1214 material already exists before the AS creates the binding or the 1215 AS creates ephemeral keys. The way pre-existing key material is 1216 distributed varies among the different approaches. For example, 1217 X.509 Certificates can be used in which case the distribution 1218 happens explicitly during the enrollment process. Or the key 1219 material is created and distributed at the TLS layer, in which 1220 case it might automatically happen during the setup of a TLS 1221 connection. 1223 3. The RS must implement the actual proof of possession check. This 1224 is typically done on the application level, it may utilize 1225 capabilities of the transport layer (e.g., TLS). Note: replay 1226 prevention is required as well! 1228 There exist several proposals to demonstrate the proof of possession 1229 in the scope of the OAuth working group: 1231 o *OAuth Token Binding* ([I-D.ietf-oauth-token-binding]): In this 1232 approach, an access token is, via the so-called token binding id, 1233 bound to key material representing a long term association between 1234 a client and a certain TLS host. Negotiation of the key material 1235 and proof of possession in the context of a TLS handshake is taken 1236 care of by the TLS stack. The client needs to determine the token 1237 binding id of the target resource server and pass this data to the 1238 access token request. The authorization server then associates 1239 the access token with this id. The resource server checks on 1240 every invocation that the token binding id of the active TLS 1241 connection and the token binding id of associated with the access 1242 token match. Since all crypto-related functions are covered by 1243 the TLS stack, this approach is very client developer friendly. 1244 As a prerequisite, token binding as described in [RFC8473] 1245 (including federated token bindings) must be supported on all ends 1246 (client, authorization server, resource server). 1248 o *OAuth Mutual TLS* ([I-D.ietf-oauth-mtls]): The approach as 1249 specified in this document allows the use of mutual TLS (mTLS) for 1250 both client authentication and sender-constrained access tokens. 1251 For the purpose of sender-constrained access tokens, the client is 1252 identified towards the resource server by the fingerprint of its 1253 public key. During processing of an access token request, the 1254 authorization server obtains the client's public key from the TLS 1255 stack and associates its fingerprint with the respective access 1256 tokens. The resource server in the same way obtains the public 1257 key from the TLS stack and compares its fingerprint with the 1258 fingerprint associated with the access token. 1260 o *Signed HTTP Requests* ([I-D.ietf-oauth-signed-http-request]): 1261 This approach utilizes [I-D.ietf-oauth-pop-key-distribution] and 1262 represents the elements of the signature in a JSON object. The 1263 signature is built using JWS. The mechanism has built-in support 1264 for signing of HTTP method, query parameters and headers. It also 1265 incorporates a timestamp as basis for replay prevention. 1267 o *JWT Pop Tokens* ([I-D.sakimura-oauth-jpop]): This draft describes 1268 different ways to constrain access token usage, namely TLS or 1269 request signing. Note: Since the authors of this draft 1270 contributed the TLS-related proposal to [I-D.ietf-oauth-mtls], 1271 this document only considers the request signing part. For 1272 request signing, the draft utilizes 1273 [I-D.ietf-oauth-pop-key-distribution] and [RFC7800]. The 1274 signature data is represented in a JWT and JWS is used for 1275 signing. Replay prevention is provided by building the signature 1276 over a server-provided nonce, client-provided nonce and a nonce 1277 counter. 1279 Mutual TLS and OAuth Token Binding are built on top of TLS and this 1280 way continue the successful OAuth 2.0 philosophy to leverage TLS to 1281 secure OAuth wherever possible. Both mechanisms allow prevention of 1282 access token leakage in a fairly client developer friendly way. 1284 There are some differences between both approaches: To start with, 1285 for OAuth Token Binding, all key material is automatically managed by 1286 the TLS stack whereas mTLS requires the developer to create and 1287 maintain the key pairs and respective certificates. Use of self- 1288 signed certificates, which is supported by the draft, significantly 1289 reduces the complexity of this task. Furthermore, OAuth Token 1290 Binding allows to use different key pairs for different resource 1291 servers, which is a privacy benefit. On the other hand, 1293 [I-D.ietf-oauth-mtls] only requires widely deployed TLS features, 1294 which means it might be easier to adopt in the short term. 1296 Application level signing approaches, like 1297 [I-D.ietf-oauth-signed-http-request] and [I-D.sakimura-oauth-jpop] 1298 have been debated for a long time in the OAuth working group without 1299 a clear outcome. 1301 As one advantage, application-level signing allows for end-to-end 1302 protection including non-repudiation even if the TLS connection is 1303 terminated between client and resource server. But deployment 1304 experiences have revealed challenges regarding robustness (e.g., 1305 reproduction of the signature base string including correct URL) as 1306 well as state management (e.g., replay prevention). 1308 This document therefore recommends implementors to consider one of 1309 TLS-based approaches wherever possible. 1311 4.8.1.3. Audience Restricted Access Tokens 1313 An audience restriction essentially restricts the resource server a 1314 particular access token can be used at. The authorization server 1315 associates the access token with a certain resource server and every 1316 resource server is obliged to verify for every request, whether the 1317 access token sent with that request was meant to be used at the 1318 particular resource server. If not, the resource server must refuse 1319 to serve the respective request. In the general case, audience 1320 restrictions limit the impact of a token leakage. In the case of a 1321 counterfeit resource server, it may (as described below) also prevent 1322 abuse of the phished access token at the legitimate resource server. 1324 The audience can basically be expressed using logical names or 1325 physical addresses (like URLs). In order to prevent phishing, it is 1326 necessary to use the actual URL the client will send requests to. In 1327 the phishing case, this URL will point to the counterfeit resource 1328 server. If the attacker tries to use the access token at the 1329 legitimate resource server (which has a different URL), the resource 1330 server will detect the mismatch (wrong audience) and refuse to serve 1331 the request. 1333 In deployments where the authorization server knows the URLs of all 1334 resource servers, the authorization server may just refuse to issue 1335 access tokens for unknown resource server URLs. 1337 The client needs to tell the authorization server, at which URL it 1338 will use the access token it is requesting. It could use the 1339 mechanism proposed [I-D.ietf-oauth-resource-indicators] or encode the 1340 information in the scope value. 1342 Instead of the URL, it is also possible to utilize the fingerprint of 1343 the resource server's X.509 certificate as audience value. This 1344 variant would also allow to detect an attempt to spoof the legit 1345 resource server's URL by using a valid TLS certificate obtained from 1346 a different CA. It might also be considered a privacy benefit to 1347 hide the resource server URL from the authorization server. 1349 Audience restriction seems easy to use since it does not require any 1350 crypto on the client side. But since every access token is bound to 1351 a certain resource server, the client also needs to obtain different 1352 RS-specific access tokens, if it wants to access several resource 1353 services. [I-D.ietf-oauth-token-binding] has the same property, 1354 since different token binding ids must be associated with the access 1355 token. [I-D.ietf-oauth-mtls] on the other hand allows a client to 1356 use the access token at multiple resource servers. 1358 It shall be noted that audience restrictions, or generally speaking 1359 an indication by the client to the authorization server where it 1360 wants to use the access token, has additional benefits beyond the 1361 scope of token leakage prevention. It allows the authorization 1362 server to create different access token whose format and content is 1363 specifically minted for the respective server. This has huge 1364 functional and privacy advantages in deployments using structured 1365 access tokens. 1367 4.8.2. Compromised Resource Server 1369 An attacker may compromise a resource server in order to get access 1370 to its resources and other resources of the respective deployment. 1371 Such a compromise may range from partial access to the system, e.g., 1372 its logfiles, to full control of the respective server. 1374 If the attacker was able to take over full control including shell 1375 access it will be able to circumvent all controls in place and access 1376 resources without access control. It will also get access to access 1377 tokens, which are sent to the compromised system and which 1378 potentially are valid for access to other resource servers as well. 1379 Even if the attacker "only" is able to access logfiles or databases 1380 of the server system, it may get access to valid access tokens. 1382 Preventing server breaches by way of hardening and monitoring server 1383 systems is considered a standard operational procedure and therefore 1384 out of scope of this document. This section will focus on the impact 1385 of such breaches on OAuth-related parts of the ecosystem, which is 1386 the replay of captured access tokens on the compromised resource 1387 server and other resource servers of the respective deployment. 1389 The following measures should be taken into account by implementors 1390 in order to cope with access token replay: 1392 o The resource server must treat access tokens like any other 1393 credentials. It is considered good practice to not log them and 1394 not to store them in plain text. 1396 o Sender-constrained access tokens as described in Section 4.8.1.2 1397 will prevent the attacker from replaying the access tokens on 1398 other resource servers. Depending on the severity of the 1399 penetration, it will also prevent replay on the compromised 1400 system. 1402 o Audience restriction as described in Section 4.8.1.3 may be used 1403 to prevent replay of captured access tokens on other resource 1404 servers. 1406 4.9. Open Redirection 1408 The following attacks can occur when an AS or client has an open 1409 redirector, i.e., a URL which causes an HTTP redirect to an attacker- 1410 controlled web site. 1412 4.9.1. Authorization Server as Open Redirector 1414 Attackers could try to utilize a user's trust in the authorization 1415 server (and its URL in particular) for performing phishing attacks. 1417 [RFC6749], Section 4.1.2.1, already prevents open redirects by 1418 stating the AS MUST NOT automatically redirect the user agent in case 1419 of an invalid combination of client_id and redirect_uri. 1421 However, as described in [I-D.ietf-oauth-closing-redirectors], an 1422 attacker could also utilize a correctly registered redirect URI to 1423 perform phishing attacks. It could for example register a client via 1424 dynamic client registration [RFC7591] and intentionally send an 1425 erroneous authorization request, e.g., by using an invalid scope 1426 value, to cause the AS to automatically redirect the user agent to 1427 its phishing site. 1429 The AS MUST take precautions to prevent this threat. Based on its 1430 risk assessment the AS needs to decide whether it can trust the 1431 redirect URI or not and SHOULD only automatically redirect the user 1432 agent, if it trusts the redirect URI. If not, it MAY inform the user 1433 that it is about to redirect her to the another site and rely on the 1434 user to decide or MAY just inform the user about the error. 1436 4.9.2. Clients as Open Redirector 1438 Client MUST NOT expose URLs which could be utilized as open 1439 redirector. Attackers may use an open redirector to produce URLs 1440 which appear to point to the client, which might trick users to trust 1441 the URL and follow it in her browser. Another abuse case is to 1442 produce URLs pointing to the client and utilize them to impersonate a 1443 client with an authorization server. 1445 In order to prevent open redirection, clients should only expose such 1446 a function, if the target URLs are whitelisted or if the origin of a 1447 request can be authenticated. 1449 4.10. 307 Redirect 1451 At the authorization endpoint, a typical protocol flow is that the AS 1452 prompts the user to enter her credentials in a form that is then 1453 submitted (using the HTTP POST method) back to the authorization 1454 server. The AS checks the credentials and, if successful, redirects 1455 the user agent to the client's redirection endpoint. 1457 In [RFC6749], the HTTP status code 302 is used for this purpose, but 1458 "any other method available via the user-agent to accomplish this 1459 redirection is allowed". However, when the status code 307 is used 1460 for redirection, the user agent will send the form data (user 1461 credentials) via HTTP POST to the client since this status code does 1462 not require the user agent to rewrite the POST request to a GET 1463 request (and thereby dropping the form data in the POST request 1464 body). If the relying party is malicious, it can use the credentials 1465 to impersonate the user at the AS. 1467 In the HTTP standard [RFC6749], only the status code 303 1468 unambigiously enforces rewriting the HTTP POST request to an HTTP GET 1469 request. For all other status codes, including the popular 302, user 1470 agents can opt not to rewrite POST to GET requests and therefore to 1471 reveal the user credentials to the client. (In practice, however, 1472 most user agents will only show this behaviour for 307 redirects.) 1474 AS which redirect a request that potentially contains user 1475 credentials therefore MUST NOT use the HTTP 307 status code for 1476 redirection. If an HTTP redirection (and not, for example, 1477 JavaScript) is used for such a request, AS SHOULD use HTTP status 1478 code 303 "See Other". 1480 4.11. TLS Terminating Reverse Proxies 1482 A common deployment architecture for HTTP applications is to have the 1483 application server sitting behind a reverse proxy which terminates 1484 the TLS connection and dispatches the incoming requests to the 1485 respective application server nodes. 1487 This section highlights some attack angles of this deployment 1488 architecture which are relevant to OAuth, and gives recommendations 1489 for security controls. 1491 In some situations, the reverse proxy needs to pass security-related 1492 data to the upstream application servers for further processing. 1493 Examples include the IP address of the request originator, token 1494 binding ids, and authenticated TLS client certificates. 1496 If the reverse proxy would pass through any header sent from the 1497 outside, an attacker could try to directly send the faked header 1498 values through the proxy to the application server in order to 1499 circumvent security controls that way. For example, it is standard 1500 practice of reverse proxies to accept "forwarded_for" headers and 1501 just add the origin of the inbound request (making it a list). 1502 Depending on the logic performed in the application server, the 1503 attacker could simply add a whitelisted IP address to the header and 1504 render a IP whitelist useless. A reverse proxy must therefore 1505 sanitize any inbound requests to ensure the authenticity and 1506 integrity of all header values relevant for the security of the 1507 application servers. 1509 If an attacker was able to get access to the internal network between 1510 proxy and application server, he could also try to circumvent 1511 security controls in place. It is therefore important to ensure the 1512 authenticity of the communicating entities. Furthermore, the 1513 communication link between reverse proxy and application server must 1514 therefore be protected against eavesdropping, injection, and replay 1515 of messages. 1517 4.12. Refresh Token Protection 1519 Refresh tokens are a convenient and UX-friendly way to obtain new 1520 access tokens after the expiration of older access tokens. Refresh 1521 tokens also add to the security of OAuth since they allow the 1522 authorization server to issue access tokens with a short lifetime and 1523 reduced scope thus reducing the potential impact of access token 1524 leakage. 1526 Refresh tokens are an attractive target for attackers since they 1527 represent the overall grant a resource owner delegated to a certain 1528 client. If an attacker is able to exfiltrate and successfully replay 1529 a refresh token, the attacker will be able to mint access tokens and 1530 use them to access resource servers on behalf of the resource owner. 1532 [RFC6749] already provides a robust baseline protection by requiring 1534 o confidentiality of the refresh tokens in transit and storage, 1536 o the transmission of refresh tokens over TLS-protected connections 1537 between authorization server and client, 1539 o the authorization server to maintain and check the binding of a 1540 refresh token to a certain client (i.e., "client_id"), 1542 o authentication of this client during token refresh, if possible, 1543 and 1545 o that refresh tokens cannot be generated, modified, or guessed. 1547 [RFC6749] also lays the foundation for further (implementation 1548 specific) security measures, such as refresh token expiration and 1549 revocation as well as refresh token rotation by defining respective 1550 error codes and response behavior. 1552 This draft gives recommendations beyond the scope of [RFC6749] and 1553 clarifications. 1555 Authorization servers MUST determine based on their risk assessment 1556 whether to issue refresh tokens to a certain client. If the 1557 authorization server decides not to issue refresh tokens, the client 1558 may refresh access tokens by utilizing other grant types, such as the 1559 authorization code grant type. In such a case, the authorization 1560 server may utilize cookies and persistent grants to optimize the user 1561 experience. 1563 If refresh tokens are issued, those refresh tokens MUST be bound to 1564 the scope and resource servers as consented by the resource owner. 1565 This is to prevent privilege escalation by the legit client and 1566 reduce the impact of refresh token leakage. 1568 Authorization server MUST utilize one of these methods to detect 1569 refresh token replay for public clients: 1571 o *Sender-constrained refresh tokens:* the authorization server 1572 cryptographically binds the refresh token to a certain client 1573 instance by utilizing [I-D.ietf-oauth-token-binding] or 1574 [I-D.ietf-oauth-mtls]. 1576 o *Refresh token rotation:* the authorization server issues a new 1577 refresh token with every access token refresh response. The 1578 previous refresh token is invalidated but information about the 1579 relationship is retained by the authorization server. If a 1580 refresh token is compromised and subsequently used by both the 1581 attacker and the legitimate client, one of them will present an 1582 invalidated refresh token, which will inform the authorization 1583 server of the breach. The authorization server cannot determine 1584 which party submitted the invalid refresh token, but it can revoke 1585 the active refresh token. This stops the attack at the cost of 1586 forcing the legit client to obtain a fresh authorization grant. 1587 Implementation note: refresh tokens belonging to the same grant 1588 may share a common id. If any of those refresh tokens is used at 1589 the authorization server, the authorization server uses this 1590 common id to look up the currently active refresh token and can 1591 revoke it. 1593 Authorization servers may revoke refresh tokens automatically in case 1594 of a security event, such as: 1596 o password change 1598 o logout at the authorization server 1600 Refresh tokens SHOULD expire if the client has been inactive for some 1601 time, i.e., the refresh token has not been used to obtain fresh 1602 access tokens for some time. The expiration time is at the 1603 discretion of the authorization server. It might be a global value 1604 or determined based on the client policy or the grant associated with 1605 the refresh token (and its sensitivity). 1607 4.13. Client Impersonating Resource Owner 1609 Resource servers may make access control decisions based on the 1610 identity of the resource owner as communicated in the "sub" claim 1611 returned by the authorization server in a token introspection 1612 response [RFC7662] or other mechanism. If a client is able to choose 1613 its own "client_id" during registration with the authorization 1614 server, then there is a risk that it can register with the same "sub" 1615 value as a privileged user. A subsequent access token obtained under 1616 the client credentials grant may be mistaken as an access token 1617 authorized by the privileged user if the resource server does not 1618 perform additional checks. 1620 4.13.1. Proposed Countermeasures 1622 Authorization servers SHOULD NOT allow clients to influence their 1623 "client_id" or "sub" value or any other claim that might cause 1624 confusion with a genuine resource owner. Where this cannot be 1625 avoided, authorization servers MUST provide another means for the 1626 resource server to distinguish between access tokens authorized by a 1627 resource owner from access tokens authorized by the client itself. 1629 5. Acknowledgements 1631 We would like to thank Jim Manico, Phil Hunt, Nat Sakimura, Christian 1632 Mainka, Doug McDorman, Johan Peeters, Joseph Heenan, Brock Allen, 1633 Vittorio Bertocci, David Waite, Nov Matake, Tomek Stojecki, Dominick 1634 Baier, Neil Madden, William Dennis, Dick Hardt, Petteri Stenius, 1635 Annabelle Richard Backman, Aaron Parecki, George Fletscher, Brian 1636 Campbell, Konstantin Lapine, and Tim Wuertele for their valuable 1637 feedback. 1639 6. IANA Considerations 1641 This draft includes no request to IANA. 1643 7. Security Considerations 1645 All relevant security considerations have been given in the 1646 functional specification. 1648 8. References 1650 8.1. Normative References 1652 [oauth-v2-form-post-response-mode] 1653 Jones, M. and B. Campbell, "OAuth 2.0 Form Post Response 1654 Mode", April 2015, . 1657 [OpenID] Sakimura, N., Bradley, J., Jones, M., de Medeiros, B., and 1658 C. Mortimore, "OpenID Connect Core 1.0 incorporating 1659 errata set 1", Nov 2014, 1660 . 1662 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 1663 Resource Identifier (URI): Generic Syntax", STD 66, 1664 RFC 3986, DOI 10.17487/RFC3986, January 2005, 1665 . 1667 [RFC6749] Hardt, D., Ed., "The OAuth 2.0 Authorization Framework", 1668 RFC 6749, DOI 10.17487/RFC6749, October 2012, 1669 . 1671 [RFC6750] Jones, M. and D. Hardt, "The OAuth 2.0 Authorization 1672 Framework: Bearer Token Usage", RFC 6750, 1673 DOI 10.17487/RFC6750, October 2012, 1674 . 1676 [RFC6819] Lodderstedt, T., Ed., McGloin, M., and P. Hunt, "OAuth 2.0 1677 Threat Model and Security Considerations", RFC 6819, 1678 DOI 10.17487/RFC6819, January 2013, 1679 . 1681 [RFC7636] Sakimura, N., Ed., Bradley, J., and N. Agarwal, "Proof Key 1682 for Code Exchange by OAuth Public Clients", RFC 7636, 1683 DOI 10.17487/RFC7636, September 2015, 1684 . 1686 [RFC7662] Richer, J., Ed., "OAuth 2.0 Token Introspection", 1687 RFC 7662, DOI 10.17487/RFC7662, October 2015, 1688 . 1690 [RFC8418] Housley, R., "Use of the Elliptic Curve Diffie-Hellman Key 1691 Agreement Algorithm with X25519 and X448 in the 1692 Cryptographic Message Syntax (CMS)", RFC 8418, 1693 DOI 10.17487/RFC8418, August 2018, 1694 . 1696 8.2. Informative References 1698 [arXiv.1508.04324v2] 1699 Mladenov, V., Mainka, C., and J. Schwenk, "On the security 1700 of modern Single Sign-On Protocols: Second-Order 1701 Vulnerabilities in OpenID Connect", January 2016, 1702 . 1704 [arXiv.1601.01229] 1705 Fett, D., Kuesters, R., and G. Schmitz, "A Comprehensive 1706 Formal Security Analysis of OAuth 2.0", January 2016, 1707 . 1709 [arXiv.1704.08539] 1710 Fett, D., Kuesters, R., and G. Schmitz, "The Web SSO 1711 Standard OpenID Connect: In-Depth Formal Security Analysis 1712 and Security Guidelines", April 2017, 1713 . 1715 [arXiv.1901.11520] 1716 Fett, D., Hosseyni, P., and R. Kuesters, "An Extensive 1717 Formal Security Analysis of the OpenID Financial-grade 1718 API", January 2019, . 1720 [bug.chromium] 1721 "Referer header includes URL fragment when opening link 1722 using New Tab", 1723 . 1726 [fb_fragments] 1727 "Facebook Developer Blog", 1728 . 1730 [I-D.bradley-oauth-jwt-encoded-state] 1731 Bradley, J., Lodderstedt, T., and H. Zandbelt, "Encoding 1732 claims in the OAuth 2 state parameter using a JWT", draft- 1733 bradley-oauth-jwt-encoded-state-09 (work in progress), 1734 November 2018. 1736 [I-D.ietf-oauth-closing-redirectors] 1737 Bradley, J., Sanso, A., and H. Tschofenig, "OAuth 2.0 1738 Security: Closing Open Redirectors in OAuth", draft-ietf- 1739 oauth-closing-redirectors-00 (work in progress), February 1740 2016. 1742 [I-D.ietf-oauth-jwsreq] 1743 Sakimura, N. and J. Bradley, "The OAuth 2.0 Authorization 1744 Framework: JWT Secured Authorization Request (JAR)", 1745 draft-ietf-oauth-jwsreq-19 (work in progress), June 2019. 1747 [I-D.ietf-oauth-mix-up-mitigation] 1748 Jones, M., Bradley, J., and N. Sakimura, "OAuth 2.0 Mix-Up 1749 Mitigation", draft-ietf-oauth-mix-up-mitigation-01 (work 1750 in progress), July 2016. 1752 [I-D.ietf-oauth-mtls] 1753 Campbell, B., Bradley, J., Sakimura, N., and T. 1754 Lodderstedt, "OAuth 2.0 Mutual TLS Client Authentication 1755 and Certificate-Bound Access Tokens", draft-ietf-oauth- 1756 mtls-15 (work in progress), July 2019. 1758 [I-D.ietf-oauth-pop-key-distribution] 1759 Bradley, J., Hunt, P., Jones, M., Tschofenig, H., and M. 1760 Meszaros, "OAuth 2.0 Proof-of-Possession: Authorization 1761 Server to Client Key Distribution", draft-ietf-oauth-pop- 1762 key-distribution-07 (work in progress), March 2019. 1764 [I-D.ietf-oauth-resource-indicators] 1765 Campbell, B., Bradley, J., and H. Tschofenig, "Resource 1766 Indicators for OAuth 2.0", draft-ietf-oauth-resource- 1767 indicators-02 (work in progress), January 2019. 1769 [I-D.ietf-oauth-signed-http-request] 1770 Richer, J., Bradley, J., and H. Tschofenig, "A Method for 1771 Signing HTTP Requests for OAuth", draft-ietf-oauth-signed- 1772 http-request-03 (work in progress), August 2016. 1774 [I-D.ietf-oauth-token-binding] 1775 Jones, M., Campbell, B., Bradley, J., and W. Denniss, 1776 "OAuth 2.0 Token Binding", draft-ietf-oauth-token- 1777 binding-08 (work in progress), October 2018. 1779 [I-D.sakimura-oauth-jpop] 1780 Sakimura, N., Li, K., and J. Bradley, "The OAuth 2.0 1781 Authorization Framework: JWT Pop Token Usage", draft- 1782 sakimura-oauth-jpop-04 (work in progress), March 2017. 1784 [oauth_security_cmu] 1785 Chen, E., Pei, Y., Chen, S., Tian, Y., Kotcher, R., and P. 1786 Tague, "OAuth Demystified for Mobile Application 1787 Developers", November 2014. 1789 [oauth_security_jcs_14] 1790 Bansal, C., Bhargavan, K., Delignat-Lavaud, A., and S. 1791 Maffeis, "Discovering concrete attacks on website 1792 authorization by formal analysis", April 2014. 1794 [oauth_security_ubc] 1795 Sun, S. and K. Beznosov, "The Devil is in the 1796 (Implementation) Details: An Empirical Analysis of OAuth 1797 SSO Systems", October 2012, 1798 . 1800 [owasp] "Open Web Application Security Project Home Page", 1801 . 1803 [owasp_csrf] 1804 "Cross-Site Request Forgery (CSRF) Prevention Cheat 1805 Sheet", . 1808 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1809 Requirement Levels", BCP 14, RFC 2119, 1810 DOI 10.17487/RFC2119, March 1997, 1811 . 1813 [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 1814 Protocol (HTTP/1.1): Semantics and Content", RFC 7231, 1815 DOI 10.17487/RFC7231, June 2014, 1816 . 1818 [RFC7591] Richer, J., Ed., Jones, M., Bradley, J., Machulak, M., and 1819 P. Hunt, "OAuth 2.0 Dynamic Client Registration Protocol", 1820 RFC 7591, DOI 10.17487/RFC7591, July 2015, 1821 . 1823 [RFC7800] Jones, M., Bradley, J., and H. Tschofenig, "Proof-of- 1824 Possession Key Semantics for JSON Web Tokens (JWTs)", 1825 RFC 7800, DOI 10.17487/RFC7800, April 2016, 1826 . 1828 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 1829 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 1830 May 2017, . 1832 [RFC8414] Jones, M., Sakimura, N., and J. Bradley, "OAuth 2.0 1833 Authorization Server Metadata", RFC 8414, 1834 DOI 10.17487/RFC8414, June 2018, 1835 . 1837 [RFC8473] Popov, A., Nystroem, M., Balfanz, D., Ed., Harper, N., and 1838 J. Hodges, "Token Binding over HTTP", RFC 8473, 1839 DOI 10.17487/RFC8473, October 2018, 1840 . 1842 [webappsec-referrer-policy] 1843 Eisinger, J. and E. Stark, "Referrer Policy", April 2017, 1844 . 1846 Appendix A. Document History 1848 [[ To be removed from the final specification ]] 1850 -13 1852 o Discourage use of Resource Owner Password Credentials Grant 1854 o Added text on client impersonating resource owner 1856 o Recommend asymmetric methods for client authentication 1858 o Encourage use of PKCE mode "S256" 1860 o PKCE may replace state for CSRF protection 1861 o AS SHOULD publish PKCE support 1863 o Cleaned up discussion on auth code injection 1865 o AS MUST support PKCE 1867 -12 1869 o Added updated attacker model 1871 -11 1873 o Adapted section 2.1.2 to outcome of consensus call 1875 o more text on refresh token inactivity and implementation note on 1876 refresh token replay detection via refresh token rotation 1878 -10 1880 o incorporated feedback by Joseph Heenan 1882 o changed occurrences of SHALL to MUST 1884 o added text on lack of token/cert binding support tokens issued in 1885 the authorization response as justification to not recommend 1886 issuing tokens there at all 1888 o added requirement to authenticate clients during code exchange 1889 (PKCE or client credential) to 2.1.1. 1891 o added section on refresh tokens 1893 o editorial enhancements to 2.1.2 based on feedback 1895 -09 1897 o changed text to recommend not to use implicit but code 1899 o added section on access token injection 1901 o reworked sections 3.1 through 3.3 to be more specific on implicit 1902 grant issues 1904 -08 1906 o added recommendations re implicit and token injection 1908 o uppercased key words in Section 2 according to RFC 2119 1909 -07 1911 o incorporated findings of Doug McDorman 1913 o added section on HTTP status codes for redirects 1915 o added new section on access token privilege restriction based on 1916 comments from Johan Peeters 1918 -06 1920 o reworked section 3.8.1 1922 o incorporated Phil Hunt's feedback 1924 o reworked section on mix-up 1926 o extended section on code leakage via referrer header to also cover 1927 state leakage 1929 o added Daniel Fett as author 1931 o replaced text intended to inform WG discussion by recommendations 1932 to implementors 1934 o modified example URLs to conform to RFC 2606 1936 -05 1938 o Completed sections on code leakage via referrer header, attacks in 1939 browser, mix-up, and CSRF 1941 o Reworked Code Injection Section 1943 o Added reference to OpenID Connect spec 1945 o removed refresh token leakage as respective considerations have 1946 been given in section 10.4 of RFC 6749 1948 o first version on open redirection 1950 o incorporated Christian Mainka's review feedback 1952 -04 1954 o Restructured document for better readability 1956 o Added best practices on Token Leakage prevention 1957 -03 1959 o Added section on Access Token Leakage at Resource Server 1961 o incorporated Brian Campbell's findings 1963 -02 1965 o Folded Mix up and Access Token leakage through a bad AS into new 1966 section for dynamic OAuth threats 1968 o reworked dynamic OAuth section 1970 -01 1972 o Added references to mitigation methods for token leakage 1974 o Added reference to Token Binding for Authorization Code 1976 o incorporated feedback of Phil Hunt 1978 o fixed numbering issue in attack descriptions in section 2 1980 -00 (WG document) 1982 o turned the ID into a WG document and a BCP 1984 o Added federated app login as topic in Other Topics 1986 Authors' Addresses 1988 Torsten Lodderstedt 1989 yes.com 1991 Email: torsten@lodderstedt.net 1993 John Bradley 1994 Yubico 1996 Email: ve7jtb@ve7jtb.com 1998 Andrey Labunets 1999 Facebook 2001 Email: isciurus@fb.com 2002 Daniel Fett 2003 yes.com 2005 Email: mail@danielfett.de