Internet-Draft | Workload Identity | July 2024 |
Hofmann, et al. | Expires 9 January 2025 | [Page] |
The use of the OAuth 2.0 framework for container orchestration systems poses a challenge as managing secrets, such as client_id and client_secret, can be complex and error-prone. "Service account token volume projection", a term introduced by Kubernetes, provides a way of injecting JSON Web Tokens (JWTs) to workloads.¶
This document describes the current best practices to avoid client_secret provisioning and leverage platform attestation to receive access tokens from an OAuth 2.0 authorization server via RFC 7523.¶
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 9 January 2025.¶
Copyright (c) 2024 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 Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License.¶
In workload scenarios dedicated management entities, also referred to as "control plane" entities, are used to start, monitor and stop workloads dynamically. These workloads frequently interact with each other and other entities within the corporate network or online. When one workload, acting as an OAuth client, wants to gain access to a protected resource hosted on another workload or on the Internet (referred here generically as a resource server) then authorization is typically required.¶
To authenticate workloads accessing resources, each workload instance requires unique credentials. This poses challenges in environments where workloads start, stop, relocate, and scale dynamically. Manual configuration, rotation, and management efforts can result in management overhead at best and security risks such as credential exposure at worst.¶
"Service account token volume projection" is a feature in the Kubernetes container orchestration system that enables users to attach platform-attested tokens to their workloads. Workloads use these tokens to authenticate themselves to APIs within the platform's control plane. While this token is used for access, it functions more like an ID Token rather than an Access Token in the OAuth context. Workloads do not receive a refresh token, and there is no involvement of authorization or consent; it simply serves as proof of the workload's identity. Workloads have several methods to obtain such tokens from Kubernetes, including through the TokenRequest API invoked by business logic or Token volume projection, which mounts the token into the workload's file system and ensures it remains up-to-date. Token volume projection offers the advantage of requiring no manual intervention by the application beyond reading a file.¶
Initially designed to authenticate access to the control plane API, the industry has recognized the service account token for its low maintenance and platform attestation capabilities and has started using it as a JWT client assertion, as specified in [RFC7523]. This token is presented to an authorization server as a client assertion. The authorization server validates the assertion's signature using [OIDC] metadata or [RFC8414] and uses the claims within the token to authenticate the client. Overall, the authorization server trusts the platform control plane for issuing and delivering these credentials. The authorization server then responds with an Access Token that the workload can use to access an OAuth2-protected resource on a resource server.¶
Figure 1 illustrates the interaction in the architecture graphically.¶
This specification defines the utilization of Service Account Tokens within container orchestration systems, providing a secure and scalable method for creating and managing these tokens while ensuring interoperability with existing OAuth-based authorization systems.¶
To distinguish between entities, we refer to the OAuth 2.0 Authorization Server within the cluster's control plane as the "Control Plane." Given the presence of two distinct access tokens, we specifically designate the token issued by the Control Plane as the "Service Account Token," thereby differentiating it from the access token issued to an OAuth 2.0 client operating within the workload by a separate authorization server.¶
In Section 3, further details are provided regarding the token content and the associated security properties.¶
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.¶
The terms 'workload' and 'container' are used interchangeably.¶
This specification relies on the use of OAuth 2.0 [RFC6749] and [RFC7523] for client authentication using a JWT.¶
Service Account Tokens used in container orchestration systems are vulnerable to various threats, as outlined below:¶
Token theft: Attackers who compromise a workload can steal tokens to impersonate it and gain unauthorized access to resources.¶
Token reuse: Stolen tokens may be reused within their expiration period to gain repeated unauthorized access. However, the expiration time limits the token reuse time window.¶
Misconfigured service accounts: mproperly configured service accounts can grant applications excessive privileges.¶
Theft of token signing key: Attackers gaining control plane access can steal the token signing key, akin to compromising client_id and client_secret in OAuth, potentially accessing all secrets in the orchestration system.¶
The following fields are populated in the Service Account Token:¶
The 'iss' claim MUST contain a string identifying the worklod orchestrator.¶
The 'sub' claim MUST contain a string identifying the workload, also serving as the client_id per [RFC7523].¶
The 'aud' claim MUST identify one or multiple authorization servers intended to receive and authorize the Service Account Token.¶
Additional processing requirements are specified in [RFC7523].¶
This entire document is about security.¶
This document does not require actions by IANA.¶
Add your name here.¶
The functionality described in this specification can be verified using Kubernetes. Modern version of Kubernetes implement service account token volume projection, which enables the ability to inject the Service Account Token with a specific issuer and audience into the workload.¶
A most important parts of the configuration are (which can be found at the end of the full configuration):¶
the path, where the application can find the token, as a file¶
the expiration of the token in seconds¶
the audience, which will be in the Service Account Token¶
serviceAccountToken: path: token expirationSeconds: 7200 audience: "https://localhost:5001/connect/token"¶
The full configuration is shown below:¶
apiVersion: apps/v1 kind: Deployment metadata: name: simpleapp labels: app: simpleapp spec: replicas: 1 selector: matchLabels: app: simpleapp template: metadata: labels: app: simpleapp spec: containers: - name: container1 image: curlimages/curl:8.2.1 imagePullPolicy: Always command: - sleep - "3600" env: - name: TOKEN_PATH value: '/var/run/secrets/other_token/token/token' volumeMounts: - mountPath: '/var/run/secrets/other_token/token' name: other-token-path volumes: - name: other-token-path projected: sources: - serviceAccountToken: path: token expirationSeconds: 7200 audience: "https://localhost:5001/connect/token"¶
The most important parts of the token, which the workload will obtain, looks as follows:¶
{ "aud": [ "https://localhost:5001/connect/token" ], "exp": 1691752299, "iss": "https://kubernetes.default.svc.cluster.local", "sub": "system:serviceaccount:test:default" }¶
A complete token example obtained by the workload is shown below.¶
{ "aud": [ "https://localhost:5001/connect/token" ], "exp": 1691752299, "iat": 1691745099, "iss": "https://kubernetes.default.svc.cluster.local", "kubernetes.io": { "namespace": "test", "pod": { "name": "simpleapp-5d7dcf96df-n7csk", "uid": "9fc443d7-5c7a-48d5-9679-0ee03b17d4c5" }, "serviceaccount": { "name": "default", "uid": "0bea3006-fb60-49a3-bc80-7e6884d378ae" } }, "nbf": 1691745099, "sub": "system:serviceaccount:test:default" }¶
To enable the authorization server to use the Service Account Token for client authentication the following configuration is needed:¶
the client id is set to system:serviceaccount:test:default
. In our case we are using the default service account in the test namespace.¶
the public key of the token signing key. This can be either configured manually, or dynamically by referencing the JWK endpoint Kubernetes exposes, which is https://kubernetes.default.svc.cluster.local/openid/v1/jwks¶
Note: Authorization servers that follow the OpenID Connect Core specification, which profiles RFC 7523, will unfortunately run into problem. Here is the why.¶
For JWT-based client authentication [OIDC] specifies the following:¶
The 'jti' claim is mandated for client authentication.¶
The 'iss' claim must match the 'sub' claim. Since Kubernetes issues the tokens, and not the workload, the two do not match.¶
[RFC7523], on the other hand, does not mandate the use of a 'jti' claim and does not mandate that the 'iss' claim equals the 'sub' claim.¶