Proof-of-Possession Tokens in Microservice Architectures
Proof-of-Possession Tokens in Microservice Architectures
Proof-of-Possession Tokens in Microservice Architectures
Architectures
Ruaridh Watt
Abstract
The popular OAuth 2.0 Framework specifies the use of Bearer Tokens
for the transmission of authorization credentials. A Bearer Token has
the property that any party in possession of it can use the it. Requests
including Bearer Tokens are therefore performed over a secure channel to
ensure that tokens cannot be obtained by eavesdroppers.
There are, however, still ways in which tokens may be leaked, in-
cluding cross-site scripting and man-in-the-middle attacks. In situations
where Bearer Tokens do not provide adequate security, proof-of-possession
techniques may be employed to bind tokens to clients, thereby mitigating
token leakage.
This project presents a method which can be used to bind tokens to
clients based on authentication performed by an external identity provider.
How clients form proof-of-possession tokens is also described. The result
is a token which may be used to transmit authorization credentials over
an insecure channel.
Token performance is measured in terms of client key generation time,
token generation time, and authorization time. The effect different signing
algorithms have on performance is measured and the proof-of-possession
token is compared to Bearer Token based authorization.
The results show that Elliptical Curve cryptography may be employed
by lightweight devices to reduce client key and token generation times.
The analysis also shows that an increase in authorization time by a factor
of between six and nine can be expected when compared to Bearer Token
based authorization.
1
Contents
1 Introduction 6
1.1 Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2 Project Goals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3 Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2 Background 8
2.1 Microservice Architecture . . . . . . . . . . . . . . . . . . . . . . 8
2.2 OAuth 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 OpenID Connect . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4 Token Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4.1 JSON Web Token . . . . . . . . . . . . . . . . . . . . . . 10
2.4.2 JWT Confirmation Claim . . . . . . . . . . . . . . . . . . 12
3 Related Work 14
3.1 SAML Holder of Key Assertion Profile . . . . . . . . . . . . . . . 14
3.2 Kerberos Tickets . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.3 Client Bound JWTs . . . . . . . . . . . . . . . . . . . . . . . . . 15
4 Method 16
4.1 System Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.1.1 Key Event . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2 Token Specifications . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2.1 Access Token . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2.2 PoP Token . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.3 Sign-in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.3.1 Authentication Request . . . . . . . . . . . . . . . . . . . 23
4.3.2 Authentication and Authorization . . . . . . . . . . . . . 23
4.3.3 Authorization Code Response . . . . . . . . . . . . . . . . 23
4.3.4 Access Token Request . . . . . . . . . . . . . . . . . . . . 25
4.3.5 ID Token Request . . . . . . . . . . . . . . . . . . . . . . 25
4.3.6 ID Token Response . . . . . . . . . . . . . . . . . . . . . . 26
4.3.7 Access Token Response . . . . . . . . . . . . . . . . . . . 28
4.4 Service Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.5 Authorization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.5.1 Parsing the Authorization Header . . . . . . . . . . . . . 30
4.5.2 Access Token Verification . . . . . . . . . . . . . . . . . . 30
4.5.3 Access Token Validation . . . . . . . . . . . . . . . . . . . 31
4.5.4 PoP Token Verification . . . . . . . . . . . . . . . . . . . 31
4.5.5 PoP Token Validation . . . . . . . . . . . . . . . . . . . . 31
4.5.6 Access Control . . . . . . . . . . . . . . . . . . . . . . . . 31
5 Implementation 32
6 Analysis 33
6.1 PoP Key Generation . . . . . . . . . . . . . . . . . . . . . . . . . 33
6.2 PoP Token Generation . . . . . . . . . . . . . . . . . . . . . . . . 35
6.3 Authorization Time . . . . . . . . . . . . . . . . . . . . . . . . . 37
7 Discussion 38
2
7.1 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
8 Conclusion 40
Appendices 44
A Testing Platform 44
3
Abbreviations
4
A data string used to authenticate a message. Computed and
verified using a single shared secret key. MACs guard against
message modification and serve as proof-of-possession of the secret
key.
MITM Man-in-the-middle
An attack in which communication between two systems is inter-
cepted. The attacker acts as a proxy and is able to read, insert
and modify communications.
PoP Proof-of-possession
Verifiable proof that an entity is privy to a secret that does not
disclose the secret itself.
5
1. INTRODUCTION
1 Introduction
The microservice architecture has emerged as a set of common software devel-
opment practices employed by a number of leading organizations. By focus-
ing on system reliability, scalability, replaceability and reducing the time-to-
market of new releases, a number of large systems have evolved into microser-
vices [28].
Systems based on a microservice architecture commonly expose functionality to
front-end applications through an API [35]. Securing an API involves binding
authorization credentials to requests. How and if a request is processed depends
on the authorization credentials included in the request.
Front-end applications typically obtain a user’s authorization credentials as a
result of the user signing in. By signing in, the user effectively delegates access
to the front-end application. Before authorization credentials are transferred to
the front-end application, the user must first be authenticated.
A system may choose to perform user authentication itself, however, due to the
risks involved in storing user credentials and the work involved in implement-
ing sign-up, sign-in, and password recovery, many applications are choosing to
outsource user management to external identity providers [27]. Many popular
online services can also act as identity providers, including Google, Facebook,
Twitter, Github and many more [2].
When a user signs in, the front-end application may be issued with a key or
token which enables resource servers to obtain the user’s authorization creden-
tials. Keys enable resource servers to look up authorization credentials whereas
tokens contain the authorization credentials themselves. Tokens prove to be
particularly suitable in microservice architectures as they enable services to act
autonomously: an authorization decision can be made without the need to fetch
authorization credentials.
The OAuth 2.0 Framework [15] is billed as “the industry-standard protocol for
authorization” [31]. In OAuth 2.0, authorization credentials are transmitted as
Access Tokens which are defined in the framework as “a string representing an
access authorization issued to the client” [15]. At the time of writing, there is
only one registered type of Access Token that may be returned in the OAuth
2.0 Framework: the Bearer Token [32].
Bearer Tokens are defined in the framework as
“A security token with the property that any party in possession
of the token (a “bearer”) can use the token in any way that any
other party in possession of it can. Using a bearer token does not
require a bearer to prove possession of cryptographic key material
(proof-of-possession)” [22].
Bearer Tokens are very convenient from a usage stand point: requests may be
authorized by simply including the token in the request. The drawback is that
Bearer Tokens must be kept secret as they can be used by anyone in possession
of them to gain access to protected resources.
6
1. INTRODUCTION
There are two problems addressed in this project. The first involves the use of
an identity provider. There are a number of different ways in which an OpenID
Connect compliant identity provider may be used [20]. Proper identity provider
usage is essential to the overall security of a system.
The second problem involves the vulnerabilities associated with Bearer Tokens.
Bearer token security relies on a secure channel to provide protection from token
disclosure, however there are still a number of ways in which bearer tokens may
be leaked, including cross-site scripting (XSS) and man-in-the-middle attacks
(MITM) [5, 7].
The project goals attempt to address the problems stated above by specify-
ing appropriate identity provider usage and an Access Token type that guards
against token leakage. In order to analyze the feasibility of the proposals in a
microservice environment an implementation and testing phase is also required.
The goals can be summarized as follows:
1. Define an Access Token type which guards against token leakage and pro-
tects against request modification and replay through proof-of-possession.
2. Specify a protocol which can be used to issue Access Tokens to front-end
applications based on authentication performed by an OpenID Connect
compliant identity provider.
3. Evaluate the feasibility of the proposals through implementation and per-
formance testing.
1.3 Structure
7
2. BACKGROUND
2 Background
As this project is concerned with securing microservices, using a method built
upon the OAuth 2.0 framework, an introduction to these areas is provided.
OpenID Connect, a widely used OAuth 2.0 extension, is also introduced as it is
used in interactions with the identity provider. Finally, an introduction to the
token format which will be used in this project is given.
Prior to 2006 it was common for third-party applications to request the user’s
authentication credentials for a service to enable delegated access [35]. For ex-
ample, a printing service would require a user to submit their username and
password for a photo hosting service in order to allow them access to their pho-
tos. This method of access delegation does not enable users to limit access; the
printing service is able to perform all the operations of the account owner.
OAuth 2.0, billed as “the industry-standard protocol for authorization” [31],
effectively decouples authentication and authorization. This enables users to
grant third-party applications limited access to services on their behalf without
disclosing their authentication credentials to the third-party.
The OAuth 2.0 framework describes a system comprising of a Resource Owner,
Client, Authorization Server, and Resource Server as described in Table 2.
8
2. BACKGROUND
Authorization
Web-browser Client
Server
Authorization Request
Authorization Request
Authorization Grant
Authorization Grant
9
2. BACKGROUND
Refresh Tokens can be used by Clients to obtain a new Access Token from
the Authorization Server. If an Access Token includes an expiry time, Clients
may use a Refresh Token to prolong their access to protected resources without
requiring re-authentication of the Resource Owner.
OpenID Connect extends the OAuth 2.0 framework to include an identity layer.
The capabilities of the Authorization Server are extended to enable the issuing of
Identity Tokens. Identity Tokens enable Clients to obtain and verify identity and
profile information of the end-user. These may be used to verify authentication
performed by an identity provider.
OpenID Connect also adds a Hybrid Flow and extended grant types. This
enables Authorization Servers to issue an Authorization Code for server-side
applications and tokens for front-end application simultaneously.
Tokens are used to securely transmit information between parties. The infor-
mation is protected from modification by a digital signature, message authenti-
cation code, or encryption. The integrity and origin of the information can be
verified using a key obtained from the issuer.
There are many token formats in use today. Many organizations use a propri-
etary format developed to meet their specific requirements. There are, however,
also a number of public standards which may be used.
Two widely used and well documented standard token formats are the Security
Assertion Markup Language (SAML) [30] and JSON Web Tokens [3]. SAML
is an XML-based markup language while JSON Web Tokens use JavaScript
Object Notation (JSON).
XML is a powerful language which incorporates validation, query and transfor-
mation capabilities, however, when it comes to the transmission of immutable
information between parties, the lightweight JSON data format, together with
the compact, url-safe JSON Web Token standard proves to be particularly suited
to the OAuth 2.0 framework. Formatting tokens using JSON also fits in with
the growing trend of APIs using only JSON as the data format for requests and
responses [35].
A JSON Web Token (JWT) is a compact, url safe means of transmitting claims
between two parties. The claims are contained in a JSON object which consti-
tutes the token payload.
The payload typically contains claims pertaining to the subject, issuer, audience
and token expiration. Such claims are registered with the Internet Assigned
10
2. BACKGROUND
Numbers Authority (IANA) and have well defined semantics, however imple-
mentation specific claims may also be included. The full list of registered claims
can be viewed in the IANA registry [19].
JWTs can be protected by a digital signature (asymmetric cryptography) or
message authentication code (symmetric cryptography). This enables the in-
tegrity and origin of the claims to be verified. Message authentication codes are
computed and verified using a single shared secret key. Digital signatures are
computed using a private key and verified using the corresponding public key.
Using digital signatures enables the separation of JWT issuing and verification
capabilities, avoids the problem of securely distributing shared secrets, and en-
ables JWT verification to be performed by untrusted clients. This project will
therefore only consider signed JWTs.
A signed JWT consists of a header, payload and signature in the following
format:
<header>.<payload>.<signature>
Algorithm Description
11
2. BACKGROUND
Algorithm 1.
12
2. BACKGROUND
{
"sub": "123456789",
"cnf": {
"jwk": {
"alg": "EC256",
"crv": "P-256",
"kty": "EC",
"use": "sig",
"x": "18wHLeIgW9wVN6VD1Txgpqy2LszYkMf6J8njVAibvhM",
"y": "-V4dS4UaLMgP_4fY4j8ir7cl1TXlFdAgcx55o7TkcSA"
}
}
}
13
3. RELATED WORK
3 Related Work
The concept of proof-of-possession is not itself a new idea, in fact, a response
digest is used in HTTP Digest Authentication [12] to prove possession of the
user’s password without the need to transmit the password itself over the wire.
In this challenge-response protocol the MD5 hash function is typically used to
distill security and message related data into a response which can be verified
by the challenging server, providing it also has some knowledge of the user’s
password.
SAML includes a Holder-of-Key Assertion Profile [29]. This specifies how a to-
ken issuer can embed X.509 data from an X.509 certificate held by the attesting
entity. The attesting entity submits the assertion and X.509 certificate along
with proof-of-possession of the corresponding private key. This allows the rely-
ing party to confirm the attesting entity. The details of how the attesting entity
proves possession of the private key is, however, not specified.
This is very similar to the JWK confirmation method for JWTs and may well
have been the inspiration behind this confirmation method.
The Client deciphers Kses and uses it to encrypt an authenticator. The ticket
and authenticator are then sent to the service:
The service attempts to decipher the ticket, Tsrv . If successful, the ticket was
created by the AS for this service and contains the ID and session key of the
14
3. RELATED WORK
user to which the ticket was issued. The service can then attempt to decipher
the authenticator using the session key from the ticket. If successful, the Client
has proven possession of the session key and it can be concluded that the ticket
was issued to the Client.
Kerberos as a whole is, of course, slightly more complicated than this. The
tickets contain values used to seed encryption and detect replay attacks. The
system also specifies a Ticket Granting Service (TGS) which enables reduced
transmission of data encrypted with a user’s secret key. Users first request a
Ticket Granting Ticket (TGT) from the AS for use with the TGS. A session
key is then used for further ticket requests aimed at the TGS.
Kerberos requires each service to have an associated symmetric key which are all
stored on a central authentication server. The addition of services and the repli-
cation of the authentication server involves the distribution of shared secrets.
This makes it unsuitable in dynamic environments where services may not be
capable of establishing a secure connection to an authentication server.
There are two IETF drafts which outline methods to bind JWTs to Clients. The
first draft, entitled OAuth 2.0 Message Authentication Code (MAC) Tokens [11],
outlines an OAuth 2.0 token type extension: the MAC token. This token type
requires the client to provide proof-of-possession of a shared symmetric key by
computing a keyed message digest of a flexible set of parameters from the HTTP
message. How the key is distributed to the client and resource servers is also
outlined. This draft was last updated January 15, 2014 and has subsequently
expired. Even though several questions remain in the draft, mac tokens have
seen some limited use [35].
The second, much more recent draft is entitled OAuth 2.0 Proof-of-Possession
(PoP) Security Architecture. Here an architecture is put forward in which a
trusted third party binds symmetric or asymmetric client key information to the
tokens issued. The draft refers, in turn, to Proof-of-Possession Key Semantics for
JSON Web Tokens [18] as an example of how key information can be bound to a
token and A Method for Signing HTTP Requests for OAuth [9] as an example of
how clients can use a JWT structure to sign the token and, optionally, parts of
the request. This draft is the closest relative to the proof-of-possession method
presented in this project.
The latest work being done on token binding involves binding tokens to connec-
tions secured using Transport Layer Security (TLS) [10]. While this method is
promising, additional challenges are posed by TLS Terminating Reverse Prox-
ies [6] and non-TLS protected resources. For these reasons, and to keep trans-
port layer and application layer security decoupled this project will only deal
with purely application layer token binding techniques.
15
4. METHOD
4 Method
The method used to achieve the project goals is given in this section. It com-
prises of a system design, token specification and protocol. These are used
to issue Client bound Access Tokens based on authentication performed by an
external OpenID Connect Provider. Clients are required to include their Ac-
cess Token and proof-of-possession with each request. To achieve this, Clients
compose a signed JWT containing the Access Token and data derived from the
request. This is referred to as a PoP Token.
In the proposed system, authorization of requests is performed independently
by individual service instances. Requests are only met if:
• The Access Token was issued by a trusted issuer.
• The Access Token has not expired.
• The Access Token contains sufficient privileges.
• The request originated from the Client to which the Access Token was
issued.
• The request has not expired.
• The request has not been modified.
• The request has not been previously met.
In contrast to Bearer Tokens, disclosure of the tokens described here poses no
threat. In addition, requests which include a PoP Token are protected from
modification and replay even in the absence of TLS.
16
4. METHOD
Message Broker
TokenService
Token Service KeySet
Key Set Service22
Service
Token Service Key Set Service 2
OpenID Connect
Client
Provider
A Key Event is published by a Token Service whenever its key set changes.
A single Token Service instance may be capable of multiple different signing
algorithms. A Key Event may therefore contain multiple public keys. Each
key must be assigned an ID so that services can identify the key to use when
verifying an Access Token signature.
Each Key Event also contains the key set’s expiry time as a Numeric Date [3,
Section 2]. The expiry time is the time at which the Token Service will next
rotate its keys plus the number of seconds its Access Tokens are valid for. For
example, if a Token Service is spawned with a key rotation period of 30 days,
and issues access tokens which are valid for 24 hours, the key set’s expiry time
would be set to the current Numeric Date plus the number of seconds in 31
days. An example Key Event, in JSON, is shown in Listing 2.
There are three token types used in the system: ID Tokens, Access Tokens and
PoP Tokens, all of which are signed JWTs.
The claims used in ID Tokens are as specified in the OpenID Connect [20, Section
2]. Access and PoP Token claims are defined in the following two sections.
Access Token claims are specified in Table 4 and an example Access Token
payload is shown in Listing 3.
17
4. METHOD
{
"keys":[
{
"alg":"ES256",
"crv":"P-256",
"kid":"nhBNz5xpracw-9Ad2wTO-MEtYcvSgQWpoOVyCrH9GMA",
"kty":"EC",
"use":"sig",
"x":"xZH7Gg9PF61IO0_k4waYROzLZh9xObfqX-AmrjuWtjc",
"y":"A6VQajFrcWjRQTepMH6jAtf-hta9EWFEvAnKGmsH-us"
},
{
"alg":"RS256",
"e":"AQAB",
"kid":"Axv407h0AL4chPT857s96kSK5rkcGMRXSq0N0pZmKf4",
"kty":"RSA",
"n":"xLOiMFbUpgJlmwdDyc_T12tzEKqbLqLrmrM3IiG0fUaiQS...",
"use":"sig"
}
],
"exp": 1513091734
}
Claim Description
18
4. METHOD
{
"aud":"api.rwatt.se",
"sub":"auth0|59b7c7d1cbb73b1e63a1aea5",
"iss":"oauth.rwatt.se",
"cnf":{
"jwk":{
"kty":"EC",
"use":"sig",
"crv":"P-256",
"x":"nVRAdyxyZUKmH-i_GTtmUxs_HjDtaAJ0lQEKKHKFmT8",
"y":"KSoOKOtfAYsulfFS__dmPnNbByG0nS8N-iGZECXtpeA",
"alg":"ES256"
}
},
"exp":1513177303
}
Additional claims may be included in the Access Token, for example, roles
and/or groups may be used to grant additional privileges to specific users. Some
OpenID Connect Providers support the customization of specific users’ ID To-
kens. In this case additional privileges may be copied from the ID Token.
The Access Token header must include a kid claim specifying the ID of the key
used to sign the token. This enables services to identify the key to use when
verifying the token signature.
PoP Token claims are specified in Table 5 and an example PoP Token shown in
Listing 4.
Claim Description
19
4. METHOD
{
"jti":"3e6569ede9f6c585",
"at":"eyJraWQiOiJBeHY0MDdoMEFMNGNoUFQ4NTdzOTZrU0s1cmtjR01...",
"exp":1513091734,
"m":"POST",
"u":"http://rwatt.se/flashcards",
"b":"pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4"
}
PoP tokens are signed JWTs containing the Client’s Access Token and request
specific claims.
The Client’s signature provides proof-of-possession of the private key and pro-
tects the integrity of the token payload. By including request specific informa-
tion in the token payload, services are able to verify that the request itself has
not been modified.
The S256 digest of the request body is used to protect its integrity. This process
is shown in Figure 3. The S256 definition used in this project is an extension of
the S256 method used in Proof Key For Code Exchange [33].
A token identifier is also included to enable services to provide replay protection
and the token is assigned an expiry time.
A PoP Token should not have to be valid for longer than 300 seconds. This
provides enough time for the token to be processed (and allow for some clock
skew) whilst minimizing the time a service must cache the token identifier in
order to provide replay protection.
20
4. METHOD
{
"name":"Jane Doe",
"email":"j.doe@rwatt.se"
}
Canonicalize
{"email":"j.doe@rwatt.se","name":"Jane Doe"}
7B 22 65 6D 61 69 6C 22 3A 22 6A 2E 64 6F 65 40
72 77 61 74 74 2E 73 65 22 2C 22 6E 61 6D 65 22
3A 22 4A 61 6E 65 20 44 6F 65 22 7D
SHA-256 Hash
5F 85 7E A3 61 49 1F 8D 5E 63 C9 3B A0 C9 11 12
A9 63 B4 F6 5C 0B 65 F1 7D 15 74 5F E5 D5 1D 71
Base64URL Encode
X4V-o2FJH41eY8k7oMkREqljtPZcC2XxfRV0X-XVHXE
21
4. METHOD
4.3 Sign-in
OpenID Connect
Web-browser Client Token Service
Provider
Authentication Request
Authentication Request
ID Token Request
ID Token Response
The Sign-in protocol begins with the Client issuing a request for the end-user
to be authenticated by the OpenID Connect Provider. An Authorization Code
is issued to the Client after successful authentication of the end-user.
This part of the protocol conforms to the OpenID Connect Authorization Code
Flow [20, Section 3.1] with a Proof Key For Code Exchange [33] and is described
in Sections 4.3.1 to 4.3.3.
Typical OpenID Connect usage would see the Client exchange the Authorization
Code for an ID Token. However, here, the code is submitted to the Token
Service along with the Client’s public key. Once the Token Service exchanges
the Authorization Code for an ID Token it holds the identity of the end-user
and the Client’s public key. The Token Service can then return an Access Token
to the Client. The protocol specification for this is defined in Sections 4.3.4
to 4.3.7.
22
4. METHOD
GET /login?
scope=openid%20profile%20email&
response_type=code&
response_mode=fragment&
client_id=1234&
redirect_uri=https://myapp.com/callback&
state=0865b13789843ca7&
code_challenge_method=S256&
code_challenge=ubw8EKBNT-RSf52eK4ZGx9ubJJta13XuJhmIhZW4Zy4&
prompt=login HTTP/1.1
Host: www.openidconnectprovider.com
The OpenID Connect Provider authenticates the end-user and asks the user for
authorization. Authorization in this setting involves the end-user giving consent
to the Token Service to access their identity information. The details of this
stage depend on the OpenID Connect Provider used.
23
4. METHOD
24
4. METHOD
the state parameter returned matches the state supplied in the Authentication
Request. This guards against CSRF attacks on the redirection endpoint [5,
Chapter 9]. If the state parameter is missing, or differs from the stored state
value, the Client discards the parameters contained in the URI fragment. An
example Authorization Code Response is shown in Listing 6.
{
"code":"nKtx8RD5OEwEoNUr",
"codeVerifier":"yHbNpe4BJECdbEXTnZMpjJGVWpNNIwTZ8F84Xi9zofR8o7 c
,→ C78BbCRtJNzG39hD3G",
"redirectUri":"https://myapp.com/callback",
"jwk":{
"alg":"ES256",
"crv":"P-256",
"kty":"EC",
"use":"sig",
"x":"jPqAr07df4ur2YM6lPlR5slfHU3OIB4nA-IsFv-Fd3E",
"y":"P07ILlrKW2B3H3xaH840Oz4adEFRzmAHc6TUvR8nluM"
}
}
Upon receiving an Access Token Request, the Token Service uses the Autho-
rization Code and code-verifier to form an ID Token Request. The parameters
25
4. METHOD
code=nKtx8RD5OEwEoNUr&
code_verifier=yHbNpe4BJECdbEXTnZMpjJGVWpNNIwTZ8F84Xi9zofR8o7cC78B c
,→ bCRtJNzG39hD3G&
redirect_uri=http://myapp.com/callback&
client_id=XpBM6P1QpOv0qdM0ngfp4fedsrbo2g50&
client_secret=TtLHEgDjGiWlxrVTOzZX8-b1Tspr6X8oRO7Vlp05em3-qcHvzwA c
,→ zfEa2Iyp_ov6Z&
grant_type=authorization_code
The exact format and content of the ID Token response depends on the OpenID
Connect Provider. Other tokens may well be included in the response, however,
since the OpenID Connect Provider is only being used as an identity provider,
everything but the ID Token may be discarded.
A typical ID Token Response is shown in Listing 9.
An example of how the ID Token payload may look after decoding is shown in
Listing 10.
26
4. METHOD
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
Pragma: no-cache
{
"access_token": "tor7f4e1zGlzDRC9sD2t5EBmROeOnL01",
"expires_in": 86400,
"id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"token_type": "Bearer"
}
{
"iss":"https://dv12rwt.eu.auth0.com/",
"sub":"auth0|59b7c7d1cbb73b1e63a1aea5",
"aud":"XpBM6P1QqOv0qdM0ngmp4fedsrbo2g50",
"exp":1513295493,
"email":"u1@rwatt.se",
"email_verified":true,
"nickname":"u1",
"name":"Joe Bloggs",
"amr":[
"mfa"
]
}
27
4. METHOD
Once the Token Service has received an ID Token it can generate an Access
Token. The Access Token contains Identity information from the ID Token and
the Client’s public key as specified in Section 4.2.1.
The Access Token Response is a JSON object containing the Access Token, the
token type identifier, and the length of time, in seconds, the Access Token is
valid for. The token type identifier used is PoP. The ID Token may also be
included to enable Clients to customize the user interface.
An example Access Token Response is shown in Listing 11.
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
Pragma: no-cache
{
"access_token":"eyJraWQiOiJ2dXhZLUpoMmI3VVN...",
"token_type":"PoP",
"expires_in":86400,
"id_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI..."
}
This concludes the Sign-in process. The Client is now able to generate PoP
Tokens and include them in service requests.
28
4. METHOD
{
"name":"Jane Doe",
"email":"j.doe@rwatt.se"
}
The S256 digest of the request body must be included in the PoP Token. If the
body content is a JSON object it is recommended that the object be serialized
using a canonical form prior to hashing. An example of this is shown in the
PoP Token specification (Section 4.2.2). This enables repeatable hashing of the
object, allowing for service implementations which deserialize the request prior
to authorization.
The resulting PoP Token payload is shown in Listing 13.
{
"jti":"3e6569ede9f6c585",
"at":"eyJraWQiOiJBeHY0MDdoMEFMNGNoUFQ4NTdzOTZrU0s1cmtjR01...",
"exp":1513091734,
"m":"POST",
"u":"http://addressbook.com/contacts",
"b":"X4V-o2FJH41eY8k7oMkREqljtPZcC2XxfRV0X-XVHXE"
}
Listing 13: The PoP Token Payload for the reqest in Listing 12
The PoP Token is then signed by the Client and included in the Authoriza-
tion header. The authorization type used is PoP. The final request is shown in
Listing 14.
29
4. METHOD
{
"name":"Jane Doe",
"email":"j.doe@rwatt.se"
}
Listing 14: The request with PoP Token included in the Authorization header
4.5 Authorization
Each request received by a service must pass authorization before being pro-
cessed. Authorization involves the following sequence of procedures:
1. Parsing the Authorization Header
2. Access Token Verification
3. Access Token Validation
4. PoP Token Verification
5. PoP Token Validation
6. Access Control
There are libraries in a number of different programming languages that can be
used to aid this process [3]. A general description of each procedure follows.
Failure of any of the steps result in the request not being processed and an
HTTP 403 Forbidden status being returned.
1. Get the key ID from the Access Token header (kid claim)
2. Check that the issuer claim specifies a trusted issuer (iss claim).
30
4. METHOD
3. Get the corresponding public JWK from the Key Set or the local cache of
active public JWKs.
4. Check that the algorithm claim in the Access Token header is the same as
the algorithm specified in the public JWK [8] (alg claim).
5. Verify the Access Token Signature using the public JWK.
1. Check that the Access Token has not expired (exp claim).
2. Check that the token is intended for use with this service (aud claim).
3. Check that the confirmation method is jwk (cnf claim).
4. Check that the JWK in the confirmation method specifies a single valid
public JWK.
1. Extract the JWK from the Access Token’s confirmation claim (cnf claim).
2. Check that the algorithm claim in the PoP Token header is the same as
the algorithm specified in the JWK (alg claim).
3. Verify the PoP Token signature.
1. Check that the PoP Token has not expired (exp claim).
2. Check that the request method is the same as the method claim (m claim).
3. Check that the request url is the same as the url claim (u claim).
4. Check that the S256 digest of the request body is the same as the body
digest claim (b claim).
5. Extract the subject ID from the Access Token (sub claim).
6. Add the token identifier to the subject’s token cache until the token ex-
pires, failing if the cache already contains this identifier (jti claim).
The service can then use the subject identifier and any additional claims included
in the Access Token to check that the user issuing the request possesses adequate
privileges. This may be as simple as checking that the subject is the owner
of the resource, or may involve checking roles, groups or other Access Token
claims. The exact method used in Access Control is left as an implementation
detail.
31
5. IMPLEMENTATION
5 Implementation
The method presented in Section 4 was implemented as a proof-of-concept and
to judge the feasibility of PoP Token based authorization.
An example Client was implemented as an Angular 5 application [1] for use
with the back-end microservices implemented using the Lagom microservices
framework [25]. The implementation used Auth0 [34] as the OpenID Connect
Provider.
Table 8 provides some further information on the modules and libraries used in
testing.
Project Description
32
6. ANALYSIS
6 Analysis
The additional protection provided by PoP Tokens comes at a cost. Bearer
Token usage, from a Client’s perspective, is as simple as including the Access
Token in the Authorization header. PoP Token usage requires Clients to gen-
erate a key pair when a user signs in and generate a new PoP Token for each
request.
PoP Token usage also requires extra work to be done when authorizing requests.
Instead of just verifying and validating an Access Token, as is the case for Bearer
Tokens, PoP Token authorization involves an additional signature verification
and validation involves computing the S256 digest of the request body.
The implementation was used to quantify the cost of Client key generation, PoP
Token generation and PoP Token based authorization for the signing algorithms
specified in Section 2.4.1. The results are used to provide a performance com-
parison between PoP Tokens and Bearer Tokens and draw conclusions about the
feasibility of PoP Token based authorization in production environments.
The Client application was tested using a Mobile and a Desktop platform. The
microservices were run on a single server. The platform specifications are shown
in Appendix A.
The log-transformation [26] was used to yield a symmetrical distribution from
the positively skewed computation times. Average times refer to the geometric
mean and the reported confidence intervals assume the data follows a log-normal
distribution. Tables and graphs are presented in the original scale.
33
6. ANALYSIS
Table 9: Average Key Generation Times with 95% confidence interval for Mobile
and Desktop
RSA 1024
RSA 2048
Key Type
EC secp256r1
EC secp384r1
34
6. ANALYSIS
RSA 1024
RSA 2048
Key Type
EC secp256r1
EC secp384r1
The choice of Client key type must also take into consideration the time it takes
to generate PoP Tokens.
Each time the Client issues a request it must generate a PoP Token. The time
this takes adds to the response time experienced by the end-user. Average PoP
Token generation times for a 1kB request are shown in Table 10 and Figures 7
and 8.
Table 10: Average PoP Token Generation Times with 95% confidence interval
for Mobile and Desktop
The results show that similar PoP Token generation times can be expected for
the RSA based algorithms. The longest generation times were experienced when
35
6. ANALYSIS
using the ES384 algorithm. However, significantly lower generation times were
achieved using the ES256 algorithm, even in the Mobile browser. This makes it
a good choice of algorithm from the Client’s perspective. The following section
will look at the effect the signing algorithm has on authorization times.
RS256
Signing Algorithm
RS384
RS512
ES256
ES384
Figure 7: Average PoP Token generation times for selected signing algorithms
on Mobile
RS256
Signing Algorithm
RS384
RS512
ES256
ES384
0 5 10 15 20 25 30 35 40 45
Time (ms)
Figure 8: Average PoP Token generation times for selected signing algorithms
on Desktop
36
6. ANALYSIS
The time it takes services to perform authorization is divided into two sub tasks:
Access Token validation and PoP Token validation. Here validation refers to
token verification and validation as described in Section 4.5.
Bearer Token based authorization times correspond to the Access Token vali-
dation time. PoP Token based authorization times correspond to the sum of
the Access Token validation and PoP Token validation times. The results are
shown in Figure 9.
RS256
RS384
SigningAlgorithm
RS512
ES256
ES384
Figure 9: Average PoP and Access Token validation times for selected signing
algorithms
When an RSA based signing algorithm is used, the overhead Access Token
validation has on request processing is extremely low (less than 1ms). This
makes RSA based algorithms the best choice for signing Access Tokens.
Clients choosing ES256 over an RSA based algorithm to minimize PoP Token
generation times will see an increase in authorization time of about 74% (from
4.11 to 7.14ms in the implementation tested). The advantages for the Client
more than outweigh the server-side cost. This means that the EC256 algorithm
represents a good choice for PoP Token signing.
Table 11 shows the average times observed for Bearer Token and PoP Token
based authorization. PoP token validation proves to be a significant overhead
in request authorization. Authorization times are increased by a factor of be-
tween 6 and 9 times compared to Bearer Tokens signed with an RSA based
algorithm.
37
7. DISCUSSION
Table 11: Average PoP and Access Token validation times with 95% confidence
interval
7 Discussion
The primary aim of this project was to address the security issues associated
with Bearer Tokens through proof-of-possession. This was done by binding
Access Tokens to Clients by including their public key and specifying a method
Clients can use to prove possession of the corresponding private key.
The advantages of token based authorization; the ability to make an authoriza-
tion decision without the need to fetch authorization credentials, is preserved.
This is essential for authorization performed by loosely coupled microservices.
Services can independently perform token verification, validation and access
control. In addition a scalable Token Service is described which can be used to
issue Access Tokens.
The increased security PoP Tokens provide can easily be compromised by the
protocol used to issue tokens. To address this problem a protocol which uses
an external OpenID Connect compliant identity provider is also specified. This
can be used to issue any custom Access Token type to any type of Client (native
or web-based). This drastically reduces the choices developers must make when
using OpenID Connect, reducing the risk of introducing security vulnerabilities
through improper OpenID Connect usage.
The final aim of the project was to judge the feasibility of PoP Tokens. To aid
this evaluation some basic performance metrics were gathered from a test imple-
mentation. However, the feasibility of the token type does not only depend on
weighing up the security increase versus performance decrease. The complexity
of Client implementations must also be considered.
The performance metrics gathered from the test implementation gave some use-
ful data, however it would be interesting to see how authorization times would
be affected by varying the PoP Token content. Protection against token leakage
38
7. DISCUSSION
can be achieved without protecting the request itself. This would simplify client
implementation and speed up authorization times.
Authorization times may also decrease significantly if services did not protect
against replay attacks as this involves database access. The cost of this operation
may also be explored.
The Client application developed for testing was run in a web-browser. A native
mobile application may perform significantly better and would provide further
data on which to judge the feasibility of PoP Tokens.
The increased authorization times may also leave services more susceptible to
denial of service attacks with carefully selected invalid token formats. This
should not differ from Bearer Token usage as the Access Token is verified first,
however further exploration of this risk warrant further work.
On a related subject, it would be desirable for the system to include token
revocation capabilities. Further work in this area is also required.
39
8. CONCLUSION
8 Conclusion
The analysis shows that Elliptical Curve cryptography may be employed by
lightweight devices to reduce Client key and token generation times. This comes
at the cost of increased authorization times, however the advantages for Client
applications outweigh the costs. From the end-user’s perspective PoP Tokens
seem viable; the effect on response times is acceptable.
PoP Tokens effectively address the security issues related to Bearer Tokens.
Requests can be performed over an insecure channel and are protected against
modification and replay. Moreover, PoP Token based authorization can be per-
formed independently, maintaining loose service coupling and scalability. PoP
Tokens also present a viable solution in this respect.
Requiring Clients to generate a PoP Token for every request is very different
to requiring the simple inclusion of a Bearer Token. The development of Client
applications becomes significantly more difficult, especially in the absence of
libraries for various platforms to aid PoP Token generation. An accepted PoP
Token standard would allow for the development of Client libraries.
The largest obstacle standing in the way of application level proof-of-possession
is undoubtedly the increased Client complexity. Current work on binding to-
kens to TLS connections could provide protection against token leakage without
adding complexity to Client applications. However, such techniques rely on the
security of the TLS connection and cannot be used in the absence of TLS. For
these reasons there are still situations which may require application level proof-
of-possession. In this case the methods described here present a viable option
for increased security in a microservice environment.
40
REFERENCES
References
[1] Angular. (Accessed on 12/19/2017). url: https://angular.io/.
[2] Auth0. Identity Providers Supported by Auth0. (Accessed on 12/21/2017).
url: https://auth0.com/docs/identityproviders.
[3] Auth0. JSON Web Tokens. url: https://jwt.io/ (visited on 09/19/2017).
[4] Tim Berners-Lee, Roy T. Fielding, and Larry Masinter. Uniform Resource
Identifier (URI): Generic Syntax. STD 66. http : / / www . rfc - editor .
org/rfc/rfc3986.txt. RFC Editor, Jan. 2005. url: http://www.rfc-
editor.org/rfc/rfc3986.txt.
[5] Charles Bihis. Mastering OAuth 2.0 : create powerful applications to inter-
act with popular service providers such as Facebook, Google, Twitter, and
more by leveraging the OAuth 2.0 Authorization Framework. Birmingham,
UK: Packt Publishing, 2015. isbn: 9781784395407.
[6] Brian Campbell. HTTPS Token Binding with TLS Terminating Reverse
Proxies. url: https://datatracker.ietf.org/meeting/99/materials/
slides- 99- tokbind- https- token- binding- with- tls- terminating-
reverse-proxies/ (visited on 10/04/2017).
[7] Wm. Arthur Conklin et al. CompTIA Security+ All-in-One Exam Guide,
Fifth Edition (Exam SY0-501). McGraw-Hill Education, 2018. isbn: 9781260019292.
[8] Critical vulnerabilities in JSON Web Token libraries. (Accessed on 12/18/2017).
url: https://auth0.com/blog/critical- vulnerabilities- in- json-
web-token-libraries/.
[9] Internet Engineering Task Force. A Method for Signing HTTP Requests
for OAuth. url: https://tools.ietf.org/html/draft- ietf- oauth-
signed-http-request-03 (visited on 09/21/2017).
[10] Internet Engineering Task Force. draft-ietf-oauth-token-binding-04 - OAuth
2.0 Token Binding. url: https://tools.ietf.org/html/draft- ietf-
oauth-token-binding-04 (visited on 10/04/2017).
[11] Internet Engineering Task Force. OAuth 2.0 Message Authentication Code
(MAC) Tokens. url: https : / / tools . ietf . org / html / draft - ietf -
oauth-v2-http-mac-05 (visited on 09/21/2017).
[12] Internet Engineering Task Force. RFC 2617 - HTTP Authentication: Ba-
sic and Digest Access Authentication. url: https://tools.ietf.org/
html/rfc2617 (visited on 09/29/2017).
[13] Internet Engineering Task Force. RFC 4120 - The Kerberos Network Au-
thentication Service (V5). url: https://tools.ietf.org/html/rfc4120
(visited on 09/28/2017).
[14] Internet Engineering Task Force. RFC 4648 - The Base16, Base32, and
Base64 Data Encodings. url: https://tools.ietf.org/html/rfc4648
(visited on 10/03/2017).
[15] Internet Engineering Task Force. RFC 6749 - The OAuth 2.0 Authoriza-
tion Framework. url: https://tools.ietf.org/html/rfc6749 (visited
on 08/28/2017).
41
REFERENCES
[16] Internet Engineering Task Force. RFC 7517 - JSON Web Key (JWK).
url: https://tools.ietf.org/html/rfc7517 (visited on 10/04/2017).
[17] Internet Engineering Task Force. RFC 7518 - JSON Web Algorithms
(JWA). url: https : / / tools . ietf . org / html / rfc7518 (visited on
10/03/2017).
[18] Internet Engineering Task Force. RFC 7800 - Proof-of-Possession Key
Semantics for JSON Web Tokens (JWTs). url: https://tools.ietf.
org/html/rfc7800 (visited on 09/20/2017).
[19] IANA. JSON Web Token (JWT) Registered Claims. url: https://www.
iana.org/assignments/jwt/jwt.xhtml (visited on 10/03/2017).
[20] Open ID. OpenID Connect Core 1.0. url: http://openid.net/specs/
openid-connect-core-1_0.html (visited on 09/19/2017).
[21] The German Federal Office for Information Security. Cryptographic Mech-
anisms: Recommendations and Key Lengths, Version 2017-01. (Accessed
on 12/20/2017). url: https://www.bsi.bund.de/SharedDocs/Downloads/
EN/BSI/Publications/TechGuidelines/TG02102/BSI-TR-02102-1.pdf.
[22] M. Jones and D. Hardt. The OAuth 2.0 Authorization Framework: Bearer
Token Usage. RFC 6750. http://www.rfc- editor.org/rfc/rfc6750.
txt. RFC Editor, Oct. 2012. url: http://www.rfc- editor.org/rfc/
rfc6750.txt.
[23] JOSE + JWT library for Java | Connect2id. (Accessed on 12/19/2017).
url: https://connect2id.com/products/nimbus-jose-jwt.
[24] jsrsasign - cryptography library in JavaScript. (Accessed on 12/19/2017).
url: https://kjur.github.io/jsrsasign.
[25] Lagom - Microservices Framework. (Accessed on 12/19/2017). url: https:
//www.lagomframework.com/.
[26] James Miller. Statistics for Data Science. Birmingham: Packt Publishing,
2017. isbn: 9781788290678.
[27] MIT. IdP (Identity Provider) - Glossary - Hermes. (Accessed on 12/21/2017).
url: http://kb.mit.edu/confluence/x/XoK2.
[28] Irakli Nadareishvili. Microservice architecture : Aligning principles, prac-
tices, and culture. Sebastopol, CA: O’Reilly Media, 2016. isbn: 9781491956250.
[29] OASIS. SAML V2.0 Holder-of-Key Assertion Profile Version 1.0. url:
http://docs.oasis- open.org/security/saml/Post2.0/sstc- saml2-
holder-of-key-cs-02.html (visited on 09/20/2017).
[30] OASIS. Security Assertion Markup Language (SAML) 2.0 Technical Overview.
url: https://www.oasis-open.org/committees/download.php/11511/
sstc-saml-tech-overview-2.0-draft-03.pdf (visited on 09/28/2017).
[31] OAuth 2.0 — OAuth. (Accessed on 12/26/2017). url: https://oauth.
net/2/.
[32] OAuth Parameters. (Accessed on 12/21/2017). url: https://www.iana.
org/assignments/oauth-parameters/oauth-parameters.xhtml.
[33] Nat Sakimura, John Bradley, and Naveen Agarwal. Proof Key for Code
Exchange by OAuth Public Clients. RFC 7636. Sept. 2015. doi: 10.17487/
RFC7636. url: https://rfc-editor.org/rfc/rfc7636.txt.
42
REFERENCES
43
Appendices
A Testing Platform
44