idnits 2.17.1 draft-ietf-oauth-v2-bearer-21.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 seems to use 'NOT RECOMMENDED' as an RFC 2119 keyword, but does not include the phrase in its RFC 2119 key words list. -- The document date (June 19, 2012) is 4319 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Outdated reference: A later version (-26) exists of draft-ietf-httpbis-p1-messaging-19 == Outdated reference: A later version (-26) exists of draft-ietf-httpbis-p7-auth-19 == Outdated reference: A later version (-31) exists of draft-ietf-oauth-v2-28 ** Obsolete normative reference: RFC 2246 (Obsoleted by RFC 4346) ** Obsolete normative reference: RFC 2818 (Obsoleted by RFC 9110) ** Obsolete normative reference: RFC 5246 (Obsoleted by RFC 8446) -- Possible downref: Non-RFC (?) normative reference: ref. 'USASCII' -- Obsolete informational reference (is this intentional?): RFC 2616 (Obsoleted by RFC 7230, RFC 7231, RFC 7232, RFC 7233, RFC 7234, RFC 7235) -- Obsolete informational reference (is this intentional?): RFC 2617 (Obsoleted by RFC 7235, RFC 7615, RFC 7616, RFC 7617) Summary: 3 errors (**), 0 flaws (~~), 5 warnings (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 OAuth Working Group M. Jones 3 Internet-Draft Microsoft 4 Intended status: Standards Track D. Hardt 5 Expires: December 21, 2012 independent 6 D. Recordon 7 Facebook 8 June 19, 2012 10 The OAuth 2.0 Authorization Framework: Bearer Token Usage 11 draft-ietf-oauth-v2-bearer-21 13 Abstract 15 This specification describes how to use bearer tokens in HTTP 16 requests to access OAuth 2.0 protected resources. Any party in 17 possession of a bearer token (a "bearer") can use it to get access to 18 the associated resources (without demonstrating possession of a 19 cryptographic key). To prevent misuse, bearer tokens need to be 20 protected from disclosure in storage and in transport. 22 Status of this Memo 24 This Internet-Draft is submitted in full conformance with the 25 provisions of BCP 78 and BCP 79. 27 Internet-Drafts are working documents of the Internet Engineering 28 Task Force (IETF). Note that other groups may also distribute 29 working documents as Internet-Drafts. The list of current Internet- 30 Drafts is at http://datatracker.ietf.org/drafts/current/. 32 Internet-Drafts are draft documents valid for a maximum of six months 33 and may be updated, replaced, or obsoleted by other documents at any 34 time. It is inappropriate to use Internet-Drafts as reference 35 material or to cite them other than as "work in progress." 37 This Internet-Draft will expire on December 21, 2012. 39 Copyright Notice 41 Copyright (c) 2012 IETF Trust and the persons identified as the 42 document authors. All rights reserved. 44 This document is subject to BCP 78 and the IETF Trust's Legal 45 Provisions Relating to IETF Documents 46 (http://trustee.ietf.org/license-info) in effect on the date of 47 publication of this document. Please review these documents 48 carefully, as they describe your rights and restrictions with respect 49 to this document. Code Components extracted from this document must 50 include Simplified BSD License text as described in Section 4.e of 51 the Trust Legal Provisions and are provided without warranty as 52 described in the Simplified BSD License. 54 Table of Contents 56 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 57 1.1. Notational Conventions . . . . . . . . . . . . . . . . . . 3 58 1.2. Terminology . . . . . . . . . . . . . . . . . . . . . . . 3 59 1.3. Overview . . . . . . . . . . . . . . . . . . . . . . . . . 4 60 2. Authenticated Requests . . . . . . . . . . . . . . . . . . . . 5 61 2.1. Authorization Request Header Field . . . . . . . . . . . . 5 62 2.2. Form-Encoded Body Parameter . . . . . . . . . . . . . . . 6 63 2.3. URI Query Parameter . . . . . . . . . . . . . . . . . . . 7 64 3. The WWW-Authenticate Response Header Field . . . . . . . . . . 8 65 3.1. Error Codes . . . . . . . . . . . . . . . . . . . . . . . 9 66 4. Example Access Token Response . . . . . . . . . . . . . . . . 10 67 5. Security Considerations . . . . . . . . . . . . . . . . . . . 10 68 5.1. Security Threats . . . . . . . . . . . . . . . . . . . . . 11 69 5.2. Threat Mitigation . . . . . . . . . . . . . . . . . . . . 11 70 5.3. Summary of Recommendations . . . . . . . . . . . . . . . . 13 71 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 14 72 6.1. OAuth Access Token Type Registration . . . . . . . . . . . 14 73 6.1.1. The "Bearer" OAuth Access Token Type . . . . . . . . . 14 74 6.2. OAuth Extensions Error Registration . . . . . . . . . . . 14 75 6.2.1. The "invalid_request" Error Value . . . . . . . . . . 14 76 6.2.2. The "invalid_token" Error Value . . . . . . . . . . . 15 77 6.2.3. The "insufficient_scope" Error Value . . . . . . . . . 15 78 6.3. Authentication Scheme Registration . . . . . . . . . . . . 16 79 6.3.1. The "Bearer" Authentication Scheme . . . . . . . . . . 16 80 7. References . . . . . . . . . . . . . . . . . . . . . . . . . . 16 81 7.1. Normative References . . . . . . . . . . . . . . . . . . . 16 82 7.2. Informative References . . . . . . . . . . . . . . . . . . 17 83 Appendix A. Acknowledgements . . . . . . . . . . . . . . . . . . 18 84 Appendix B. Document History . . . . . . . . . . . . . . . . . . 18 85 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 26 87 1. Introduction 89 OAuth enables clients to access protected resources by obtaining an 90 access token, which is defined in OAuth 2.0 Authorization 91 [I-D.ietf-oauth-v2] as "a string representing an access authorization 92 issued to the client", rather than using the resource owner's 93 credentials directly. 95 Tokens are issued to clients by an authorization server with the 96 approval of the resource owner. The client uses the access token to 97 access the protected resources hosted by the resource server. This 98 specification describes how to make protected resource requests when 99 the OAuth access token is a bearer token. 101 This specification defines the use of bearer tokens over HTTP/1.1 102 [I-D.ietf-httpbis-p1-messaging] using TLS [RFC5246] to access 103 protected resources. TLS is mandatory to implement and use with this 104 specification; other specifications may extend this specification for 105 use with other protocols. While designed for use with access tokens 106 resulting from OAuth 2.0 Authorization [I-D.ietf-oauth-v2] flows to 107 access OAuth protected resources, this specification actually defines 108 a general HTTP authorization method that can be used with bearer 109 tokens from any source to access any resources protected by those 110 bearer tokens. The Bearer authentication scheme is intended 111 primarily for server authentication using the WWW-Authenticate and 112 Authorization HTTP headers, but does not preclude its use for proxy 113 authentication. 115 1.1. Notational Conventions 117 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 118 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 119 document are to be interpreted as described in Key words for use in 120 RFCs to Indicate Requirement Levels [RFC2119]. 122 This document uses the Augmented Backus-Naur Form (ABNF) notation of 123 [RFC5234]. Additionally, the following rules are included from 124 HTTP/1.1, Part 7 [I-D.ietf-httpbis-p7-auth]: auth-param, auth-scheme, 125 and b64token; and from Uniform Resource Identifier (URI) [RFC3986]: 126 URI-Reference. 128 Unless otherwise noted, all the protocol parameter names and values 129 are case sensitive. 131 1.2. Terminology 132 Bearer Token 133 A security token with the property that any party in possession of 134 the token (a "bearer") can use the token in any way that any other 135 party in possession of it can. Using a bearer token does not 136 require a bearer to prove possession of cryptographic key material 137 (proof-of-possession). 139 All other terms are as defined in OAuth 2.0 Authorization 140 [I-D.ietf-oauth-v2]. 142 1.3. Overview 144 OAuth provides a method for clients to access a protected resource on 145 behalf of a resource owner. In the general case, before a client can 146 access a protected resource, it must first obtain an authorization 147 grant from the resource owner and then exchange the authorization 148 grant for an access token. The access token represents the grant's 149 scope, duration, and other attributes granted by the authorization 150 grant. The client accesses the protected resource by presenting the 151 access token to the resource server. In some cases, a client can 152 directly present its own credentials to an authorization server to 153 obtain an access token without having to first obtain an 154 authorization grant from a resource owner. 156 The access token provides an abstraction, replacing different 157 authorization constructs (e.g., username and password, assertion) for 158 a single token understood by the resource server. This abstraction 159 enables issuing access tokens valid for a short time period, as well 160 as removing the resource server's need to understand a wide range of 161 authentication schemes. 163 +--------+ +---------------+ 164 | |--(A)- Authorization Request ->| Resource | 165 | | | Owner | 166 | |<-(B)-- Authorization Grant ---| | 167 | | +---------------+ 168 | | 169 | | Authorization Grant & +---------------+ 170 | |--(C)--- Client Credentials -->| Authorization | 171 | Client | | Server | 172 | |<-(D)----- Access Token -------| | 173 | | +---------------+ 174 | | 175 | | +---------------+ 176 | |--(E)----- Access Token ------>| Resource | 177 | | | Server | 178 | |<-(F)--- Protected Resource ---| | 179 +--------+ +---------------+ 181 Figure 1: Abstract Protocol Flow 183 The abstract flow illustrated in Figure 1 describes the overall OAuth 184 2.0 protocol architecture. The following steps are specified within 185 this document: 187 E) The client makes a protected resource request to the resource 188 server by presenting the access token. 190 F) The resource server validates the access token, and if valid, 191 serves the request. 193 This document also imposes semantic requirements upon the access 194 token returned in Step D. 196 2. Authenticated Requests 198 This section defines three methods of sending bearer access tokens in 199 resource requests to resource servers. Clients MUST NOT use more 200 than one method to transmit the token in each request. 202 2.1. Authorization Request Header Field 204 When sending the access token in the "Authorization" request header 205 field defined by HTTP/1.1, Part 7 [I-D.ietf-httpbis-p7-auth], the 206 client uses the "Bearer" authentication scheme to transmit the access 207 token. 209 For example: 210 GET /resource HTTP/1.1 211 Host: server.example.com 212 Authorization: Bearer mF_9.B5f-4.1JqM 214 The "Authorization" header field uses the framework defined by 215 HTTP/1.1, Part 7 [I-D.ietf-httpbis-p7-auth] as follows: 216 credentials = "Bearer" 1*SP b64token 218 The b64token syntax was chosen over the alternative #auth-param 219 syntax also defined by HTTP/1.1, Part 7 [I-D.ietf-httpbis-p7-auth] 220 both for simplicity and for compatibility with existing 221 implementations. If additional parameters are needed in the future, 222 a different scheme would need to be defined. 224 Clients SHOULD make authenticated requests with a bearer token using 225 the "Authorization" request header field with the "Bearer" HTTP 226 authorization scheme. Resource servers MUST support this method. 228 2.2. Form-Encoded Body Parameter 230 When sending the access token in the HTTP request entity-body, the 231 client adds the access token to the request body using the 232 "access_token" parameter. The client MUST NOT use this method unless 233 all of the following conditions are met: 235 o The HTTP request entity-header includes the "Content-Type" header 236 field set to "application/x-www-form-urlencoded". 238 o The entity-body follows the encoding requirements of the 239 "application/x-www-form-urlencoded" content-type as defined by 240 HTML 4.01 [W3C.REC-html401-19991224]. 242 o The HTTP request entity-body is single-part. 244 o The content to be encoded in the entity-body MUST consist entirely 245 of ASCII [USASCII] characters. 247 o The HTTP request method is one for which the request body has 248 defined semantics. In particular, this means that the "GET" 249 method MUST NOT be used. 251 The entity-body MAY include other request-specific parameters, in 252 which case, the "access_token" parameter MUST be properly separated 253 from the request-specific parameters using "&" character(s) (ASCII 254 code 38). 256 For example, the client makes the following HTTP request using 257 transport-layer security: 258 POST /resource HTTP/1.1 259 Host: server.example.com 260 Content-Type: application/x-www-form-urlencoded 262 access_token=mF_9.B5f-4.1JqM 264 The "application/x-www-form-urlencoded" method SHOULD NOT be used 265 except in application contexts where participating browsers do not 266 have access to the "Authorization" request header field. Resource 267 servers MAY support this method. 269 2.3. URI Query Parameter 271 When sending the access token in the HTTP request URI, the client 272 adds the access token to the request URI query component as defined 273 by Uniform Resource Identifier (URI) [RFC3986] using the 274 "access_token" parameter. 276 For example, the client makes the following HTTP request using 277 transport-layer security: 278 GET /resource?access_token=mF_9.B5f-4.1JqM HTTP/1.1 279 Host: server.example.com 281 The HTTP request URI query can include other request-specific 282 parameters, in which case, the "access_token" parameter MUST be 283 properly separated from the request-specific parameters using "&" 284 character(s) (ASCII code 38). 286 For example: 287 https://server.example.com/resource?x=y&access_token=mF_9.B5f-4.1JqM&p=q 289 Clients using the URI Query Parameter method SHOULD also send a 290 Cache-Control header containing the "no-store" option. Server 291 success (2XX status) responses to these requests SHOULD contain a 292 Cache-Control header with the "private" option. 294 Because of the security weaknesses associated with the URI method 295 (see Section 5), including the high likelihood that the URL 296 containing the access token will be logged, it SHOULD NOT be used 297 unless it is impossible to transport the access token in the 298 "Authorization" request header field or the HTTP request entity-body. 299 Resource servers MAY support this method. 301 This method is included to document current use; its use is not 302 recommended, both due to its security deficiencies (see Section 5) 303 and because it uses a reserved query parameter name, which is counter 304 to URI namespace best practices, per the Architecture of the World 305 Wide Web [W3C.REC-webarch-20041215]. 307 3. The WWW-Authenticate Response Header Field 309 If the protected resource request does not include authentication 310 credentials or does not contain an access token that enables access 311 to the protected resource, the resource server MUST include the HTTP 312 "WWW-Authenticate" response header field; it MAY include it in 313 response to other conditions as well. The "WWW-Authenticate" header 314 field uses the framework defined by HTTP/1.1, Part 7 315 [I-D.ietf-httpbis-p7-auth]. 317 All challenges defined by this specification MUST use the auth-scheme 318 value "Bearer". This scheme MUST be followed by one or more auth- 319 param values. The auth-param attributes used or defined by this 320 specification are as follows. Other auth-param attributes MAY be 321 used as well. 323 A "realm" attribute MAY be included to indicate the scope of 324 protection in the manner described in HTTP/1.1, Part 7 325 [I-D.ietf-httpbis-p7-auth]. The "realm" attribute MUST NOT appear 326 more than once. 328 The "scope" attribute is defined in Section 3.3 of OAuth 2.0 329 Authorization [I-D.ietf-oauth-v2]. The "scope" attribute is a space- 330 delimited list of case sensitive scope values indicating the required 331 scope of the access token for accessing the requested resource. 332 "scope" values are implementation defined; there is no centralized 333 registry for them; allowed values are defined by the authorization 334 server. The order of "scope" values is not significant. In some 335 cases, the "scope" value will be used when requesting a new access 336 token with sufficient scope of access to utilize the protected 337 resource. Use of the "scope" attribute is OPTIONAL. The "scope" 338 attribute MUST NOT appear more than once. The "scope" value is 339 intended for programmatic use and is not meant to be displayed to end 340 users. 342 Two example scope values follow; these are taken from the OpenID 343 Connect [OpenID.Messages] and OATC Online Multimedia Authorization 344 Protocol [OMAP] OAuth 2.0 use cases, respectively: 345 scope="openid profile email" 346 scope="urn:example:channel=HBO&urn:example:rating=G,PG-13" 348 If the protected resource request included an access token and failed 349 authentication, the resource server SHOULD include the "error" 350 attribute to provide the client with the reason why the access 351 request was declined. The parameter value is described in 352 Section 3.1. In addition, the resource server MAY include the 353 "error_description" attribute to provide developers a human-readable 354 explanation that is not meant to be displayed to end users. It also 355 MAY include the "error_uri" attribute with an absolute URI 356 identifying a human-readable web page explaining the error. The 357 "error", "error_description", and "error_uri" attributes MUST NOT 358 appear more than once. 360 Values for the "scope" attribute MUST NOT include characters outside 361 the set %x21 / %x23-5B / %x5D-7E specified in Section A.4 of OAuth 362 2.0 Authorization [I-D.ietf-oauth-v2] for representing scope values 363 and %x20 for delimiters between scope values. Values for the "error" 364 and "error_description" attributes MUST NOT include characters 365 outside the set %x20-21 / %x23-5B / %x5D-7E specified in Sections A.7 366 and A.8 of OAuth 2.0 Authorization. Values for the "error_uri" 367 attribute MUST conform to the URI-Reference syntax, and thus MUST NOT 368 include characters outside the set %x21 / %x23-5B / %x5D-7E specified 369 in Section A.9 of OAuth 2.0 Authorization. 371 For example, in response to a protected resource request without 372 authentication: 373 HTTP/1.1 401 Unauthorized 374 WWW-Authenticate: Bearer realm="example" 376 And in response to a protected resource request with an 377 authentication attempt using an expired access token: 378 HTTP/1.1 401 Unauthorized 379 WWW-Authenticate: Bearer realm="example", 380 error="invalid_token", 381 error_description="The access token expired" 383 3.1. Error Codes 385 When a request fails, the resource server responds using the 386 appropriate HTTP status code (typically, 400, 401, 403, or 405), and 387 includes one of the following error codes in the response: 389 invalid_request 390 The request is missing a required parameter, includes an 391 unsupported parameter or parameter value, repeats the same 392 parameter, uses more than one method for including an access 393 token, or is otherwise malformed. The resource server SHOULD 394 respond with the HTTP 400 (Bad Request) status code. 396 invalid_token 397 The access token provided is expired, revoked, malformed, or 398 invalid for other reasons. The resource SHOULD respond with 399 the HTTP 401 (Unauthorized) status code. The client MAY 400 request a new access token and retry the protected resource 401 request. 403 insufficient_scope 404 The request requires higher privileges than provided by the 405 access token. The resource server SHOULD respond with the HTTP 406 403 (Forbidden) status code and MAY include the "scope" 407 attribute with the scope necessary to access the protected 408 resource. 410 If the request lacks any authentication information (e.g., the client 411 was unaware authentication is necessary or attempted using an 412 unsupported authentication method), the resource server SHOULD NOT 413 include an error code or other error information. 415 For example: 416 HTTP/1.1 401 Unauthorized 417 WWW-Authenticate: Bearer realm="example" 419 4. Example Access Token Response 421 Typically a bearer token is returned to the client as part of an 422 OAuth 2.0 [I-D.ietf-oauth-v2] access token response. An example of 423 such a response is: 424 HTTP/1.1 200 OK 425 Content-Type: application/json;charset=UTF-8 426 Cache-Control: no-store 427 Pragma: no-cache 429 { 430 "access_token":"mF_9.B5f-4.1JqM", 431 "token_type":"Bearer", 432 "expires_in":3600, 433 "refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA" 434 } 436 5. Security Considerations 438 This section describes the relevant security threats regarding token 439 handling when using bearer tokens and describes how to mitigate these 440 threats. 442 5.1. Security Threats 444 The following list presents several common threats against protocols 445 utilizing some form of tokens. This list of threats is based on NIST 446 Special Publication 800-63 [NIST800-63]. Since this document builds 447 on the OAuth 2.0 Authorization specification, we exclude a discussion 448 of threats that are described there or in related documents. 450 Token manufacture/modification: An attacker may generate a bogus 451 token or modify the token contents (such as the authentication or 452 attribute statements) of an existing token, causing the resource 453 server to grant inappropriate access to the client. For example, 454 an attacker may modify the token to extend the validity period; a 455 malicious client may modify the assertion to gain access to 456 information that they should not be able to view. 458 Token disclosure: Tokens may contain authentication and attribute 459 statements that include sensitive information. 461 Token redirect: An attacker uses a token generated for consumption 462 by one resource server to gain access to a different resource 463 server that mistakenly believes the token to be for it. 465 Token replay: An attacker attempts to use a token that has already 466 been used with that resource server in the past. 468 5.2. Threat Mitigation 470 A large range of threats can be mitigated by protecting the contents 471 of the token by using a digital signature or a Message Authentication 472 Code (MAC). Alternatively, a bearer token can contain a reference to 473 authorization information, rather than encoding the information 474 directly. Such references MUST be infeasible for an attacker to 475 guess; using a reference may require an extra interaction between a 476 server and the token issuer to resolve the reference to the 477 authorization information. The mechanics of such an interaction are 478 not defined by this specification. 480 This document does not specify the encoding or the contents of the 481 token; hence detailed recommendations about the means of guaranteeing 482 token integrity protection are outside the scope of this document. 483 The token integrity protection MUST be sufficient to prevent the 484 token from being modified. 486 To deal with token redirect, it is important for the authorization 487 server to include the identity of the intended recipients (the 488 audience), typically a single resource server (or a list of resource 489 servers), in the token. Restricting the use of the token to a 490 specific scope is also RECOMMENDED. 492 The authorization server MUST implement TLS. Which version(s) ought 493 to be implemented will vary over time, and depend on the widespread 494 deployment and known security vulnerabilities at the time of 495 implementation. At the time of this writing, TLS version 1.2 496 [RFC5246] is the most recent version, but has very limited actual 497 deployment, and might not be readily available in implementation 498 toolkits. TLS version 1.0 [RFC2246] is the most widely deployed 499 version, and will give the broadest interoperability. 501 To protect against token disclosure, confidentiality protection MUST 502 be applied using TLS [RFC5246] with a ciphersuite that provides 503 confidentiality and integrity protection. This requires that the 504 communication interaction between the client and the authorization 505 server, as well as the interaction between the client and the 506 resource server, utilize confidentiality and integrity protection. 507 Since TLS is mandatory to implement and to use with this 508 specification, it is the preferred approach for preventing token 509 disclosure via the communication channel. For those cases where the 510 client is prevented from observing the contents of the token, token 511 encryption MUST be applied in addition to the usage of TLS 512 protection. As a further defense against token disclosure, the 513 client MUST validate the TLS certificate chain when making requests 514 to protected resources, including checking the Certificate Revocation 515 List (CRL) [RFC5280]. 517 Cookies are typically transmitted in the clear. Thus, any 518 information contained in them is at risk of disclosure. Therefore, 519 bearer tokens MUST NOT be stored in cookies that can be sent in the 520 clear. See HTTP State Management Mechanism [RFC6265] for security 521 considerations about cookies. 523 In some deployments, including those utilizing load balancers, the 524 TLS connection to the resource server terminates prior to the actual 525 server that provides the resource. This could leave the token 526 unprotected between the front end server where the TLS connection 527 terminates and the back end server that provides the resource. In 528 such deployments, sufficient measures MUST be employed to ensure 529 confidentiality of the token between the front end and back end 530 servers; encryption of the token is one possible such measure. 532 To deal with token capture and replay, the following recommendations 533 are made: First, the lifetime of the token MUST be limited; one means 534 of achieving this is by putting a validity time field inside the 535 protected part of the token. Note that using short-lived (one hour 536 or less) tokens reduces the impact of them being leaked. Second, 537 confidentiality protection of the exchanges between the client and 538 the authorization server and between the client and the resource 539 server MUST be applied. As a consequence, no eavesdropper along the 540 communication path is able to observe the token exchange. 541 Consequently, such an on-path adversary cannot replay the token. 542 Furthermore, when presenting the token to a resource server, the 543 client MUST verify the identity of that resource server, as per 544 Section 3.1 of HTTP Over TLS [RFC2818]. Note that the client MUST 545 validate the TLS certificate chain when making these requests to 546 protected resources. Presenting the token to an unauthenticated and 547 unauthorized resource server or failing to validate the certificate 548 chain will allow adversaries to steal the token and gain unauthorized 549 access to protected resources. 551 5.3. Summary of Recommendations 553 Safeguard bearer tokens: Client implementations MUST ensure that 554 bearer tokens are not leaked to unintended parties, as they will 555 be able to use them to gain access to protected resources. This 556 is the primary security consideration when using bearer tokens and 557 underlies all the more specific recommendations that follow. 559 Validate TLS certificate chains: The client MUST validate the TLS 560 certificate chain when making requests to protected resources. 561 Failing to do so may enable DNS hijacking attacks to steal the 562 token and gain unintended access. 564 Always use TLS (https): Clients MUST always use TLS [RFC5246] 565 (https) or equivalent transport security when making requests with 566 bearer tokens. Failing to do so exposes the token to numerous 567 attacks that could give attackers unintended access. 569 Don't store bearer tokens in cookies: Implementations MUST NOT store 570 bearer tokens within cookies that can be sent in the clear (which 571 is the default transmission mode for cookies). Implementations 572 that do store bearer tokens in cookies MUST take precautions 573 against cross site request forgery. 575 Issue short-lived bearer tokens: Token servers SHOULD issue short- 576 lived (one hour or less) bearer tokens, particularly when issuing 577 tokens to clients that run within a web browser or other 578 environments where information leakage may occur. Using short- 579 lived bearer tokens can reduce the impact of them being leaked. 581 Issue scoped bearer tokens: Token servers SHOULD issue bearer tokens 582 that contain an audience restriction, scoping their use to the 583 intended relying party or set of relying parties. 585 Don't pass bearer tokens in page URLs: Bearer tokens SHOULD NOT be 586 passed in page URLs (for example as query string parameters). 587 Instead, bearer tokens SHOULD be passed in HTTP message headers or 588 message bodies for which confidentiality measures are taken. 589 Browsers, web servers, and other software may not adequately 590 secure URLs in the browser history, web server logs, and other 591 data structures. If bearer tokens are passed in page URLs, 592 attackers might be able to steal them from the history data, logs, 593 or other unsecured locations. 595 6. IANA Considerations 597 6.1. OAuth Access Token Type Registration 599 This specification registers the following access token type in the 600 OAuth Access Token Type Registry defined in OAuth 2.0 Authorization 601 [I-D.ietf-oauth-v2]. 603 6.1.1. The "Bearer" OAuth Access Token Type 605 Type name: 606 Bearer 608 Additional Token Endpoint Response Parameters: 609 (none) 611 HTTP Authentication Scheme(s): 612 Bearer 614 Change controller: 615 IETF 617 Specification document(s): 618 [[ this document ]] 620 6.2. OAuth Extensions Error Registration 622 This specification registers the following error values in the OAuth 623 Extensions Error Registry defined in OAuth 2.0 Authorization 624 [I-D.ietf-oauth-v2]. 626 6.2.1. The "invalid_request" Error Value 627 Error name: 628 invalid_request 630 Error usage location: 631 Resource access error response 633 Related protocol extension: 634 Bearer access token type 636 Change controller: 637 IETF 639 Specification document(s): 640 [[ this document ]] 642 6.2.2. The "invalid_token" Error Value 644 Error name: 645 invalid_token 647 Error usage location: 648 Resource access error response 650 Related protocol extension: 651 Bearer access token type 653 Change controller: 654 IETF 656 Specification document(s): 657 [[ this document ]] 659 6.2.3. The "insufficient_scope" Error Value 661 Error name: 662 insufficient_scope 664 Error usage location: 665 Resource access error response 667 Related protocol extension: 668 Bearer access token type 670 Change controller: 671 IETF 673 Specification document(s): 674 [[ this document ]] 676 6.3. Authentication Scheme Registration 678 This specification registers the following authentication scheme in 679 the Authentication Scheme Registry defined in HTTP/1.1, Part 7 680 [I-D.ietf-httpbis-p7-auth]. 682 6.3.1. The "Bearer" Authentication Scheme 684 Authentication Scheme Name: 685 Bearer 687 Pointer to specification text: 688 [[ this document ]] 690 Notes (optional): 691 (none) 693 7. References 695 7.1. Normative References 697 [I-D.ietf-httpbis-p1-messaging] 698 Fielding, R., Lafon, Y., and J. Reschke, "HTTP/1.1, part 699 1: URIs, Connections, and Message Parsing", 700 draft-ietf-httpbis-p1-messaging-19 (work in progress), 701 March 2012. 703 [I-D.ietf-httpbis-p7-auth] 704 Fielding, R., Lafon, Y., and J. Reschke, "HTTP/1.1, part 705 7: Authentication", draft-ietf-httpbis-p7-auth-19 (work in 706 progress), March 2012. 708 [I-D.ietf-oauth-v2] 709 Hammer, E., Recordon, D., and D. Hardt, "The OAuth 2.0 710 Authorization Framework", draft-ietf-oauth-v2-28 (work in 711 progress), June 2012. 713 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 714 Requirement Levels", BCP 14, RFC 2119, March 1997. 716 [RFC2246] Dierks, T. and C. Allen, "The TLS Protocol Version 1.0", 717 RFC 2246, January 1999. 719 [RFC2818] Rescorla, E., "HTTP Over TLS", RFC 2818, May 2000. 721 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 722 Resource Identifier (URI): Generic Syntax", STD 66, 723 RFC 3986, January 2005. 725 [RFC5234] Crocker, D. and P. Overell, "Augmented BNF for Syntax 726 Specifications: ABNF", STD 68, RFC 5234, January 2008. 728 [RFC5246] Dierks, T. and E. Rescorla, "The Transport Layer Security 729 (TLS) Protocol Version 1.2", RFC 5246, August 2008. 731 [RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., 732 Housley, R., and W. Polk, "Internet X.509 Public Key 733 Infrastructure Certificate and Certificate Revocation List 734 (CRL) Profile", RFC 5280, May 2008. 736 [RFC6265] Barth, A., "HTTP State Management Mechanism", RFC 6265, 737 April 2011. 739 [USASCII] American National Standards Institute, "Coded Character 740 Set -- 7-bit American Standard Code for Information 741 Interchange", ANSI X3.4, 1986. 743 [W3C.REC-html401-19991224] 744 Hors, A., Raggett, D., and I. Jacobs, "HTML 4.01 745 Specification", World Wide Web Consortium 746 Recommendation REC-html401-19991224, December 1999, 747 . 749 [W3C.REC-webarch-20041215] 750 Jacobs, I. and N. Walsh, "Architecture of the World Wide 751 Web, Volume One", World Wide Web Consortium 752 Recommendation REC-webarch-20041215, December 2004, 753 . 755 7.2. Informative References 757 [NIST800-63] 758 Burr, W., Dodson, D., Perlner, R., Polk, T., Gupta, S., 759 and E. Nabbus, "NIST Special Publication 800-63-1, 760 INFORMATION SECURITY", December 2008. 762 [OMAP] Huff, J., Schlacht, D., Nadalin, A., Simmons, J., 763 Rosenberg, P., Madsen, P., Ace, T., Rickelton-Abdi, C., 764 and B. Boyer, "Online Multimedia Authorization Protocol: 765 An Industry Standard for Authorized Access to Internet 766 Multimedia Resources", April 2012. 768 [OpenID.Messages] 769 Sakimura, N., Bradley, J., Jones, M., de Medeiros, B., 770 Mortimore, C., and E. Jay, "OpenID Connect Messages 1.0", 771 May 2012. 773 [RFC2616] Fielding, R., Gettys, J., Mogul, J., Frystyk, H., 774 Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext 775 Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999. 777 [RFC2617] Franks, J., Hallam-Baker, P., Hostetler, J., Lawrence, S., 778 Leach, P., Luotonen, A., and L. Stewart, "HTTP 779 Authentication: Basic and Digest Access Authentication", 780 RFC 2617, June 1999. 782 Appendix A. Acknowledgements 784 The following people contributed to preliminary versions of this 785 document: Blaine Cook (BT), Brian Eaton (Google), Yaron Y. Goland 786 (Microsoft), Brent Goldman (Facebook), Raffi Krikorian (Twitter), 787 Luke Shepard (Facebook), and Allen Tom (Yahoo!). The content and 788 concepts within are a product of the OAuth community, the WRAP 789 community, and the OAuth Working Group. 791 The OAuth Working Group has dozens of very active contributors who 792 proposed ideas and wording for this document, including: Michael 793 Adams, Amanda Anganes, Andrew Arnott, Derek Atkins, Dirk Balfanz, 794 John Bradley, Brian Campbell, Francisco Corella, Leah Culver, Bill de 795 hOra, Breno de Medeiros, Brian Ellin, Igor Faynberg, Stephen Farrell, 796 Igor Faynberg, George Fletcher, Tim Freeman, Evan Gilbert, Yaron Y. 797 Goland, Thomas Hardjono, Justin Hart, Phil Hunt, John Kemp, Eran 798 Hammer, Chasen Le Hara, Dick Hardt, Barry Leiba, Amos Jeffries, 799 Michael B. Jones, Torsten Lodderstedt, Paul Madsen, Eve Maler, James 800 Manger, Laurence Miao, William J. Mills, Chuck Mortimore, Anthony 801 Nadalin, Axel Nennker, Mark Nottingham, David Recordon, Julian 802 Reschke, Rob Richards, Justin Richer, Peter Saint-Andre, Nat 803 Sakimura, Rob Sayre, Marius Scurtescu, Naitik Shah, Justin Smith, 804 Jeremy Suriel, Christian Stuebner, Doug Tangren, Paul Tarjan, Hannes 805 Tschofenig, Franklin Tse, Sean Turner, Paul Walker, Shane Weeden, 806 Skylar Woodward, and Zachary Zeltsan. 808 Appendix B. Document History 810 [[ to be removed by the RFC editor before publication as an RFC ]] 812 -21 813 o Changed "NOT RECOMMENDED" to "not recommended" in caveat about the 814 URI Query Parameter method. 816 o Changed "other specifications may extend this specification for 817 use with other transport protocols" to "other specifications may 818 extend this specification for use with other protocols". 820 o Changed Acknowledgements to use only ASCII characters, per the RFC 821 style guide. 823 -20 825 o Added caveat about using a reserved query parameter name being 826 counter to URI namespace best practices. 828 o Specified use of Cache-Control options when using the URI Query 829 Parameter method. 831 o Changed title to "The OAuth 2.0 Authorization Framework: Bearer 832 Token Usage". 834 o Referenced syntax definitions for the "scope", "error", 835 "error_description", and "error_uri" parameters in the OAuth 2.0 836 core spec. 838 o Registered the "invalid_request", "invalid_token", and 839 "insufficient_scope" error values in the OAuth Extensions Error 840 Registry. 842 o Acknowledged additional individuals. 844 -19 846 o Addressed DISCUSS issues and comments raised for which resolutions 847 have been agreed to. No normative changes were made. Changes 848 made were: 850 o Use ABNF from RFC 5234. 852 o Added sentence "The Bearer authentication scheme is intended 853 primarily for server authentication using the WWW-Authenticate and 854 Authorization HTTP headers, but does not preclude its use for 855 proxy authentication" to the introduction. 857 o In the introduction, state that this document also imposes 858 semantic requirements upon the access token. 860 o Reference the "scope" definition in the OAuth core spec. 862 o Added "scope" examples. 864 o Reference RFC 6265 for security considerations about cookies. 866 -18 868 o Changed example bearer token value from vF9dft4qmT to mF_9.B5f- 869 4.1JqM. 871 o Added example access token response returning a Bearer token. 873 -17 875 o Restore RFC 2818 reference for server identity verification and 876 add RFC 5280 reference for certificate revocation lists, per Gen- 877 ART review comments. 879 -16 881 o Use the HTTPbis auth-param syntax for Bearer challenge attributes. 883 o Dropped the sentence "The "realm" value is intended for 884 programmatic use and is not meant to be displayed to end users". 886 o Reordered form-encoded body parameter description bullets for 887 better readability. 889 o Added [USASCII] reference. 891 -15 893 o Clarified that form-encoded content must consist entirely of ASCII 894 characters. 896 o Added TLS version requirements. 898 o Applied editorial improvements suggested by Mark Nottingham during 899 the APPS area review. 901 -14 903 o Changes made in response to review comments by Security Area 904 Director Stephen Farrell. Specifically: 906 o Strengthened warnings about passing an access token as a query 907 parameter and more precisely described the limitations placed upon 908 the use of this method. 910 o Clarified that the "realm" attribute MAY included to indicate the 911 scope of protection in the manner described in HTTP/1.1, Part 7 912 [I-D.ietf-httpbis-p7-auth]. 914 o Normatively stated that "the token integrity protection MUST be 915 sufficient to prevent the token from being modified". 917 o Added statement that "TLS is mandatory to implement and use with 918 this specification" to the introduction. 920 o Stated that TLS MUST be used with "a ciphersuite that provides 921 confidentiality and integrity protection". 923 o Added "As a further defense against token disclosure, the client 924 MUST validate the TLS certificate chain when making requests to 925 protected resources" to the Threat Mitigation section. 927 o Clarified that putting a validity time field inside the protected 928 part of the token is one means, but not the only means, of 929 limiting the lifetime of the token. 931 o Dropped the confusing phrase "for instance, through the use of 932 TLS" from the sentence about confidentiality protection of the 933 exchanges. 935 o Reference RFC 6125 for identity verification, rather than RFC 936 2818. 938 o Stated that the token MUST be protected between front end and back 939 end servers when the TLS connection terminates at a front end 940 server that is distinct from the actual server that provides the 941 resource. 943 o Stated that bearer tokens MUST NOT be stored in cookies that can 944 be sent in the clear in the Threat Mitigation section. 946 o Replaced sole remaining reference to [RFC2616] with HTTPbis 947 [I-D.ietf-httpbis-p1-messaging] reference. 949 o Replaced all references where the reference is used as if it were 950 part of the sentence (such as "defined by [I-D.whatever]") with 951 ones where the specification name is used, followed by the 952 reference (such as "defined by Whatever [I-D.whatever]"). 954 o Other on-normative editorial improvements. 956 -13 958 o At the request of Hannes Tschofenig, made ABNF changes to make it 959 clear that no special WWW-Authenticate response header field 960 parsers are needed. The "scope", "error-description", and 961 "error-uri" parameters are all now defined as quoted-string in the 962 ABNF (as "error" already was). Restrictions on these values that 963 were formerly described in the ABNFs are now described in 964 normative text instead. 966 -12 968 o Made non-normative editorial changes that Hannes Tschofenig 969 requested be applied prior to forwarding the specification to the 970 IESG. 972 o Added rationale for the choice of the b64token syntax. 974 o Added rationale stating that receivers are free to parse the 975 "scope" attribute using a standard quoted-string parser, since it 976 will correctly process all legal "scope" values. 978 o Added additional active working group contributors to the 979 Acknowledgements section. 981 -11 983 o Replaced uses of <"> with DQUOTE to pass ABNF syntax check. 985 -10 987 o Removed the #auth-param option from Authorization header syntax 988 (leaving only the b64token syntax). 990 o Restricted the "scope" value character set to %x21 / %x23-5B / 991 %x5D-7E (printable ASCII characters excluding double-quote and 992 backslash). Indicated that scope is intended for programmatic use 993 and is not meant to be displayed to end users. 995 o Restricted the character set for "error_description" strings to SP 996 / VCHAR and indicated that they are not meant to be displayed to 997 end users. 999 o Included more description in the Abstract, since Hannes Tschofenig 1000 indicated that the RFC editor would require this. 1002 o Changed "Access Grant" to "Authorization Grant", as was done in 1003 the core spec. 1005 o Simplified the introduction to the Authenticated Requests section. 1007 -09 1009 o Incorporated working group last call comments. Specific changes 1010 were: 1012 o Use definitions from [I-D.ietf-httpbis-p7-auth] rather than 1013 [RFC2617]. 1015 o Update credentials definition to conform to 1016 [I-D.ietf-httpbis-p7-auth]. 1018 o Further clarified that query parameters may occur in any order. 1020 o Specify that error_description is UTF-8 encoded (matching the core 1021 specification). 1023 o Registered "Bearer" Authentication Scheme in Authentication Scheme 1024 Registry defined by [I-D.ietf-httpbis-p7-auth]. 1026 o Updated references to oauth-v2, httpbis-p1-messaging, and httpbis- 1027 p7-auth drafts. 1029 o Other wording improvements not introducing normative changes. 1031 -08 1033 o Updated references to oauth-v2 and HTTPbis drafts. 1035 -07 1037 o Added missing comma in error response example. 1039 -06 1041 o Changed parameter name "bearer_token" to "access_token", per 1042 working group consensus. 1044 o Changed HTTP status code for "invalid_request" error code from 1045 HTTP 401 (Unauthorized) back to HTTP 400 (Bad Request), per input 1046 from HTTP working group experts. 1048 -05 1050 o Removed OAuth Errors Registry, per design team input. 1052 o Changed HTTP status code for "invalid_request" error code from 1053 HTTP 400 (Bad Request) to HTTP 401 (Unauthorized) to match HTTP 1054 usage [[ change pending working group consensus ]]. 1056 o Added missing quotation marks in error-uri definition. 1058 o Added note to add language and encoding information to 1059 error_description if the core specification does. 1061 o Explicitly reference the Augmented Backus-Naur Form (ABNF) defined 1062 in [RFC5234]. 1064 o Use auth-param instead of repeating its definition, which is ( 1065 token "=" ( token / quoted-string ) ). 1067 o Clarify security considerations about including an audience 1068 restriction in the token and include a recommendation to issue 1069 scoped bearer tokens in the summary of recommendations. 1071 -04 1073 o Edits responding to working group last call feedback on -03. 1074 Specific edits enumerated below. 1076 o Added Bearer Token definition in Terminology section. 1078 o Changed parameter name "oauth_token" to "bearer_token". 1080 o Added realm parameter to "WWW-Authenticate" response to comply 1081 with [RFC2617]. 1083 o Removed "[ RWS 1#auth-param ]" from "credentials" definition since 1084 it did not comply with the ABNF in [I-D.ietf-httpbis-p7-auth]. 1086 o Removed restriction that the "bearer_token" (formerly 1087 "oauth_token") parameter be the last parameter in the entity-body 1088 and the HTTP request URI query. 1090 o Do not require WWW-Authenticate Response in a reply to a malformed 1091 request, as an HTTP 400 Bad Request response without a WWW- 1092 Authenticate header is likely the right response in some cases of 1093 malformed requests. 1095 o Removed OAuth Parameters registry extension. 1097 o Numerous editorial improvements suggested by working group 1098 members. 1100 -03 1102 o Restored the WWW-Authenticate response header functionality 1103 deleted from the framework specification in draft 12 based upon 1104 the specification text from draft 11. 1106 o Augmented the OAuth Parameters registry by adding two additional 1107 parameter usage locations: "resource request" and "resource 1108 response". 1110 o Registered the "oauth_token" OAuth parameter with usage location 1111 "resource request". 1113 o Registered the "error" OAuth parameter. 1115 o Created the OAuth Error registry and registered errors. 1117 o Changed the "OAuth2" OAuth access token type name to "Bearer". 1119 -02 1121 o Incorporated feedback received on draft 01. Most changes were to 1122 the security considerations section. No normative changes were 1123 made. Specific changes included: 1125 o Changed terminology from "token reuse" to "token capture and 1126 replay". 1128 o Removed sentence "Encrypting the token contents is another 1129 alternative" from the security considerations since it was 1130 redundant and potentially confusing. 1132 o Corrected some references to "resource server" to be 1133 "authorization server" in the security considerations. 1135 o Generalized security considerations language about obtaining 1136 consent of the resource owner. 1138 o Broadened scope of security considerations description for 1139 recommendation "Don't pass bearer tokens in page URLs". 1141 o Removed unused reference to OAuth 1.0. 1143 o Updated reference to framework specification and updated David 1144 Recordon's e-mail address. 1146 o Removed security considerations text on authenticating clients. 1148 o Registered the "OAuth2" OAuth access token type and "oauth_token" 1149 parameter. 1151 -01 1153 o First public draft, which incorporates feedback received on -00 1154 including enhanced Security Considerations content. This version 1155 is intended to accompany OAuth 2.0 draft 11. 1157 -00 1159 o Initial draft based on preliminary version of OAuth 2.0 draft 11. 1161 Authors' Addresses 1163 Michael B. Jones 1164 Microsoft 1166 Email: mbj@microsoft.com 1167 URI: http://self-issued.info/ 1169 Dick Hardt 1170 independent 1172 Email: dick.hardt@gmail.com 1173 URI: http://dickhardt.org/ 1175 David Recordon 1176 Facebook 1178 Email: dr@fb.com 1179 URI: http://www.davidrecordon.com/