PlaybookLast checked 16 October 2026 with AI-assisted research. Editor: Akshay Dubey.Corrections logEditorial policy
On this page
  1. How Kubernetes service accounts work
  2. Bound tokens and legacy tokens: a dated timeline
  3. Controls, with acceptance criteria
  4. Inventory queries
  5. Cloud access without keys in pods
  6. How this maps to the OWASP NHI Top 10
  7. FAQ
  8. Sources

Kubernetes service account governance means knowing every service account in every cluster, giving each workload its own account with least-privilege RBAC, switching off token automounting where a pod does not call the API, relying on short-lived bound tokens instead of Secret-based tokens, and removing legacy tokens. Cloud access from pods should use federation, not cloud keys stored in the cluster.

A Kubernetes service account is a non-human identity. The token a pod presents is a credential that identity holds. This page sets out how Kubernetes issues those credentials today, which version changed what, and the controls and acceptance criteria we suggest. Kubernetes facts are from kubernetes.io as read on 10 October 2026; controls marked as our suggestion are not Kubernetes requirements.

How Kubernetes service accounts work

  • Namespaced, and one by default. Each namespace has a service account named default. If a pod does not name a service account, Kubernetes assigns the namespace's default account to it. If the default object is deleted, the control plane recreates it.
  • Credentials are mounted by default. Unless automountServiceAccountToken is set to false, the pod receives credentials for the API server. The field can be set on the ServiceAccount or the pod; if both are set, the pod spec takes precedence.
  • The identity has a fixed name. Service accounts authenticate as system:serviceaccount:NAMESPACE:NAME and belong to the groups system:serviceaccounts and system:serviceaccounts:NAMESPACE. RBAC bindings and audit log entries use this name.
  • Tokens are bearer tokens. Kubernetes documentation states that service account bearer tokens are valid outside the cluster. Whoever holds the token can act as the account until it expires or is invalidated.

Bound tokens and legacy tokens: a dated timeline

Most governance questions in Kubernetes come down to which kind of token a cluster still has. The changes below are taken from Kubernetes documentation and feature gate records.

VersionChangeWhat it means for governance
Before v1.22Kubernetes automatically created Secret-based credentials for service accountsClusters that started on older versions may still hold long-lived token Secrets
v1.22Bound service account token volumes stable: by default the kubelet obtains time-bound tokens through the TokenRequest API (stable since v1.20) and mounts them in a projected volumeNew pods get tokens that expire and are refreshed automatically
v1.24Secret-based tokens are no longer generated automatically for each service accountA kubernetes.io/service-account-token Secret created after this point was created on purpose by someone; it needs an owner and a reason
v1.28 (alpha), v1.29 (beta), v1.30 (stable)Legacy token clean-up (LegacyServiceAccountTokenCleanUp). From 1.29, auto-generated legacy tokens unused for a period (default one year) are labelled kubernetes.io/legacy-token-invalid-since and stop authenticating; if still unused after a further period (default one year), they are deletedUnused auto-generated tokens are retired by the cluster, slowly. Manually created token Secrets are not auto-generated and are outside this clean-up. The feature gate was removed after v1.31, so from v1.32 the clean-up cannot be switched off; the period is set with --legacy-service-account-token-clean-up-period
v1.33Creating node-bound tokens is generally availableTokens can be bound to a Node so they are revoked when the Node is deleted

Bound tokens from the TokenRequest API expire when the pod is deleted or after a set lifespan, by default one hour. The kubelet requests a new token when the current one is older than 80% of its time to live, or older than 24 hours. Kubernetes documentation notes there is no specific mechanism to invalidate a token issued through TokenRequest other than these bindings and expiry, so deleting the pod (or Node, for node-bound tokens) is the revocation path. Manually created token Secrets remain supported, but Kubernetes recommends the TokenRequest subresource instead, and warns that long-lived bearer tokens are a security risk once disclosed.

Controls, with acceptance criteria

The controls below are our suggestion for governing service accounts in a cluster. The Kubernetes mechanism in each row is documented; the acceptance criterion is ours, written so it can be checked from a query or a record.

ControlKubernetes mechanismAcceptance criterion (our suggestion)
One account per workloadSet spec.serviceAccountName on every workloadNo pods in application namespaces run as default; exceptions are listed with an owner
No API token where none is neededautomountServiceAccountToken: false on the account or the podWorkloads that do not call the API server have automounting disabled
Least-privilege RBACRoles and RoleBindings scoped to the namespace and verbs needed. Kubernetes documentation describes using RBAC so service account permissions follow least privilegeNo service account is bound to cluster-admin or a wildcard role without a recorded exception and named owner
No long-lived token SecretsUse TokenRequest (for example kubectl create token with --duration) instead of kubernetes.io/service-account-token SecretsCount of token Secrets is zero, or each has an owner, purpose and review date
Audience set for external consumersProjected tokens with a specific audience; Kubernetes advises that an application should always define the audience it acceptsEvery service that accepts Kubernetes tokens checks audience, ideally via the TokenReview API
Secrets protectedEncryption at rest for Secrets, least-privilege RBAC on Secrets, access limited to specific containers, external secret store providersEncryption at rest is configured and RBAC read access to Secrets is limited to named accounts
Audit logging onAPI server audit policy (--audit-policy-file) and a log or webhook backendAudit events for service account activity reach central storage; see monitoring and detection
Owner recordedLabels or annotations on the ServiceAccount (a site convention, not a Kubernetes feature)Each account records a named owner and the owning team; a team name alone is not an owner

Kubernetes Secrets are, by default, stored unencrypted in the API server's data store (etcd), and anyone with API access to a Secret, or access to etcd, can read it. Base64 in a Secret manifest is an encoding, not protection. That is why the Secrets row above starts with encryption at rest.

Inventory queries

The NHI discovery queries page lists commands for every service account, the accounts pods actually use, legacy token Secrets and RBAC bindings. Two further queries help with the timeline above:

  • kubectl get secrets --all-namespaces --field-selector type=kubernetes.io/service-account-token -L kubernetes.io/legacy-token-last-used -L kubernetes.io/legacy-token-invalid-since lists token Secrets with the last-used and invalid-since labels as columns. A Secret with no last-used label may never have been used since tracking began, or may have been created manually.
  • kubectl get pods --all-namespaces -o custom-columns=NS:.metadata.namespace,POD:.metadata.name,SA:.spec.serviceAccountName,AUTOMOUNT:.spec.automountServiceAccountToken shows which account each pod uses and whether the pod overrides automounting. A blank AUTOMOUNT value means the pod inherits the account setting.

An account that no running pod uses is a candidate for removal, not proof of disuse: tokens can be used from outside the cluster. Confirm against audit logs before deleting.

Cloud access without keys in pods

Pods often need a cloud identity as well as a Kubernetes one. Each major provider maps a Kubernetes service account to a cloud identity without a stored key:

  • Amazon EKS. IAM roles for service accounts (IRSA) federate through an OIDC identity provider. EKS Pod Identity associates an IAM role with a service account in a namespace; a Pod Identity Agent runs as a DaemonSet on each node and supplies temporary credentials to pods on that node, without an OIDC identity provider.
  • Google Kubernetes Engine. Workload Identity Federation for GKE lets IAM policies grant a Kubernetes service account access to Google Cloud APIs without service account key files. IAM policies name the account through a principal identifier that includes the project's workload identity pool (PROJECT_ID.svc.id.goog), the namespace and the service account name.
  • Microsoft Entra. Workload identity federation lets a user-assigned managed identity or app registration trust tokens from a Kubernetes cluster, including AKS, EKS, GKE or on-premises clusters.

In each case the cloud-side trust should name the specific namespace and service account, not a whole cluster or namespace, unless every workload in that scope needs the same access. See workload identity federation for the trust configuration checklist and cloud workload identity governance for the cloud side. For workload-to-workload identity across clusters, see SPIFFE and SPIRE.

How this maps to the OWASP NHI Top 10

The mapping is ours, not a statement by OWASP.

OWASP riskWhere it shows up in KubernetesControl above
NHI1 Improper OffboardingAccounts and token Secrets left after a workload is removedInventory queries; owner recorded
NHI2 Secret LeakageToken or cloud key readable from a Secret or a container imageSecrets protected; cloud access without keys
NHI5 Overprivileged NHIService account bound to cluster-wide or wildcard rolesLeast-privilege RBAC
NHI7 Long-Lived Secretskubernetes.io/service-account-token SecretsNo long-lived token Secrets
NHI8 Environment IsolationTest and production workloads sharing a cluster identity or cloud roleOne account per workload; cloud trust scoped per namespace and account
NHI9 NHI ReuseMany workloads running as defaultOne account per workload

Frequently asked questions

How long do Kubernetes service account tokens last?

Tokens issued through the TokenRequest API and mounted by the kubelet expire when the pod is deleted or after a set lifespan, by default one hour, and the kubelet refreshes them before expiry. Manually created Secrets of type kubernetes.io/service-account-token do not expire on their own.

Does Kubernetes still create long-lived service account tokens?

Not automatically. Since v1.24 Kubernetes no longer generates Secret-based tokens for each service account. Since v1.29, auto-generated legacy tokens unused for a year (by default) are marked invalid and later deleted. Token Secrets created by hand are still supported and are not covered by that clean-up.

Should every pod have its own service account?

Each workload should, in our view. Pods that name no account run as the namespace default account, so every such workload shares one identity and one set of permissions. That is NHI reuse in OWASP terms and makes audit logs ambiguous about which workload acted.

Are Kubernetes Secrets encrypted?

Not by default. Kubernetes documentation states that Secrets are stored unencrypted in etcd by default and recommends enabling encryption at rest, least-privilege RBAC on Secrets, limiting access to specific containers and considering external secret stores.

How should pods get cloud credentials?

Through federation rather than stored keys: IRSA or EKS Pod Identity on Amazon EKS, Workload Identity Federation for GKE on Google Cloud, and Microsoft Entra workload identity federation for clusters that need Azure access. Scope the cloud-side trust to the specific namespace and service account.

What are the alternatives to Kubernetes service account tokens for workload authentication?

For calls to a cloud provider, federation maps the service account to a cloud identity without a stored key: IRSA or EKS Pod Identity, Workload Identity Federation for GKE, or Microsoft Entra workload identity federation. For workload-to-workload authentication across clusters or organisations, SPIFFE and SPIRE issue attested identities. The service account remains the in-cluster identity in each case.

Sources

From the publisher

HumanAudit, which publishes this site, is preparing the NHI Governance pack: an NHI policy, ownership register, lifecycle procedures and one control set mapped, as our interpretation, to PCI DSS v4.0.1, ISO/IEC 27001:2022, NIS2 and DORA. Planned for March 2027; not yet on sale, and no price has been published.

Monthly change log

Know when the NHI landscape changes.

One email a month from this reference: new deals, standards status changes and corrections. No sponsored content. Unsubscribe from any email.

We first email you a link to confirm. Privacy policy.