TOC |
|
This document specifies the OAuth 2.0 MAC token type and authentication scheme.
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as “work in progress.”
This Internet-Draft will expire on July 13, 2011.
Copyright (c) 2011 IETF Trust and the persons identified as the document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
1.
Introduction
1.1.
Example
1.2.
Notational Conventions
2.
Issuing MAC-Type Access Tokens
3.
Making Requests
3.1.
The Authorization Request Header
3.2.
Signature
3.2.1.
Normalized Request String
3.2.2.
hmac-sha-1
3.2.3.
hmac-sha-256
4.
Verifying Requests
5.
Scheme Extensions
6.
Security Considerations
6.1.
Secrets Transmission
6.2.
Confidentiality of Requests
6.3.
Spoofing by Counterfeit Servers
6.4.
Plaintext Storage of Credentials
6.5.
Entropy of Secrets
6.6.
Denial of Service / Resource Exhaustion Attacks
6.7.
Coverage Limitations
7.
IANA Considerations
7.1.
The "secret" OAuth Parameter
7.2.
The "secret" OAuth Parameter
8.
Acknowledgments
Appendix A.
Document History
9.
References
9.1.
Normative References
9.2.
Informative References
§
Author's Address
TOC |
OAuth 2.0 ([I‑D.ietf‑oauth‑v2] (Hammer-Lahav, E., Recordon, D., and D. Hardt, “The OAuth 2.0 Protocol Framework,” November 2010.)) defines a token-based authentication framework in which third-party applications (clients) access protected resources using access tokens. Access tokens are obtained via the resource owners' authorization from an authorization server.
This specification defines the MAC token type for use with the OAuth 2.0 framework. It defines type-specific token attributes and provides a method for making authenticated HTTP requests with partial cryptographic verification of the request - covering the HTTP method, request URI, host, and in some cases the request body.
This specification does not define methods for the client to specifically request a MAC-type token from the authorization server. Additionally, it does not include any discovery facilities for identifying which token types are supported by a resource server or how the client may go about obtaining access tokens. This specification assumes that the authorization server has issued the client a MAC-type token and describes how the client authenticates using that access token.
The MAC token type is not compatible with the HMAC-SHA1 signature method defined in OAuth 1.0 (Hammer-Lahav, E., “The OAuth 1.0 Protocol,” April 2010.) [RFC5849].
This specification is an extension of [I‑D.ietf‑oauth‑v2] (Hammer-Lahav, E., Recordon, D., and D. Hardt, “The OAuth 2.0 Protocol Framework,” November 2010.) and uses its terminology.
Please discuss this draft on the oauth@ietf.org mailing list.
TOC |
The client attempts to access a protected resource without authentication, making the following HTTP request to the resource server:
GET /resource/1?b=1&a=2 HTTP/1.1 Host: example.com
The resource server returns the following authentication challenge:
HTTP/1.1 401 Unauthorized WWW-Authenticate: OAuth2 Date: Thu, 02 Dec 2010 21:39:45 GMT
The client has previously obtained a set of token credentials for accessing resources on the http://example.com/ resource server. The credentials issued to the client by the authorization server included the following attributes:
- Access token:
- h480djs93hd8
- Token type:
- mac
- MAC algorithm:
- hmac-sha-1
- Token secret:
- 489dks293j39
The client attempts the HTTP request again, this time using the token credentials issued by the authorization server earlier to authenticate. To construct the authentication header, the client calculates the current timestamp and a nonce. The nonce is unique to the timestamp used, typically a random string:
- Timestamp:
- 137131200
- Nonce:
- dj83hs9s
The client normalizes the request and constructs the signature base string (the new line separator character is represented by \n for display purposes only):
h480djs93hd8\n 137131200\n dj83hs9s\n GET\n example.com\n 80\n /resource/1\n a=2\n b=1
The signature base string is signed using the specified MAC token algorithm hmac-sha-1 with the signature base string as text and the token secret as key. The resulting digest is base64-encoded to produce the request signature:
IdSrHQHTwCPWGrqzGGIR791ZJXE=
The client includes the access token, timestamp, nonce, and signature with the request using the Authorization request header field:
GET /resource/1 HTTP/1.1 Host: example.com Authorization: MAC token='h480djs93hd8', timestamp='137131200', nonce='dj83hs9s', signature='IdSrHQHTwCPWGrqzGGIR791ZJXE='
The resource server validates the request by calculating the signature again based on the request received and verifies the validity and scope of the access token. If valid, the resource server responds with the requested protected resource representation.
TOC |
The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'MAY', and 'OPTIONAL' in this document are to be interpreted as described in [RFC2119] (Bradner, S., “Key words for use in RFCs to Indicate Requirement Levels,” March 1997.).
This document uses the Augmented Backus-Naur Form (ABNF) notation of [I‑D.ietf‑httpbis‑p1‑messaging] (Fielding, R., Gettys, J., Mogul, J., Nielsen, H., Masinter, L., Leach, P., Berners-Lee, T., and J. Reschke, “HTTP/1.1, part 1: URIs, Connections, and Message Parsing,” October 2009.).
TOC |
Authorization servers issuing MAC-type access tokens MUST include the following parameters whenever a response includes the access_token parameter:
- secret
- REQUIRED. The token shared secret used as the MAC algorithm key.
- algorithm
- REQUIRED. The MAC algorithm used to calculate the request signature. Value MUST be one of hmac-sha-1, hmac-sha-256, or a registered extension algorithm name as described in Section 5 (Scheme Extensions).
TOC |
To make authenticated requests, the client must be in possession of a valid MAC-type access token, issued by an authorization server accepted by the resource server. The client constructs the request by calculating of a set of attributes, and adding them to the HTTP request using the Authorization header field (The Authorization Request Header). Authenticated request can be sent in response to an authentication challenge or directly.
TOC |
The Authorization request header field uses the framework defined by [RFC2617] (Franks, J., Hallam-Baker, P., Hostetler, J., Lawrence, S., Leach, P., Luotonen, A., and L. Stewart, “HTTP Authentication: Basic and Digest Access Authentication,” June 1999.) as follows:
credentials = 'MAC' [ RWS 1#param ] param = access-token / timestamp / nonce / signature access-token = 'token' '=' quoted-string timestamp = 'timestamp' '=' <"> 1*DIGIT <"> nonce = 'nonce' '=' quoted-string signature = 'signature' '=' quoted-string
The token attribute value is set to the access token received from the authorization server.
The timestamp attribute value is set to the current time expressed in the number of seconds since January 1, 1970 00:00:00 GMT, and MUST be a positive integer.
The nonce attribute value is set to a random string, uniquely generated by the client to allow the resource server to verify that a request has never been made before and helps prevent replay attacks when requests are made over an insecure channel. The nonce value MUST be unique across all requests with the same timestamp and access token combination.
To avoid the need to retain an infinite number of nonce values for future checks, servers MAY choose to restrict the time period after which a request with an old timestamp is rejected. Such a restriction implies a level of synchronization between the client's and server's clocks. The client MAY use the Date response header field to synchronize its clock after a failed request.
The signature attribute value is set as described in Section 3.2 (Signature).
Each of the four attributes MUST appear once, and only once.
TOC |
The client uses the MAC token algorithm and the access token secret - both provided by the authorization server - to calculate the request signature. This specification defines two algorithms: hmac-sha-1 and hmac-sha-256, and provides an extension registry for additional algorithms.
TOC |
The normalized request string is a consistent, reproducible concatenation of several of the HTTP request elements into a single string. By normalizing the request into a reproducible string, the client and resource server can both sign the same string. The string is constructed by concatenating together, in order, the following HTTP request elements:
For example, the HTTP request:
GET /request?b5=%3D%253D&a3=a&c%40=&a2=r%20b&c2&a3=2+q HTTP/1.1 Host: example.com
using access token kkk9d7dh3k39sjv7, timestamp 137131201, and nonce 7d8f3e4a is normalized into the following string (the new line Separator character is represented by \n for display purposes only):
kkk9d7dh3k39sjv7\n 137131201\n 7d8f3e4a\n GET\n example.com\n 80\n /request\n a2=r%20b\n a3=2%20q\n a3=a\n b5=%3D%253D\n c%40=\n c2=
TOC |
The query component is parsed into a list of name/value parameter pairs by treating it as an application/x-www-form-urlencoded string, separating the names and values and decoding them as defined by [W3C.REC‑html401‑19991224] (Hors, A., Jacobs, I., and D. Raggett, “HTML 4.01 Specification,” December 1999.) section 17.13.4.
Once separated and decoded, the parameters are concatenated back together as follows:
Note that the percent-encoding method described is different from the encoding scheme used by the application/x-www-form-urlencoded content-type (for example, it encodes space characters as %20 instead of the + character). It MAY be different from the percent-encoding functions provided by web development frameworks (e.g. encode different characters, use lower case hexadecimal characters).
For example, the HTTP request URI:
/request?b5=%3D%253D&a3=a&c%40=&a2=r%20b&c2&a3=2+q
Contains the following (fully decoded) parameters used in the signature base sting:
Name | Value |
---|---|
b5 | =%3D |
a3 | a |
c@ | |
a2 | r b |
c2 | |
a3 | 2 q |
Note that the value of b5 is =%3D and not ==. Both c@ and c2 have empty values. While the encoding rules specified in this specification for the purpose of constructing the signature base string exclude the use of a + character (ASCII code 43) to represent an encoded space character (ASCII code 32), this practice is widely used in application/x-www-form-urlencoded encoded values, and MUST be properly decoded, as demonstrated by one of the a3 parameter instances (the a3 parameter is used twice in this request).
The parsed parameters are normalized as follows:
Encoded:
Name | Value |
---|---|
b5 | %3D%253D |
a3 | a |
c%40 | |
a2 | r%20b |
c2 | |
a3 | 2%20q |
Sorted:
Name | Value |
---|---|
a2 | r%20b |
a3 | 2%20q |
a3 | a |
b5 | %3D%253D |
c%40 | |
c2 |
Concatenated Pairs:
Name=Value |
---|
a2=r%20b |
a3=2%20q |
a3=a |
b5=%3D%253D |
c%40= |
c2= |
And concatenated together into a single string (the new line separator character is represented by \n for display purposes only):
a2=r%20b\n a3=2%20q\n a3=a\n b5=%3D%253D\n c%40=\n c2=
TOC |
hmac-sha-1 uses the HMAC-SHA1 algorithm as defined in [RFC2104] (Krawczyk, H., Bellare, M., and R. Canetti, “HMAC: Keyed-Hashing for Message Authentication,” February 1997.):
digest = HMAC-SHA1 (key, text)
Where:
- text
- is set to the value of the normalize request string as described in Section 3.2.1 (Normalized Request String).
- key
- is set to the access token shared-secret provided by the authorization server.
- digest
- is used to set the value of the signature attribute, after the result octet string is base64-encoded per [RFC2045] (Freed, N. and N. Borenstein, “Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies,” November 1996.) section 6.8.
TOC |
hmac-sha-1 uses the HMAC algorithm as defined in [RFC2104] (Krawczyk, H., Bellare, M., and R. Canetti, “HMAC: Keyed-Hashing for Message Authentication,” February 1997.) together with the SHA-256 hash function defined in [NIST FIPS‑180‑3] (National Institute of Standards and Technology, “Secure Hash Standard (SHS). FIPS PUB 180-3, October 2008,” .):
digest = HMAC-SHA256 (key, text)
Where:
- text
- is set to the value of the normalize request string as described in Section 3.2.1 (Normalized Request String).
- key
- is set to the access token shared-secret provided by the authorization server.
- digest
- is used to set the value of the signature attribute, after the result octet string is base64-encoded per [RFC2045] (Freed, N. and N. Borenstein, “Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies,” November 1996.) section 6.8.
TOC |
A servers receiving an authenticated request validates it by performing the following REQUIRED steps:
If the request fails verification, the server SHOULD respond with an HTTP 401 (unauthorized) status code, and SHOULD include a token scheme authentication challenge using the WWW-Authenticate header field. The server MAY include further details about why the request was rejected using the error attribute.
TOC |
[[ TBD ]]
TOC |
As stated in [RFC2617] (Franks, J., Hallam-Baker, P., Hostetler, J., Lawrence, S., Leach, P., Luotonen, A., and L. Stewart, “HTTP Authentication: Basic and Digest Access Authentication,” June 1999.), the greatest sources of risks are usually found not in the core protocol itself but in policies and procedures surrounding its use. Implementers are strongly encouraged to assess how this protocol addresses their security requirements.
TOC |
This specification does not describe any mechanism for obtaining or transmitting access token secrets. Methods used to obtain tokens should ensure that these transmissions are protected using transport-layer mechanisms such as TLS or SSL.
TOC |
While this protocol provides a mechanism for verifying the integrity of requests, it provides no guarantee of request confidentiality. Unless further precautions are taken, eavesdroppers will have full access to request content. Servers should carefully consider the kinds of data likely to be sent as part of such requests, and should employ transport-layer security mechanisms to protect sensitive resources.
TOC |
This protocol makes no attempt to verify the authenticity of the resource server. A hostile party could take advantage of this by intercepting the client's requests and returning misleading or otherwise incorrect responses. Service providers should consider such attacks when developing services using this protocol, and should require transport-layer security for any requests where the authenticity of the resource server or of request responses is an issue.
TOC |
The access token shared-secret functions the same way passwords do in traditional authentication systems. In order to compute the signature, the server must have access to the secret in plaintext form. This is in contrast, for example, to modern operating systems, which store only a one-way hash of user credentials.
If an attacker were to gain access to these secrets - or worse, to the server's database of all such secrets - he or she would be able to perform any action on behalf of any resource owner. Accordingly, it is critical that servers protect these secrets from unauthorized access.
TOC |
Unless a transport-layer security protocol is used, eavesdroppers will have full access to authenticated requests and signatures, and will thus be able to mount offline brute-force attacks to recover the secret used. Authorization servers should be careful to assign shared-secrets which are long enough, and random enough, to resist such attacks for at least the length of time that the shared-secrets are valid.
For example, if shared-secrets are valid for two weeks, authorization servers should ensure that it is not possible to mount a brute force attack that recovers the shared-secret in less than two weeks. Of course, authorization servers are urged to err on the side of caution, and use the longest secrets reasonable.
It is equally important that the pseudo-random number generator (PRNG) used to generate these secrets be of sufficiently high quality. Many PRNG implementations generate number sequences that may appear to be random, but which nevertheless exhibit patterns or other weaknesses which make cryptanalysis or brute force attacks easier. Implementers should be careful to use cryptographically secure PRNGs to avoid these problems.
TOC |
This specification includes a number of features which may make resource exhaustion attacks against servers possible. For example, this protocol requires servers to track used nonces. If an attacker is able to use many nonces quickly, the resources required to track them may exhaust available capacity. And again, this protocol can require servers to perform potentially expensive computations in order to verify the signature on incoming requests. An attacker may exploit this to perform a denial of service attack by sending a large number of invalid requests to the server.
Resource Exhaustion attacks are by no means specific to this specification. However, implementers should be careful to consider the additional avenues of attack that this protocol exposes, and design their implementations accordingly. For example, entropy starvation typically results in either a complete denial of service while the system waits for new entropy or else in weak (easily guessable) secrets. When implementing this protocol, servers should consider which of these presents a more serious risk for their application and design accordingly.
TOC |
The normalized request string has been designed to support the authentication methods defined in this specification. Those designing additional methods, should evaluated the compatibility of the normalized request string with their security requirements. Since the normalized request string does not cover the entire HTTP request, servers should employ additional mechanisms to protect such elements.
TOC |
TOC |
- Parameter name:
- secret
- Parameter usage location:
- The end-user authorization endpoint response and the token endpoint response.
- Change controller:
- IETF
- Specification document(s):
- [[ this document ]]
- Related information:
- None
TOC |
- Parameter name:
- secret
- Parameter usage location:
- The end-user authorization endpoint response and the token endpoint response.
- Change controller:
- IETF
- Specification document(s):
- [[ this document ]]
- Related information:
- None
TOC |
The author would like to thank [[ some people ]] for their suggestions, feedback, and continued support.
TOC |
[[ To be removed by the RFC editor before publication as an RFC. ]]
-00
TOC |
TOC |
TOC |
[RFC5849] | Hammer-Lahav, E., “The OAuth 1.0 Protocol,” RFC 5849, April 2010 (TXT). |
TOC |
Eran Hammer-Lahav | |
Yahoo! | |
Email: | eran@hueniverse.com |
URI: | http://hueniverse.com |