idnits 2.17.1 draft-ietf-oauth-security-topics-06.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 : ---------------------------------------------------------------------------- ** There are 3 instances of too long lines in the document, the longest one being 13 characters in excess of 72. ** The document seems to lack a both a reference to RFC 2119 and the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. RFC 2119 keyword, line 413: '...ization endpoint SHOULD not include th...' RFC 2119 keyword, line 419: '...horization codes SHOULD be invalidated...' RFC 2119 keyword, line 426: '...he "state" value SHOULD be invalidated...' RFC 2119 keyword, line 597: '...servers, clients MUST prevent mix-up a...' RFC 2119 keyword, line 1113: '... stating the AS MUST NOT automaticall...' (5 more instances...) Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'SHOULD not' in this paragraph: The page rendered as a result of the OAuth authorization response and the authorization endpoint SHOULD not include third-party resources or links to external sites. == Using lowercase 'not' together with uppercase 'MUST', 'SHALL', 'SHOULD', or 'RECOMMENDED' is not an accepted usage according to RFC 2119. Please use uppercase 'NOT' together with RFC 2119 keywords (if that is what you mean). Found 'MUST not' in this paragraph: Client MUST not expose URLs which could be utilized as open redirector. Attackers may use an open redirector to produce URLs which appear to point to the client, which might trick users to trust the URL and follow it in her browser. Another abuse case is to produce URLs pointing to the client and utilize them to impersonate a client with an authorization server. -- The document date (May 20, 2018) is 2162 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) ** Downref: Normative reference to an Informational RFC: RFC 6819 ** Obsolete normative reference: RFC 7231 (Obsoleted by RFC 9110) == Outdated reference: A later version (-09) exists of draft-bradley-oauth-jwt-encoded-state-08 == Outdated reference: A later version (-34) exists of draft-ietf-oauth-jwsreq-16 == Outdated reference: A later version (-17) exists of draft-ietf-oauth-mtls-08 == Outdated reference: A later version (-07) exists of draft-ietf-oauth-pop-key-distribution-03 == Outdated reference: A later version (-08) exists of draft-ietf-oauth-token-binding-06 == Outdated reference: A later version (-18) exists of draft-ietf-tokbind-https-14 == Outdated reference: A later version (-05) exists of draft-sakimura-oauth-jpop-04 Summary: 4 errors (**), 0 flaws (~~), 10 warnings (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Open Authentication Protocol T. Lodderstedt, Ed. 3 Internet-Draft YES.com AG 4 Intended status: Best Current Practice J. Bradley 5 Expires: November 21, 2018 Yubico 6 A. Labunets 7 Facebook 8 D. Fett 9 University of Stuttgart 10 May 20, 2018 12 OAuth 2.0 Security Best Current Practice 13 draft-ietf-oauth-security-topics-06 15 Abstract 17 This document describes best current security practices for OAuth 18 2.0. 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 November 21, 2018. 40 Copyright Notice 42 Copyright (c) 2018 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 2. Recommendations . . . . . . . . . . . . . . . . . . . . . . . 4 59 2.1. Protecting redirect-based flows . . . . . . . . . . . . . 4 60 2.2. Token Replay Prevention . . . . . . . . . . . . . . . . . 5 61 3. Attacks and Mitigations . . . . . . . . . . . . . . . . . . . 5 62 3.1. Insufficient redirect URI validation . . . . . . . . . . 5 63 3.1.1. Attacks on Authorization Code Grant . . . . . . . . . 6 64 3.1.2. Attacks on Implicit Grant . . . . . . . . . . . . . . 7 65 3.1.3. Proposed Countermeasures . . . . . . . . . . . . . . 8 66 3.2. Code or State Leakage from Client or AS via Referrer 67 Headers . . . . . . . . . . . . . . . . . . . . . . . . . 9 68 3.2.1. Proposed Countermeasures . . . . . . . . . . . . . . 9 69 3.3. Attacks through the Browser History . . . . . . . . . . . 10 70 3.3.1. Code in Browser History . . . . . . . . . . . . . . . 10 71 3.3.2. Access Token in Browser History . . . . . . . . . . . 10 72 3.4. Mix-Up . . . . . . . . . . . . . . . . . . . . . . . . . 11 73 3.4.1. Attack Description . . . . . . . . . . . . . . . . . 11 74 3.4.2. Countermeasures . . . . . . . . . . . . . . . . . . . 13 75 3.5. Code Injection . . . . . . . . . . . . . . . . . . . . . 14 76 3.5.1. Proposed Countermeasures . . . . . . . . . . . . . . 16 77 3.6. Cross Site Request Forgery . . . . . . . . . . . . . . . 17 78 3.6.1. Proposed Countermeasures . . . . . . . . . . . . . . 17 79 3.7. Access Token Leakage at the Resource Server . . . . . . . 18 80 3.7.1. Access Token Phishing by Counterfeit Resource Server 18 81 3.7.1.1. Metadata . . . . . . . . . . . . . . . . . . . . 18 82 3.7.1.2. Sender Constrained Access Tokens . . . . . . . . 19 83 3.7.1.3. Audience Restricted Access Tokens . . . . . . . . 22 84 3.7.2. Compromised Resource Server . . . . . . . . . . . . . 23 85 3.8. Open Redirection . . . . . . . . . . . . . . . . . . . . 24 86 3.8.1. Authorization Server as Open Redirector . . . . . . . 24 87 3.8.2. Clients as Open Redirector . . . . . . . . . . . . . 24 88 3.9. TLS Terminating Reverse Proxies . . . . . . . . . . . . . 25 89 4. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 25 90 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 26 91 6. Security Considerations . . . . . . . . . . . . . . . . . . . 26 92 7. References . . . . . . . . . . . . . . . . . . . . . . . . . 26 93 7.1. Normative References . . . . . . . . . . . . . . . . . . 26 94 7.2. Informative References . . . . . . . . . . . . . . . . . 26 95 Appendix A. Document History . . . . . . . . . . . . . . . . . . 29 96 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 31 98 1. Introduction 100 It's been a while since OAuth has been published in RFC 6749 101 [RFC6749] and RFC 6750 [RFC6750]. Since publication, OAuth 2.0 has 102 gotten massive traction in the market and became the standard for API 103 protection and, as foundation of OpenID Connect [OpenID], identity 104 providing. While OAuth was used in a variety of scenarios and 105 different kinds of deployments, the following challenges could be 106 observed: 108 o OAuth implementations are being attacked through known 109 implementation weaknesses and anti-patterns (XSRF, referrer 110 header). Although most of these threats are discussed in the 111 OAuth 2.0 Threat Model and Security Considerations [RFC6819], 112 continued exploitation demonstrates there may be a need for more 113 specific recommendations or that the existing mitigations are too 114 difficult to deploy. 116 o Technology has changed, e.g., the way browsers treat fragments in 117 some situations, which may change the implicit grant's underlying 118 security model. 120 o OAuth is used in much more dynamic setups than originally 121 anticipated, creating new challenges with respect to security. 122 Those challenges go beyond the original scope of RFC 6749 123 [RFC6749], RFC 6750 [RFC6749], and RFC 6819 [RFC6819]. 125 OAuth initially assumed a static relationship between client, 126 authorization server and resource servers. The URLs of AS and RS 127 were known to the client at deployment time and built an anchor for 128 the trust relationship among those parties. The validation whether 129 the client talks to a legitimate server was based on TLS server 130 authentication (see [RFC6819], Section 4.5.4). With the increasing 131 adoption of OAuth, this simple model dissolved and, in several 132 scenarios, was replaced by a dynamic establishment of the 133 relationship between clients on one side and the authorization and 134 resource servers of a particular deployment on the other side. This 135 way the same client could be used to access services of different 136 providers (in case of standard APIs, such as e-Mail or OpenID 137 Connect) or serves as a frontend to a particular tenant in a multi- 138 tenancy. Extensions of OAuth, such as [RFC7591] and 139 [I-D.ietf-oauth-discovery] were developed in order to support the 140 usage of OAuth in dynamic scenarios. As a challenge to the 141 community, such usage scenarios open up new attack angles, which are 142 discussed in this document. 144 The remainder of the document is organized as follows: The next 145 section summarizes the most important recommendations of the OAuth 146 working group for every OAuth implementor. Afterwards, a detailed 147 analysis of the threats and implementation issues which can be found 148 in the wild today is given along with a discussion of potential 149 countermeasures. 151 2. Recommendations 153 This section describes the set of security mechanisms the OAuth 154 working group recommendeds to OAuth implementers. 156 2.1. Protecting redirect-based flows 158 Authorization servers shall utilize exact matching of client redirect 159 URIs against pre-registered URIs. This measure contributes to the 160 prevention of leakage of authorization codes and access tokens 161 (depending on the grant type). It also helps to detect mix-up 162 attacks. 164 Clients shall avoid any redirects or forwards which can be 165 parameterized by URI query parameters, in order to provide a further 166 layer of defence against token leakage. If there is a need for this 167 kind of redirects, clients are advised to implement appropriate 168 countermeasures against open redirection, e.g., as described by the 169 OWASP [owasp]. 171 Clients shall ensure to only process redirect responses of the OAuth 172 authorization server they send the respective request to and in the 173 same user agent this request was initiated in. In particular, 174 clients shall implement appropriate XSRF prevention by utilizing one- 175 time use XSRF tokens carried in the "state" parameter, which are 176 securely bound to the user agent. Moreover, the client shall 177 memorize which authorization server it sent an authorization request 178 to and bind this information to the user agent and ensure any sub- 179 sequent messages are sent to the same authorization server. 180 Furthermore, clients should use AS-specific redirect URIs as a means 181 to identify the AS a particular response came from. Matching this 182 with the before mentioned information regarding the AS the client 183 sent the request to helps to detect mix-up attacks. 185 Note: [I-D.bradley-oauth-jwt-encoded-state] gives advice on how to 186 implement XSRF prevention and AS matching using signed JWTs in the 187 "state" parameter. 189 Clients shall use PKCE [RFC7636] in order to (with the help of the 190 authorization server) detect and prevent attempts to inject (replay) 191 authorization codes into the authorization response. The PKCE 192 challenges must be transaction-specific and securely bound to the 193 user agent, in which the transaction was started. OpenID Connect 194 clients may use the "nonce" parameter of the OpenID Connect 195 authentication request as specified in [OpenID] in conjunction with 196 the corresponding ID Token claim for the same purpose. 198 Note: although PKCE so far was recommended as mechanism to protect 199 native apps, this advice applies to all kinds of OAuth clients, 200 including web applications. 202 Authorization servers shall consider the recommendations given in 203 [RFC6819], Section 4.4.1.1, on authorization code replay prevention. 205 2.2. Token Replay Prevention 207 Authorization servers shall use TLS-based methods for sender 208 constrained access tokens as described in Section 3.7.1.2, such as 209 token binding [I-D.ietf-oauth-token-binding] or Mutual TLS for OAuth 210 2.0 [I-D.ietf-oauth-mtls] in order to prevent token replay. It is 211 also recommend to use end-to-end TLS whenever possible. 213 3. Attacks and Mitigations 215 This section gives a detailed description of attacks on OAuth 216 implementations, along with potential countermeasures. This section 217 complements and enhances the description given in [RFC6819]. 219 3.1. Insufficient redirect URI validation 221 Some authorization servers allow clients to register redirect URI 222 patterns instead of complete redirect URIs. In those cases, the 223 authorization server, at runtime, matches the actual redirect URI 224 parameter value at the authorization endpoint against this pattern. 225 This approach allows clients to encode transaction state into 226 additional redirect URI parameters or to register just a single 227 pattern for multiple redirect URIs. As a downside, it turned out to 228 be more complex to implement and error prone to manage than exact 229 redirect URI matching. Several successful attacks have been observed 230 in the wild, which utilized flaws in the pattern matching 231 implementation or concrete configurations. Such a flaw effectively 232 breaks client identification or authentication (depending on grant 233 and client type) and allows the attacker to obtain an authorization 234 code or access token, either: 236 o by directly sending the user agent to a URI under the attackers 237 control or 239 o by exposing the OAuth credentials to an attacker by utilizing an 240 open redirector at the client in conjunction with the way user 241 agents handle URL fragments. 243 3.1.1. Attacks on Authorization Code Grant 245 For a public client using the grant type code, an attack would look 246 as follows: 248 Let's assume the redirect URL pattern "https://*.somesite.example/*" 249 had been registered for the client "s6BhdRkqt3". This pattern allows 250 redirect URIs pointing to any host residing in the domain 251 somesite.example. So if an attacker manages to establish a host or 252 subdomain in somesite.example he can impersonate the legitimate 253 client. Assume the attacker sets up the host 254 "evil.somesite.example". 256 (1) The attacker needs to trick the user into opening a tampered URL 257 in his browser, which launches a page under the attacker's 258 control, say "https://www.evil.example". 260 (2) This URL initiates an authorization request with the client id 261 of a legitimate client to the authorization endpoint. This is 262 the example authorization request (line breaks are for display 263 purposes only): 265 GET /authorize?response_type=code&client_id=s6BhdRkqt3&state=xyz 266 &redirect_uri=https%3A%2F%2Fevil.somesite.example%2Fcb HTTP/1.1 267 Host: server.somesite.example 269 (3) The authorization server validates the redirect URI in order to 270 identify the client. Since the pattern allows arbitrary domains 271 host names in "somesite.example", the authorization request is 272 processed under the legitimate client's identity. This includes 273 the way the request for user consent is presented to the user. 274 If auto-approval is allowed (which is not recommended for public 275 clients according to [RFC6749]), the attack can be performed 276 even easier. 278 (4) If the user does not recognize the attack, the code is issued 279 and directly sent to the attacker's client. 281 (5) Since the attacker impersonated a public client, it can directly 282 exchange the code for tokens at the respective token endpoint. 284 Note: This attack will not directly work for confidential clients, 285 since the code exchange requires authentication with the legitimate 286 client's secret. The attacker will need to utilize the legitimate 287 client to redeem the code (e.g., by performing a code injection 288 attack). This kind of injections is covered in 289 Section Code Injection. 291 3.1.2. Attacks on Implicit Grant 293 The attack described above works for the implicit grant as well. If 294 the attacker is able to send the authorization response to a URI 295 under his control, he will directly get access to the fragment 296 carrying the access token. 298 Additionally, implicit clients can be subject to a further kind of 299 attacks. It utilizes the fact that user agents re-attach fragments 300 to the destination URL of a redirect if the location header does not 301 contain a fragment (see [RFC7231], Section 9.5). The attack 302 described here combines this behavior with the client as an open 303 redirector in order to get access to access tokens. This allows 304 circumvention even of strict redirect URI patterns (but not strict 305 URL matching!). 307 Assume the pattern for client "s6BhdRkqt3" is 308 "https://client.somesite.example/cb?*", i.e., any parameter is 309 allowed for redirects to "https://client.somesite.example/cb". 310 Unfortunately, the client exposes an open redirector. This endpoint 311 supports a parameter "redirect_to" which takes a target URL and will 312 send the browser to this URL using an HTTP Location header redirect 313 302. 315 (1) Same as above, the attacker needs to trick the user into opening 316 a tampered URL in his browser, which launches a page under the 317 attacker's control, say "https://www.evil.example". 319 (2) The URL initiates an authorization request, which is very 320 similar to the attack on the code flow. As differences, it 321 utilizes the open redirector by encoding 322 "redirect_to=https://client.evil.example" into the redirect URI 323 and it uses the response type "token" (line breaks are for 324 display purposes only): 326 GET /authorize?response_type=token&client_id=s6BhdRkqt3&state=xyz 327 &redirect_uri=https%3A%2F%2Fclient.somesite.example%2Fcb%26redirect_to 328 %253Dhttps%253A%252F%252Fclient.evil.example%252Fcb HTTP/1.1 329 Host: server.somesite.example 331 (3) Since the redirect URI matches the registered pattern, the 332 authorization server allows the request and sends the resulting 333 access token with a 302 redirect (some response parameters are 334 omitted for better readability) 336 HTTP/1.1 302 Found 337 Location: https://client.somesite.example/cb? 338 redirect_to%3Dhttps%3A%2F%2Fclient.evil.example%2Fcb 339 #access_token=2YotnFZFEjr1zCsicMWpAA&... 341 (4) At the example.com, the request arrives at the open redirector. 342 It will read the redirect parameter and will issue an HTTP 302 343 Location header redirect to the URL "https://evil.example.com/ 344 cb". 346 HTTP/1.1 302 Found 347 Location: https://client.evil.example/cb 349 (5) Since the redirector at client.somesite.example does not include 350 a fragment in the Location header, the user agent will re-attach 351 the original fragment 352 "#access_token=2YotnFZFEjr1zCsicMWpAA&..." to the URL and will 353 navigate to the following URL: 355 https://client.evil.example/cb#access_token=2YotnFZFEjr1zCsicMWpAA&... 357 (6) The attacker's page at client.evil.example can access the 358 fragment and obtain the access token. 360 3.1.3. Proposed Countermeasures 362 The complexity of implementing and managing pattern matching 363 correctly obviously causes security issues. This document therefore 364 proposes to simplify the required logic and configuration by using 365 exact redirect URI matching only. This means the authorization 366 server shall compare the two URIs using simple string comparison as 367 defined in [RFC3986], Section 6.2.1.. 369 Additional recommendations: 371 o Servers on which callbacks are hosted must not expose open 372 redirectors (see Section 3.8). 374 o Clients may drop fragments via intermediary URLs with "fix 375 fragments" (see [fb_fragments]) to prevent the user agent from 376 appending any unintended fragments. 378 As an alternative to exact redirect URI matching, the AS could also 379 authenticate clients, e.g., using [I-D.ietf-oauth-jwsreq]. 381 3.2. Code or State Leakage from Client or AS via Referrer Headers 383 Authorization codes or values of "state" can unintentionally be 384 disclosed to attackers through the referrer header, by leaking either 385 from a client's web site or from an AS's web site. 387 Leakage from OAuth client: This requires that the client, as a result 388 of a successful authorization request, renders a page that 390 o contains links to other pages under the attacker's control (ads, 391 faq, ...) and a user clicks on such a link, or 393 o includes third-party content (iframes, images, etc.) for example 394 if the page contains user-generated content (blog). 396 As soon as the browser navigates to the attacker's page or loads the 397 third-party content, the attacker receives the authorization response 398 URL and can extract "code" or "state". 400 Leakage from AS: In a similar way, an attacker can learn "state" if 401 the authorization endpoint at the authorization server contains links 402 or third-party content as above. 404 Consequences: An attacker that learns a valid code through a referrer 405 header can perform the same attacks as described in 406 Section Section 3.1.1. If the attacker learns "state", the CSRF 407 protection achieved by using "state" is lost, resulting in CSRF 408 attacks as described in [RFC6819], Section 4.4.1.8.. 410 3.2.1. Proposed Countermeasures 412 The page rendered as a result of the OAuth authorization response and 413 the authorization endpoint SHOULD not include third-party resources 414 or links to external sites. 416 The following measures further reduce the chances of a successful 417 attack: 419 o Authorization codes SHOULD be invalidated by the AS after their 420 first use at the token endpoint. For example, if an AS 421 invalidated the code after the legitimate client redeemed it, the 422 attacker would fail exchanging this code later. (This does not 423 mitigate the attack if the attacker manages to exchange the code 424 for a token before the legitimate client does so.) 426 o The "state" value SHOULD be invalidated by the client after its 427 first use at the redirection endpoint. If this is implemented, 428 and an attacker receives a token through the referrer header from 429 the client's web site, the "state" was already used, invalidated 430 by the client and cannot be used again by the attacker. (This 431 does not help if the "state" leaks from the AS's web site, since 432 then the "state" has not been used at the redirection endpoint at 433 the client yet.) 435 o Bind authorization code to a confidential client or PKCE 436 challenge. In this case, the attacker lacks the secret to request 437 the code exchange. 439 o Suppress the referrer header by adding the attribute 440 "rel="noreferrer"" to HTML links or by applying an appropriate 441 Referrer Policy [webappsec-referrer-policy] to the document 442 (either as part of the "referrer" meta attribute or by setting a 443 Referrer-Policy header). 445 o Use form post response mode instead of redirect for authorization 446 response (see [oauth-v2-form-post-response-mode]). 448 3.3. Attacks through the Browser History 450 Authorization codes and access tokens can end up in the browser's 451 history of visited URLs, enabling the attacks described in the 452 following. 454 3.3.1. Code in Browser History 456 When a browser navigates to "client.com/ 457 redirection_endpoint?code=abcd" as a result of a redirect from a 458 provider's authorization endpoint, the URL including the 459 authorization code may end up in the browser's history. An attacker 460 with access to the device could obtain the code and try to replay it. 462 Proposed countermeasures: 464 o Authorization code replay prevention as described in [RFC6819], 465 Section 4.4.1.1, and Section 3.5 467 o Use form post response mode instead of redirect for authorization 468 response (see [oauth-v2-form-post-response-mode]) 470 3.3.2. Access Token in Browser History 472 An access token may end up in the browser history if a a client or 473 just a web site, which already has a token, deliberately navigates to 474 a page like "provider.com/get_user_profile?access_token=abcdef.". 475 Actually [RFC6750]discourages this practice and asks to transfer 476 tokens via a header, but in practice web sites often just pass access 477 token in query parameters. 479 In case of implicit grant, a URL like "client.com/ 480 redirection_endpoint#access_token=abcdef" may also end up in the 481 browser history as a result of a redirect from a provider's 482 authorization endpoint. 484 Proposed countermeasures: 486 o Replace implicit flow with postmessage communication or the 487 authorization code grant 489 o Never pass access tokens in URL query parameters 491 3.4. Mix-Up 493 Mix-up is an attack on scenarios where an OAuth client interacts with 494 multiple authorization servers, as is usually the case when dynamic 495 registration is used. The goal of the attack is to obtain an 496 authorization code or an access token by tricking the client into 497 sending those credentials to the attacker instead of using them at 498 the respective endpoint at the authorization/resource server. 500 3.4.1. Attack Description 502 For a detailed attack description, refer to [arXiv.1601.01229] and 503 [I-D.ietf-oauth-mix-up-mitigation]. The description here closely 504 follows [arXiv.1601.01229], with variants of the attack outlined 505 below. 507 Preconditions: For the attack to work, we assume that 509 (1) the implicit or authorization code grant are used with multiple 510 AS of which one is considered "honest" (H-AS) and one is 511 operated by the attacker (A-AS), 513 (2) the client stores the AS chosen by the user in a session bound 514 to the user's browser and uses the same redirection endpoint URI 515 for each AS, and 517 (3) the attacker can manipulate the first request/response pair from 518 a user's browser to the client (in which the user selects a 519 certain AS and is then redirected by the client to that AS). 521 Some of the attack variants described below require different 522 preconditions. 524 In the following, we assume that the client is registered with H-AS 525 (URI: "https://honest.as.example", client id: 7ZGZldHQ) and with A-AS 526 (URI: "https://attacker.example", client id: 666RVZJTA). 528 Attack on the authorization code grant: 530 (1) The user selects to start the grant using H-AS (e.g., by 531 clicking on a button at the client's website). 533 (2) The attacker intercepts this request and changes the user's 534 selection to "A-AS". 536 (3) The client stores in the user's session that the user selected 537 "A-AS" and redirects the user to A-AS's authorization endpoint 538 by sending the following response: 540 HTTP/1.1 302 Found 541 Location: https://attacker.example/authorize?response_type=code&client_id=666RVZJTA 543 (4) Now the attacker intercepts this response and changes the 544 redirection such that the user is being redirected to H-AS. The 545 attacker also replaces the client id of the client at A-AS with 546 the client's id at H-AS, resulting in the following response 547 being sent to the browser: 549 HTTP/1.1 302 Found 550 Location: https://honest.as.example/authorize?response_type=code&client_id=7ZGZldHQ 552 (5) Now, the user authorizes the client to access her resources at 553 H-AS. H-AS issues a code and sends it (via the browser) back to 554 the client. 556 (6) Since the client still assumes that the code was issued by A-AS, 557 it will try to redeem the code at A-AS's token endpoint. 559 (7) The attacker therefore obtains code and can either exchange the 560 code for an access token (for public clients) or perform a code 561 injection attack as described in Section Section 3.5. 563 Variants: 565 Implicit Grant In the implicit grant, the attacker receives an 566 access token instead of the code; the rest of the attack 567 works as above. 569 Mix-Up Without Interception A variant of the above attack works even 570 if the first request/response pair cannot be intercepted (for 571 example, because TLS is used to protect these messages): 573 Here, we assume that the user wants to start the grant using 574 A-AS (and not H-AS). After the client redirected the user to 575 the authorization endpoint at A-AS, the attacker immediately 576 redirects the user to H-AS (changing the client id 577 "7ZGZldHQ"). (A vigilant user might at this point detect 578 that she intended to use A-AS instead of H-AS.) The attack 579 now proceeds exactly as in step 1 of the attack description 580 above. 582 Per-AS Redirect URIs If clients use different redirect URIs for 583 different ASs, do not store the selected AS in the user's 584 session, and ASs do not check the redirect URIs properly, 585 attackers can mount an attack called "Cross-Social Network 586 Request Forgery". We refer to [oauth_security_jcs_14] for 587 details. 589 OpenID Connect There are several variants that can be used to attack 590 OpenID Connect. They are described in detail in 591 [arXiv.1704.08539], Appendix A, and [arXiv.1508.04324v2], 592 Section 6 ("Malicious Endpoints Attacks"). 594 3.4.2. Countermeasures 596 In scenarios where an OAuth client interacts with multiple 597 authorization servers, clients MUST prevent mix-up attacks. 599 Potential countermeasures: 601 o Configure authorization servers to return an AS identitifier 602 ("iss") and the "client_id" for which a code or token was issued 603 in the authorization response. This enables clients to compare 604 this data to their own client id and the "iss" identifier of the 605 AS it believed it sent the user agent to. This mitigation is 606 discussed in detail in [I-D.ietf-oauth-mix-up-mitigation]. In 607 OpenID Connect, if an ID token is returned in the authorization 608 response, it carries client id and issuer. It can be used for 609 this mitigation. 611 o As it can be seen in the preconditions of the attacks above, 612 clients can prevent mix-up attack by (1) using AS-specific 613 redirect URIs with exact redirect URI matching, (2) storing, for 614 each authorization request, the intended AS, and (3) comparing the 615 intended AS with the actual redirect URI where the authorization 616 response was received. 618 3.5. Code Injection 620 In such an attack, the adversary attempts to inject a stolen 621 authorization code into a legitimate client on a device under his 622 control. In the simplest case, the attacker would want to use the 623 code in his own client. But there are situations where this might 624 not be possible or intended. Examples are: 626 o The attacker wants to access certain functions in this particular 627 client. As an example, the attacker wants to impersonate his 628 victim in a certain app or on a certain web site. 630 o The code is bound to a particular confidential client and the 631 attacker is unable to obtain the required client credentials to 632 redeem the code himself. 634 o The authorization or resource servers are limited to certain 635 networks, the attackers is unable to access directly. 637 How does an attack look like? 639 (1) The attacker obtains an authorization code by performing any of 640 the attacks described above. 642 (2) It performs a regular OAuth authorization process with the 643 legitimate client on his device. 645 (3) The attacker injects the stolen authorization code in the 646 response of the authorization server to the legitimate client. 648 (4) The client sends the code to the authorization server's token 649 endpoint, along with client id, client secret and actual 650 "redirect_uri". 652 (5) The authorization server checks the client secret, whether the 653 code was issued to the particular client and whether the actual 654 redirect URI matches the "redirect_uri" parameter (see 655 [RFC6749]). 657 (6) If all checks succeed, the authorization server issues access 658 and other tokens to the client, so now the attacker is able to 659 impersonate the legitimate user. 661 Obviously, the check in step (5) will fail, if the code was issued to 662 another client id, e.g., a client set up by the attacker. The check 663 will also fail if the authorization code was already redeemed by the 664 legitimate user and was one-time use only. 666 An attempt to inject a code obtained via a malware pretending to be 667 the legitimate client should also be detected, if the authorization 668 server stored the complete redirect URI used in the authorization 669 request and compares it with the redirect_uri parameter. 671 [RFC6749], Section 4.1.3, requires the AS to "... ensure that the 672 "redirect_uri" parameter is present if the "redirect_uri" parameter 673 was included in the initial authorization request as described in 674 Section 4.1.1, and if included ensure that their values are 675 identical.". In the attack scenario described above, the legitimate 676 client would use the correct redirect URI it always uses for 677 authorization requests. But this URI would not match the tampered 678 redirect URI used by the attacker (otherwise, the redirect would not 679 land at the attackers page). So the authorization server would 680 detect the attack and refuse to exchange the code. 682 Note: this check could also detect attempt to inject a code, which 683 had been obtained from another instance of the same client on another 684 device, if certain conditions are fulfilled: 686 o the redirect URI itself needs to contain a nonce or another kind 687 of one-time use, secret data and 689 o the client has bound this data to this particular instance. 691 But this approach conflicts with the idea to enforce exact redirect 692 URI matching at the authorization endpoint. Moreover, it has been 693 observed that providers very often ignore the redirect_uri check 694 requirement at this stage, maybe because it doesn't seem to be 695 security-critical from reading the spec. 697 Other providers just pattern match the redirect_uri parameter against 698 the registered redirect URI pattern. This saves the authorization 699 server from storing the link between the actual redirect URI and the 700 respective authorization code for every transaction. But this kind 701 of check obviously does not fulfill the intent of the spec, since the 702 tampered redirect URI is not considered. So any attempt to inject a 703 code obtained using the "client_id" of a legitimate client or by 704 utilizing the legitimate client on another device won't be detected 705 in the respective deployments. 707 It is also assumed that the requirements defined in [RFC6749], 708 Section 4.1.3, increase client implementation complexity as clients 709 need to memorize or re-construct the correct redirect URI for the 710 call to the tokens endpoint. 712 This document therefore recommends to instead bind every 713 authorization code to a certain client instance on a certain device 714 (or in a certain user agent) in the context of a certain transaction. 716 3.5.1. Proposed Countermeasures 718 There are multiple technical solutions to achieve this goal: 720 Nonce OpenID Connect's existing "nonce" parameter could be used for 721 this purpose. The nonce value is one-time use and created by 722 the client. The client is supposed to bind it to the user 723 agent session and sends it with the initial request to the 724 OpenId Provider (OP). The OP associates the nonce to the 725 authorization code and attests this binding in the ID token, 726 which is issued as part of the code exchange at the token 727 endpoint. If an attacker injected an authorization code in 728 the authorization response, the nonce value in the client 729 session and the nonce value in the ID token will not match 730 and the attack is detected. The assumption is that an 731 attacker cannot get hold of the user agent state on the 732 victims device, where he has stolen the respective 733 authorization code. The main advantage of this option is 734 that Nonce is an existing feature used in the wild. On the 735 other hand, leveraging Nonce by the broader OAuth community 736 would require AS and client to adopt ID Tokens. 738 Code-bound State The "state" parameter as specified in [RFC6749] 739 could be used similarly to what is described above. This 740 would require to add a further parameter "state" to the code 741 exchange token endpoint request. The authorization server 742 would then compare the "state" value it associated with the 743 code and the "state" value in the parameter. If those values 744 do not match, it is considered an attack and the request 745 fails. The advantage of this approach would be to utilize an 746 existing OAuth parameter. But it would also mean to re- 747 interpret the purpose of "state" and to extend the token 748 endpoint request. 750 PKCE The PKCE parameter "challenge" along with the corresponding 751 "verifier" as specified in [RFC7636] could be used in the 752 same way as "nonce" or "state". In contrast to its original 753 intention, the verifier check would fail although the client 754 uses its correct verifier but the code is associated with a 755 challenge, which does not match. PKCE is a deployed OAuth 756 feature, even though it is used today to secure native apps, 757 only. 759 Token Binding Token binding [I-D.ietf-oauth-token-binding] could 760 also be used. In this case, the code would need to be bound 761 to two legs, between user agent and AS and the user agent and 762 the client. This requires further data (extension to 763 response) to manifest binding id for particular code. Token 764 binding is promising as a secure and convenient mechanism 765 (due to its browser integration). As a challenge, it 766 requires broad browser support and use with native apps is 767 still under discussion. 769 per instance client id/secret One could use per instance "client_id" 770 and secrets and bind the code to the respective "client_id". 771 Unfortunately, this does not fit into the web application 772 programming model (would need to use per user client ids). 774 PKCE seems to be the most obvious solution for OAuth clients as it 775 available and effectively used today for similar purposes for OAuth 776 native apps whereas "nonce" is appropriate for OpenId Connect 777 clients. 779 Note on pre-warmed secrets: An attacker can circumvent the 780 countermeasures described above if he is able to create or capture 781 the respective secret or code_challenge on a device under his 782 control, which is then used in the victim's authorization request. 783 Exact redirect URI matching of authorization requests can prevent the 784 attacker from using the pre-warmed secret in the faked authorization 785 transaction on the victim's device. 786 Unfortunately, it does not work for all kinds of OAuth clients. It 787 is effective for web and JS apps and for native apps with claimed 788 URLs. Attacks on native apps using custom schemes or redirect URIs 789 on localhost cannot be prevented this way, except if the AS enforces 790 one-time use for PKCE verifier or "nonce" values. 792 3.6. Cross Site Request Forgery 794 An attacker might attempt to inject a request to the redirect URI of 795 the legitimate client on the victim's device, e.g., to cause the 796 client to access resources under the attacker's control. 798 3.6.1. Proposed Countermeasures 800 Standard CSRF defenses should be used to protect the redirection 801 endpoint, for example: 803 CSRF Tokens Use of CSRF tokens which are bound to the user agent 804 and passed in the "state" parameter to the 805 authorization server. 807 Origin Header The Origin header can be used to detect and prevent 808 CSRF attacks. Since this feature, at the time of 809 writing, is not consistently supported by all 810 browsers, CSRF tokens should be used in addition to 811 Origin header checking. 813 For more details see [owasp_csrf]. 815 3.7. Access Token Leakage at the Resource Server 817 Access tokens can leak from a resource server under certain 818 circumstances. 820 3.7.1. Access Token Phishing by Counterfeit Resource Server 822 An attacker may setup his own resource server and trick a client into 823 sending access tokens to it, which are valid for other resource 824 servers. If the client sends a valid access token to this 825 counterfeit resource server, the attacker in turn may use that token 826 to access other services on behalf of the resource owner. 828 This attack assumes the client is not bound to a certain resource 829 server (and the respective URL) at development time, but client 830 instances are configured with an resource server's URL at runtime. 831 This kind of late binding is typical in situations where the client 832 uses a standard API, e.g., for e-Mail, calendar, health, or banking 833 and is configured by an user or administrator for the standard-based 834 service, this particular user or company uses. 836 There are several potential mitigation strategies, which will be 837 discussed in the following sections. 839 3.7.1.1. Metadata 841 An authorization server could provide the client with additional 842 information about the location where it is safe to use its access 843 tokens. 845 In the simplest form, this would require the AS to publish a list of 846 its known resource servers, illustrated in the following example 847 using a metadata parameter "resource_servers": 849 HTTP/1.1 200 OK 850 Content-Type: application/json 852 { 853 "issuer":"https://server.somesite.example", 854 "authorization_endpoint":"https://server.somesite.example/authorize", 855 "resource_servers":[ 856 "email.somesite.example", 857 "storage.somesite.example", 858 "video.somesite.example"] 859 ... 860 } 862 The AS could also return the URL(s) an access token is good for in 863 the token response, illustrated by the example return parameter 864 "access_token_resource_server": 866 HTTP/1.1 200 OK 867 Content-Type: application/json;charset=UTF-8 868 Cache-Control: no-store 869 Pragma: no-cache 871 { 872 "access_token":"2YotnFZFEjr1zCsicMWpAA", 873 "access_token_resource_server":"https://hostedresource.somesite.example/path1", 874 ... 875 } 877 This mitigation strategy would rely on the client to enforce the 878 security policy and to only send access tokens to legitimate 879 destinations. Results of OAuth related security research (see for 880 example [oauth_security_ubc] and [oauth_security_cmu]) indicate a 881 large portion of client implementations do not or fail to properly 882 implement security controls, like "state" checks. So relying on 883 clients to prevent access token phishing is likely to fail as well. 884 Moreover given the ratio of clients to authorization and resource 885 servers, it is considered the more viable approach to move as much as 886 possible security-related logic to those entities. Clearly, the 887 client has to contribute to the overall security. But there are 888 alternative countermeasures, as described in the next sections, which 889 provide a better balance between the involved parties. 891 3.7.1.2. Sender Constrained Access Tokens 893 As the name suggests, sender constrained access token scope the 894 applicability of an access token to a certain sender. This sender is 895 obliged to demonstrate knowledge of a certain secret as prerequisite 896 for the acceptance of that token at a resource server. 898 A typical flow looks like this: 900 1. The authorization server associates data with the access token 901 which binds this particular token to a certain client. The 902 binding can utilize the client identity, but in most cases the AS 903 utilizes key material (or data derived from the key material) 904 known to the client. 906 2. This key material must be distributed somehow. Either the key 907 material already exists before the AS creates the binding or the 908 AS creates ephemeral keys. The way pre-existing key material is 909 distributed varies among the different approaches. For example, 910 X.509 Certificates can be used in which case the distribution 911 happens explicitly during the enrollment process. Or the key 912 material is created and distributed at the TLS layer, in which 913 case it might automatically happens during the setup of a TLS 914 connection. 916 3. The RS must implement the actual proof of possession check. This 917 is typically done on the application level, it may utilize 918 capabilities of the transport layer (e.g., TLS). Note: replay 919 prevention is required as well! 921 There exists several proposals to demonstrate the proof of possession 922 in the scope of the OAuth working group: 924 o [I-D.ietf-oauth-token-binding]: In this approach, an access tokens 925 is, via the so-called token binding id, bound to key material 926 representing a long term association between a client and a 927 certain TLS host. Negotiation of the key material and proof of 928 possession in the context of a TLS handshake is taken care of by 929 the TLS stack. The client needs to determine the token binding id 930 of the target resource server and pass this data to the access 931 token request. The authorization server than associates the 932 access token with this id. The resource server checks on every 933 invocation that the token binding id of the active TLS connection 934 and the token binding id of associated with the access token 935 match. Since all crypto-related functions are covered by the TLS 936 stack, this approach is very client developer friendly. As a 937 prerequisite, token binding as described in 938 [I-D.ietf-tokbind-https] (including federated token bindings) must 939 be supported on all ends (client, authorization server, resource 940 server). 942 o [I-D.ietf-oauth-mtls]: The approach as specified in this document 943 allow use of mutual TLS for both client authentication and sender 944 constraint access tokens. For the purpose of sender constraint 945 access tokens, the client is identified towards the resource 946 server by the fingerprint of its public key. During processing of 947 an access token request, the authorization server obtains the 948 client's public key from the TLS stack and associates its 949 fingerprint with the respective access tokens. The resource 950 server in the same way obtains the public key from the TLS stack 951 and compares its fingerprint with the fingerprint associated with 952 the access token. 954 o [I-D.ietf-oauth-signed-http-request] specifies an approach to sign 955 HTTP requests. It utilizes [I-D.ietf-oauth-pop-key-distribution] 956 and represents the elements of the signature in a JSON object. 957 The signature is built using JWS. The mechanism has built-in 958 support for signing of HTTP method, query parameters and headers. 959 It also incorporates a timestamp as basis for replay prevention. 961 o [I-D.sakimura-oauth-jpop]: this draft describes different ways to 962 constrain access token usage, namely TLS or request signing. 963 Note: Since the authors of this draft contributed the TLS-related 964 proposal to [I-D.ietf-oauth-mtls], this document only considers 965 the request signing part. For request signing, the draft utilizes 966 [I-D.ietf-oauth-pop-key-distribution] and RFC 7800 [RFC7800]. The 967 signature data is represented in a JWT and JWS is used for 968 signing. Replay prevention is provided by building the signature 969 over a server-provided nonce, client-provided nonce and a nonce 970 counter. 972 [I-D.ietf-oauth-mtls] and [I-D.ietf-oauth-token-binding] are built on 973 top of TLS and this way continue the successful OAuth 2.0 philosophy 974 to leverage TLS to secure OAuth wherever possible. Both mechanisms 975 allow prevention of access token leakage in a fairly client developer 976 friendly way. 978 There are some differences between both approaches: To start with, in 979 [I-D.ietf-oauth-token-binding] all key material is automatically 980 managed by the TLS stack whereas [I-D.ietf-oauth-mtls] requires the 981 developer to create and maintain the key pairs and respective 982 certificates. Use of self-signed certificates, which is supported by 983 the draft, significantly reduce the complexity of this task. 984 Furthermore, [I-D.ietf-oauth-token-binding] allows to use different 985 key pairs for different resource servers, which is a privacy benefit. 986 On the other hand, [I-D.ietf-oauth-mtls] only requires widely 987 deployed TLS features, which means it might be easier to adopt in the 988 short term. 990 Application level signing approaches, like 991 [I-D.ietf-oauth-signed-http-request] and [I-D.sakimura-oauth-jpop] 992 have been debated for a long time in the OAuth working group without 993 a clear outcome. 995 As one advantage, application-level signing allows for end-to-end 996 protection including non-repudiation even if the TLS connection is 997 terminated between client and resource server. But deployment 998 experiences have revealed challenges regarding robustness (e.g., 999 reproduction of the signature base string including correct URL) as 1000 well as state management (e.g., replay prevention). 1002 This document therefore recommends implementors to consider one of 1003 TLS-based approaches wherever possible. 1005 3.7.1.3. Audience Restricted Access Tokens 1007 An audience restriction essentially restricts the resource server a 1008 particular access token can be used at. The authorization server 1009 associates the access token with a certain resource server and every 1010 resource server is obliged to verify for every request, whether the 1011 access token send with that request was meant to be used at the 1012 particular resource server. If not, the resource server must refuse 1013 to serve the respective request. In the general case, audience 1014 restrictions limit the impact of a token leakage. In the case of a 1015 counterfeit resource server, it may (as described see below) also 1016 prevent abuse of the phished access token at the legitimate resource 1017 server. 1019 The audience can basically be expressed using logical names or 1020 physical addresses (like URLs). In order to prevent phishing, it is 1021 necessary to use the actual URL the client will send requests to. In 1022 the phishing case, this URL will point to the counterfeit resource 1023 server. If the attacker tries to use the access token at the 1024 legitimate resource server (which has a different URL), the resource 1025 server will detect the mismatch (wrong audience) and refuse to serve 1026 the request. 1028 In deployments where the authorization server knows the URLs of all 1029 resource servers, the authorization server may just refuse to issue 1030 access tokens for unknown resource server URLs. 1032 The client needs to tell the authorization server, at which URL it 1033 will use the access token it is requesting. It could use the 1034 mechanism proposed [I-D.campbell-oauth-resource-indicators] or encode 1035 the information in the scope value. 1037 Instead of the URL, it is also possible to utilize the fingerprint of 1038 the resource server's X.509 certificate as audience value. This 1039 variant would also allow to detect an attempt to spoof the legit 1040 resource server's URL by using a valid TLS certificate obtained from 1041 a different CA. It might also be considered a privacy benefit to 1042 hide the resource server URL from the authorization server. 1044 Audience restriction seems easy to use since it does not require any 1045 crypto on the client side. But since every access token is bound to 1046 a certain resource server, the client also needs to obtain different 1047 RS-specific access tokens, if it wants to access several resource 1048 services. [I-D.ietf-oauth-token-binding] has the same property, 1049 since different token binding ids must be associated with the access 1050 token. [I-D.ietf-oauth-mtls] on the other hand allows a client to 1051 use the access token at multiple resource servers. 1053 It shall be noted that audience restrictions, or generally speaking 1054 an indication by the client to the authorization server where it 1055 wants to use the access token, has additional benefits beyond the 1056 scope of token leakage prevention. It allows the authorization 1057 server to create different access token whose format and content is 1058 specifically minted for the respective server. This has huge 1059 functional and privacy advantages in deployments using structured 1060 access tokens. 1062 3.7.2. Compromised Resource Server 1064 An attacker may compromise a resource server in order to get access 1065 to its resources and other resources of the respective deployment. 1066 Such a compromise may range from partial access to the system, e.g., 1067 its logfiles, to full control of the respective server. 1069 If the attacker was able to take over full control including shell 1070 access it will be able to circumvent all controls in place and access 1071 resources without access control. It will also get access to access 1072 tokens, which are sent to the compromised system and which 1073 potentially are valid for access to other resource servers as well. 1074 Even if the attacker "only" is able to access logfiles or databases 1075 of the server system, it may get access to valid access tokens. 1077 Preventing server breaches by way of hardening and monitoring server 1078 systems is considered a standard operational procedure and therefore 1079 out of scope of this document. This section will focus on the impact 1080 of such breaches on OAuth-related parts of the ecosystem, which is 1081 the replay of captured access tokens on the compromised resource 1082 server and other resource servers of the respective deployment. 1084 The following measures shall be taken into account by implementors in 1085 order to cope with access token replay: 1087 o The resource server must treat access tokens like any other 1088 credentials. It is considered good practice to not log them and 1089 not to store them in plain text. 1091 o Sender constraint access tokens as described in Section 3.7.1.2 1092 will prevent the attacker from replaying the access tokens on 1093 other resource servers. Depending on the severity of the 1094 penetration, it will also prevent replay on the compromised 1095 system. 1097 o Audience restriction as described in Section 3.7.1.3 may be used 1098 to prevent replay of captured access tokens on other resource 1099 servers. 1101 3.8. Open Redirection 1103 The following attacks can occur when an AS or client has an open 1104 redirector, i.e., a URL which causes an HTTP redirect to an attacker- 1105 controlled web site. 1107 3.8.1. Authorization Server as Open Redirector 1109 Attackers could try to utilize a user's trust in the authorization 1110 server (and its URL in particular) for performing phishing attacks. 1112 [RFC6749], Section 4.1.2.1, already prevents open redirects by 1113 stating the AS MUST NOT automatically redirect the user agent in case 1114 of an invalid combination of client_id and redirect_uri. 1116 However, as described in [I-D.ietf-oauth-closing-redirectors], an 1117 attacker could also utilize a correctly registered redirect URI to 1118 perform phishing attacks. It could for example register a client via 1119 dynamic client [RFC7591] registration and intentionally send an 1120 erroneous authorization request, e.g., by using an invalid scope 1121 value, to cause the AS to automatically redirect the user agent to 1122 its phishing site. 1124 The AS MUST take precautions to prevent this threat. Based on its 1125 risk assessment the AS needs to decide whether it can trust the 1126 redirect URI or not and SHOULD only automatically redirect the user 1127 agent, if it trusts the redirect URI. If not, it MAY inform the user 1128 that it is about to redirect her to the another site and rely on the 1129 user to decide or MAY just inform the user about the error. 1131 3.8.2. Clients as Open Redirector 1133 Client MUST not expose URLs which could be utilized as open 1134 redirector. Attackers may use an open redirector to produce URLs 1135 which appear to point to the client, which might trick users to trust 1136 the URL and follow it in her browser. Another abuse case is to 1137 produce URLs pointing to the client and utilize them to impersonate a 1138 client with an authorization server. 1140 In order to prevent open redirection, clients should only expose such 1141 a function, if the target URLs are whitelisted or if the origin of a 1142 request can be authenticated. 1144 3.9. TLS Terminating Reverse Proxies 1146 A common deployment architecture for HTTP applications is to have the 1147 application server sitting behind a reverse proxy, which terminates 1148 the TLS connection and dispatches the incoming requests to the 1149 respective application server nodes. 1151 This section highlights some attack angles of this deployment 1152 architecture, which are relevant to OAuth, and give recommendations 1153 for security controls. 1155 In some situations, the reverse proxy needs to pass security-related 1156 data to the upstream application servers for further processing. 1157 Examples include the IP address of the request originator, token 1158 binding ids and authenticated TLS client certificates. 1160 If the reverse proxy would pass through any header sent from the 1161 outside, an attacker could try to directly send the faked header 1162 values through the proxy to the application server in order to 1163 circumvent security controls that way. For example, it is standard 1164 practice of reverse proxies to accept "forwarded_for" headers and 1165 just add the origin of the inbound request (making it a list). 1166 Depending on the logic performed in the application server, the 1167 attacker could simply add a whitelisted IP address to the header and 1168 render a IP whitelist useless. A reverse proxy must therefore 1169 sanitize any inbound requests to ensure the authenticity and 1170 integrity of all header values relevant for the security of the 1171 application servers. 1173 If an attacker would be able to get access to the internal network 1174 between proxy and application server, it could also try to circumvent 1175 security controls in place. It is therefore important to ensure the 1176 authenticity of the communicating entities. Furthermore, the 1177 communication link between reverse proxy and application server must 1178 therefore be protected against tapping and injection (including 1179 replay prevention). 1181 4. Acknowledgements 1183 We would like to thank Jim Manico, Phil Hunt, Nat Sakimura, Christian 1184 Mainka, Doug McDorman, and Brian Campbell for their valuable 1185 feedback. 1187 5. IANA Considerations 1189 This draft includes no request to IANA. 1191 6. Security Considerations 1193 All relevant security considerations have been given in the 1194 functional specification. 1196 7. References 1198 7.1. Normative References 1200 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 1201 Resource Identifier (URI): Generic Syntax", STD 66, 1202 RFC 3986, DOI 10.17487/RFC3986, January 2005, 1203 . 1205 [RFC6749] Hardt, D., Ed., "The OAuth 2.0 Authorization Framework", 1206 RFC 6749, DOI 10.17487/RFC6749, October 2012, 1207 . 1209 [RFC6750] Jones, M. and D. Hardt, "The OAuth 2.0 Authorization 1210 Framework: Bearer Token Usage", RFC 6750, 1211 DOI 10.17487/RFC6750, October 2012, 1212 . 1214 [RFC6819] Lodderstedt, T., Ed., McGloin, M., and P. Hunt, "OAuth 2.0 1215 Threat Model and Security Considerations", RFC 6819, 1216 DOI 10.17487/RFC6819, January 2013, 1217 . 1219 [RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer 1220 Protocol (HTTP/1.1): Semantics and Content", RFC 7231, 1221 DOI 10.17487/RFC7231, June 2014, 1222 . 1224 [RFC7591] Richer, J., Ed., Jones, M., Bradley, J., Machulak, M., and 1225 P. Hunt, "OAuth 2.0 Dynamic Client Registration Protocol", 1226 RFC 7591, DOI 10.17487/RFC7591, July 2015, 1227 . 1229 7.2. Informative References 1231 [arXiv.1508.04324v2] 1232 Mladenov, V., Mainka, C., and J. Schwenk, "On the security 1233 of modern Single Sign-On Protocols: Second-Order 1234 Vulnerabilities in OpenID Connect", arXiv 1508.04324v2, 1235 January 2016, . 1237 [arXiv.1601.01229] 1238 Fett, D., Kuesters, R., and G. Schmitz, "A Comprehensive 1239 Formal Security Analysis of OAuth 2.0", arXiv 1601.01229, 1240 January 2016, . 1242 [arXiv.1704.08539] 1243 Fett, D., Kuesters, R., and G. Schmitz, "The Web SSO 1244 Standard OpenID Connect: In-Depth Formal Security Analysis 1245 and Security Guidelines", arXiv 1704.08539, April 2017, 1246 . 1248 [fb_fragments] 1249 "Facebook Developer Blog", 1250 . 1252 [I-D.bradley-oauth-jwt-encoded-state] 1253 Bradley, J., Lodderstedt, T., and H. Zandbelt, "Encoding 1254 claims in the OAuth 2 state parameter using a JWT", draft- 1255 bradley-oauth-jwt-encoded-state-08 (work in progress), 1256 January 2018. 1258 [I-D.campbell-oauth-resource-indicators] 1259 Campbell, B., Bradley, J., and H. Tschofenig, "Resource 1260 Indicators for OAuth 2.0", draft-campbell-oauth-resource- 1261 indicators-02 (work in progress), November 2016. 1263 [I-D.ietf-oauth-closing-redirectors] 1264 Bradley, J., Sanso, A., and H. Tschofenig, "OAuth 2.0 1265 Security: Closing Open Redirectors in OAuth", draft-ietf- 1266 oauth-closing-redirectors-00 (work in progress), February 1267 2016. 1269 [I-D.ietf-oauth-discovery] 1270 Jones, M., Sakimura, N., and J. Bradley, "OAuth 2.0 1271 Authorization Server Metadata", draft-ietf-oauth- 1272 discovery-10 (work in progress), March 2018. 1274 [I-D.ietf-oauth-jwsreq] 1275 Sakimura, N. and J. Bradley, "The OAuth 2.0 Authorization 1276 Framework: JWT Secured Authorization Request (JAR)", 1277 draft-ietf-oauth-jwsreq-16 (work in progress), April 2018. 1279 [I-D.ietf-oauth-mix-up-mitigation] 1280 Jones, M., Bradley, J., and N. Sakimura, "OAuth 2.0 Mix-Up 1281 Mitigation", draft-ietf-oauth-mix-up-mitigation-01 (work 1282 in progress), July 2016. 1284 [I-D.ietf-oauth-mtls] 1285 Campbell, B., Bradley, J., Sakimura, N., and T. 1286 Lodderstedt, "OAuth 2.0 Mutual TLS Client Authentication 1287 and Certificate Bound Access Tokens", draft-ietf-oauth- 1288 mtls-08 (work in progress), May 2018. 1290 [I-D.ietf-oauth-pop-key-distribution] 1291 Bradley, J., Hunt, P., Jones, M., and H. Tschofenig, 1292 "OAuth 2.0 Proof-of-Possession: Authorization Server to 1293 Client Key Distribution", draft-ietf-oauth-pop-key- 1294 distribution-03 (work in progress), February 2017. 1296 [I-D.ietf-oauth-signed-http-request] 1297 Richer, J., Bradley, J., and H. Tschofenig, "A Method for 1298 Signing HTTP Requests for OAuth", draft-ietf-oauth-signed- 1299 http-request-03 (work in progress), August 2016. 1301 [I-D.ietf-oauth-token-binding] 1302 Jones, M., Campbell, B., Bradley, J., and W. Denniss, 1303 "OAuth 2.0 Token Binding", draft-ietf-oauth-token- 1304 binding-06 (work in progress), March 2018. 1306 [I-D.ietf-tokbind-https] 1307 Popov, A., Nystrom, M., Balfanz, D., Langley, A., Harper, 1308 N., and J. Hodges, "Token Binding over HTTP", draft-ietf- 1309 tokbind-https-14 (work in progress), May 2018. 1311 [I-D.sakimura-oauth-jpop] 1312 Sakimura, N., Li, K., and J. Bradley, "The OAuth 2.0 1313 Authorization Framework: JWT Pop Token Usage", draft- 1314 sakimura-oauth-jpop-04 (work in progress), March 2017. 1316 [oauth-v2-form-post-response-mode] 1317 Microsoft and Ping Identity, "OAuth 2.0 Form Post Response 1318 Mode", April 2015, . 1321 [oauth_security_cmu] 1322 Carnegie Mellon University, Carnegie Mellon University, 1323 Microsoft Research, Carnegie Mellon University, Carnegie 1324 Mellon University, and Carnegie Mellon University, "OAuth 1325 Demystified for Mobile Application Developers", November 1326 2014. 1328 [oauth_security_jcs_14] 1329 Bansal, C., Bhargavan, K., Delignat-Lavaud, A., and S. 1330 Maffeis, "Discovering concrete attacks on website 1331 authorization by formal analysis", April 2014. 1333 [oauth_security_ubc] 1334 University of British Columbia and University of British 1335 Columbia, "The Devil is in the (Implementation) Details: 1336 An Empirical Analysis of OAuth SSO Systems", October 2012, 1337 . 1339 [OpenID] NRI, Ping Identity, Microsoft, Google, and Salesforce, 1340 "OpenID Connect Core 1.0 incorporating errata set 1", Nov 1341 2014, 1342 . 1344 [owasp] "Open Web Application Security Project Home Page", 1345 . 1347 [owasp_csrf] 1348 "Cross-Site Request Forgery (CSRF) Prevention Cheat 1349 Sheet", . 1352 [RFC7636] Sakimura, N., Ed., Bradley, J., and N. Agarwal, "Proof Key 1353 for Code Exchange by OAuth Public Clients", RFC 7636, 1354 DOI 10.17487/RFC7636, September 2015, 1355 . 1357 [RFC7800] Jones, M., Bradley, J., and H. Tschofenig, "Proof-of- 1358 Possession Key Semantics for JSON Web Tokens (JWTs)", 1359 RFC 7800, DOI 10.17487/RFC7800, April 2016, 1360 . 1362 [webappsec-referrer-policy] 1363 Google Inc. and Google Inc., "Referrer Policy", April 1364 2017, . 1366 Appendix A. Document History 1368 [[ To be removed from the final specification ]] 1370 -06 1372 o reworked section 3.8.1 1374 o incorporated Phil Hunt's feedback 1375 o reworked section on mix-up 1377 o extended section on code leakage via referrer header to also cover 1378 state leakage 1380 o added Daniel Fett as author 1382 o replaced text intended to inform WG discussion by recommendations 1383 to implementors 1385 o modified example URLs to conform to RFC 2606 1387 -05 1389 o Completed sections on code leakage via referrer header, attacks in 1390 browser, mix-up, and CSRF 1392 o Reworked Code Injection Section 1394 o Added reference to OpenID Connect spec 1396 o removed refresh token leakage as respective considerations have 1397 been given in section 10.4 of RFC 6749 1399 o first version on open redirection 1401 o incorporated Christian Mainka's review feedback 1403 -04 1405 o Restructured document for better readability 1407 o Added best practices on Token Leakage prevention 1409 -03 1411 o Added section on Access Token Leakage at Resource Server 1413 o incorporated Brian Campbell's findings 1415 -02 1417 o Folded Mix up and Access Token leakage through a bad AS into new 1418 section for dynamic OAuth threats 1420 o reworked dynamic OAuth section 1422 -01 1423 o Added references to mitigation methods for token leakage 1425 o Added reference to Token Binding for Authorization Code 1427 o incorporated feedback of Phil Hunt 1429 o fixed numbering issue in attack descriptions in section 2 1431 -00 (WG document) 1433 o turned the ID into a WG document and a BCP 1435 o Added federated app login as topic in Other Topics 1437 Authors' Addresses 1439 Torsten Lodderstedt (editor) 1440 YES.com AG 1442 Email: torsten@lodderstedt.net 1444 John Bradley 1445 Yubico 1447 Email: ve7jtb@ve7jtb.com 1449 Andrey Labunets 1450 Facebook 1452 Email: isciurus@fb.com 1454 Daniel Fett 1455 University of Stuttgart 1457 Email: daniel.fett@sec.uni-stuttgart.de