Web Authorization Protocol D. Fett
Internet-Draft yes.com
Intended status: Standards Track J. Bradley
Expires: September 28, 2019 Yubico
B. Campbell
Ping Identity
T. Lodderstedt
yes.com
M. Jones
Microsoft
March 27, 2019

OAuth 2.0 Demonstration of Proof-of-Possession at the Application Layer
draft-fett-oauth-dpop-00

Abstract

This document defines a sender-constraint mechanism for OAuth 2.0 access tokens and refresh tokens utilizing an application-level proof-of-possession mechanism based on public/private key pairs.

Status of This Memo

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 https://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 September 28, 2019.

Copyright Notice

Copyright (c) 2019 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 (https://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.


Table of Contents

1. Introduction

[I-D.ietf-oauth-mtls] describes methods to bind (sender-constrain) access tokens using mutual Transport Layer Security (TLS) authentication with X.509 certificates.

[I-D.ietf-oauth-token-binding] provides mechanisms to sender-constrain access tokens using HTTP token binding.

Due to a sub-par user experience of TLS client authentication in user agents and a lack of support for HTTP token binding, neither mechanism can be used if an OAuth client is a Single Page Application (SPA) running in a web browser.

This document defines an application-level sender-constraint mechanism for OAuth 2.0 access tokens and refresh tokens that can be applied when neither mTLS nor OAuth Token Binding are utilized. It achieves proof-of-possession using a public/private key pair.

1.1. Conventions and Terminology

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

This specification uses the terms "access token", "refresh token", "authorization server", "resource server", "authorization endpoint", "authorization request", "authorization response", "token endpoint", "grant type", "access token request", "access token response", and "client" defined by The OAuth 2.0 Authorization Framework [RFC6749].

2. Main Objective

Under the attacker model defined in [I-D.ietf-oauth-security-topics], the mechanism defined by this specification tries to ensure token replay at a different endpoint is prevented.

More precisely, if an adversary is able to get hold of an access token because it set up a counterfeit authorization server or resource server, the adversary is not able to replay the respective access token at another authorization or resource server.

Secondary objectives are discussed in Section 10.

3. Concept

+--------+                               +---------------+
|        |                               |               | 
|        |--(A)- Authorization Request ->|   Resource    |
|        |                               |     Owner     |
|        |<-(B)-- Authorization Grant ---|               |
|        |                               +---------------+
|        |
|        |                               +---------------+
|        |--(C)-- Token Request -------->|               |
| Client |        (DPop-Binding)         | Authorization |
|        |                               |     Server    |
|        |<-(D)-- PoP Access Token ------|               |
|        |                               +---------------+
|        |        PoP Refresh Token for public clients
|        | 
|        |                               +---------------+
|        |--(E)-- PoP Access Token ----->|               |
|        |        (DPoP-Proof)           |    Resource   |
|        |                               |     Server    |
|        |<-(F)--- Protected Resource ---|               |
|        |                               +---------------+
|        |
|        | public client refresh token usage:
|        |                               +---------------+
|        |--(G)-- PoP Refresh Token ---->|               |
|        |        (DPoP-Proof)           | Authorization |
|        |                               |     Server    |
|        |<-(H)-- PoP Access Token ------|               |
|        |                               +---------------+
|        |
+--------+

Figure 1: Basic DPoP Flow

The new elements introduced by this specification are shown in Figure 1:

The mechanism presented herein is not a client authentication method. In fact, a primary use case are public clients (single page applications) that do not use client authentication. Nonetheless, DPoP is designed such that it is compatible with private_key_jwt and all other client authentication methods.

4. Token Request (Binding Tokens to a Public Key)

To bind an tokens to a public key in the token request, the client MUST provide a public key and prove the possession of the corresponding private key. The following HTTPS request illustrates the protocol for this (with extra line breaks for display purposes only):

POST /token HTTP/1.1
Host: server.example.com
Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
Content-Type: application/x-www-form-urlencoded;charset=UTF-8

grant_type=authorization_code
&code=SplxlOBeZQQYbYS6WxSbIA
&redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
&token_type=bearer+dpop
&dpop_binding=eyJhbGciOiJSU0ExXzUi ...
(remainder of JWK omitted for brevity)

Figure 2: Token Request for a DPoP bound token.

The parameter dpop_binding MUST contain a JWT signed using the asymmetric key chosen by the client. The header of the JWT contains the following fields:

The body of the JWT contains the following fields:

An example JWT is shown in Figure 3.

{
    "typ": "dpop_binding+jwt",
    "alg": "ES512",
    "jwk": {
         "kty" : "EC",
         "kid" : "11",
         "crv" : "P-256",
         "x" : "usWxHK2PmfnHKwXPS54m0kTcGJ90UiglWiGahtagnv8",
         "y" : "3BttVivg+lSreASjpkttcsz+1rb7btKLv8EX4"
     }

}.{
    "jti": "HK2PmfnHKwXP",
    "http_method": "get",
    "http_uri": "https://resource-server.example.com?path=something",
    "exp": "..."
}

Figure 3: Example JWT for dpop_binding parameter.

If the authorization server receives a dpop_binding parameter in a token request, the authorization server MUST check that:

If these checks are successful, the authorization server MUST associate the access token with the public key. It then sets token_type to bearer+dpop in the token response.

5. Resource Access (Proof of Possession for Access Tokens)

To make use of an access token that is token bound to a public key using DPoP, a client MUST prove the possession of the corresponding private key. More precisely, the client MUST create a JWT and sign it using the previously chosen private key.

The JWT has the same format as above, except:

The signed JWT MUST then be sent in the dpop_proof request parameter.

If a resource server detects that an access token that is to be used for resource access is bound to a public key using DPoP (via the methods described in Section 7) it MUST check that:

If any of these checks fails, the resource server MUST NOT grant access to the resource.

6. Refresh Token Usage (Proof of Possession for Refresh Tokens)

At the token endpoint, public clients MUST provide a proof of possession in the same way as for access tokens.

7. Public Key Confirmation

It MUST be ensured that resource servers can reliably identify whether a token is bound using DPoP and learn the public key to which the token is bound.

Access tokens that are represented as JSON Web Tokens (JWT)[RFC7519] MUST contain information about the DPoP public key (in JWK format) in the member dpop+jwk of the cnf claim, as shown in Figure 4.

{
    "iss": "https://server.example.com",
    "sub": "something@example.com",
    "exp": 1493726400,
    "nbf": 1493722800,
    "cnf":{
        "dpop+jwk": {
            "kty" : "EC",
            "kid" : "11",
            "crv" : "P-256",
            "x" : "usWxHK2PmfnHKwXPS54m0kTcGJ90UiglWiGahtagnv8",
            "y" : "3BttVivg+lSreASjpkttcsz+1rb7btKLv8EX4"
        }
    }
}

Figure 4: Example access token with cnf claim.

When access token introspection is used, the same cnf claim as above MUST be contained in the introspection response.

8. Acknowledgements

This document resulted from discussions at the 4th OAuth Security Workshop in Stuttgart, Germany. We thank the organizers of this workshop (Ralf Küsters, Guido Schmitz).

9. IANA Considerations

9.1. JWT Confirmation Methods Registration

This specification requests registration of the following value in the IANA "JWT Confirmation Methods" registry [IANA.JWT.Claims] for JWT "cnf" member values established by [RFC7800].

9.2. OAuth Parameters Registry

This specification registers the following parameters in the IANA "OAuth Parameters" registry defined in OAuth 2.0 [RFC6749].

9.3. JSON Web Signature and Encryption Type Values Registration

This specification registers the "dpop+jwt" type value in the IANA JSON Web Signature and Encryption Type Values registry [RFC7515]:

10. Security Considerations

The Prevention of Token Replay at a Different Endpoint is achieved through the binding of the DPoP JWT to a certain URI and HTTP method.

10.1. Token Replay at the same authorization server

If an adversary is able to get hold of an DPoP-Binding JWT, it might replay it at the authorization server's token endpoint with the same or different payload. The issued access token is useless as long as the adversary does not get hold of a valid DPoP-Binding JWT for the corresponding resource server.

10.2. Token Replay at the same resource server endpoint

If an adversary is able to get hold of a DPoP-Proof JWT, the adversary could replay that token later at the same endpoint (the HTTP endpoint and method are enforced via the respective claims in the JWTs). To prevent this, clients MUST limit the lifetime of the JWTs, preferably to a brief period. Furthermore, the jti claim in each JWT MUST contain a unique (incrementing or randomly chosen) value, as proposed in [RFC7253]. Resource servers SHOULD store values at least for the lifetime of the respective JWT and decline HTTP requests by clients if a jti value has been seen before.

10.3. Signed JWT Swapping

Servers accepting signed DPoP JWTs MUST check the typ field in the headers of the JWTs to ensure that adversaries cannot use JWTs created for other purposes in the DPoP headers.

10.4. Comparison to mTLS and OAuth Token Binding

11. References

11.1. Normative References

[RFC7253] Krovetz, T. and P. Rogaway, "The OCB Authenticated-Encryption Algorithm", RFC 7253, DOI 10.17487/RFC7253, May 2014.
[RFC7519] Jones, M., Bradley, J. and N. Sakimura, "JSON Web Token (JWT)", RFC 7519, DOI 10.17487/RFC7519, May 2015.

11.2. Informative References

[I-D.ietf-oauth-mtls] Campbell, B., Bradley, J., Sakimura, N. and T. Lodderstedt, "OAuth 2.0 Mutual TLS Client Authentication and Certificate-Bound Access Tokens", Internet-Draft draft-ietf-oauth-mtls-13, February 2019.
[I-D.ietf-oauth-security-topics] Lodderstedt, T., Bradley, J., Labunets, A. and D. Fett, "OAuth 2.0 Security Best Current Practice", Internet-Draft draft-ietf-oauth-security-topics-12, March 2019.
[I-D.ietf-oauth-token-binding] Jones, M., Campbell, B., Bradley, J. and W. Denniss, "OAuth 2.0 Token Binding", Internet-Draft draft-ietf-oauth-token-binding-08, October 2018.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997.
[RFC6749] Hardt, D., "The OAuth 2.0 Authorization Framework", RFC 6749, DOI 10.17487/RFC6749, October 2012.
[RFC7515] Jones, M., Bradley, J. and N. Sakimura, "JSON Web Signature (JWS)", RFC 7515, DOI 10.17487/RFC7515, May 2015.
[RFC7800] Jones, M., Bradley, J. and H. Tschofenig, "Proof-of-Possession Key Semantics for JSON Web Tokens (JWTs)", RFC 7800, DOI 10.17487/RFC7800, April 2016.
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017.

Appendix A. Document History

[[ To be removed from the final specification ]]

-00

Authors' Addresses

Daniel Fett yes.com EMail: mail@danielfett.de
John Bradley Yubico EMail: ve7jtb@ve7jtb.com
Brian Campbell Ping Identity EMail: bcampbell@pingidentity.com
Torsten Lodderstedt yes.com EMail: torsten@lodderstedt.net
Michael Jones Microsoft EMail: mbj@microsoft.com