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'sdefaultaccount to it. If thedefaultobject is deleted, the control plane recreates it. - Credentials are mounted by default. Unless
automountServiceAccountTokenis set tofalse, 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:NAMEand belong to the groupssystem:serviceaccountsandsystem: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.
| Version | Change | What it means for governance |
|---|---|---|
| Before v1.22 | Kubernetes automatically created Secret-based credentials for service accounts | Clusters that started on older versions may still hold long-lived token Secrets |
| v1.22 | Bound 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 volume | New pods get tokens that expire and are refreshed automatically |
| v1.24 | Secret-based tokens are no longer generated automatically for each service account | A 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 deleted | Unused 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.33 | Creating node-bound tokens is generally available | Tokens 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.
| Control | Kubernetes mechanism | Acceptance criterion (our suggestion) |
|---|---|---|
| One account per workload | Set spec.serviceAccountName on every workload | No pods in application namespaces run as default; exceptions are listed with an owner |
| No API token where none is needed | automountServiceAccountToken: false on the account or the pod | Workloads that do not call the API server have automounting disabled |
| Least-privilege RBAC | Roles and RoleBindings scoped to the namespace and verbs needed. Kubernetes documentation describes using RBAC so service account permissions follow least privilege | No service account is bound to cluster-admin or a wildcard role without a recorded exception and named owner |
| No long-lived token Secrets | Use TokenRequest (for example kubectl create token with --duration) instead of kubernetes.io/service-account-token Secrets | Count of token Secrets is zero, or each has an owner, purpose and review date |
| Audience set for external consumers | Projected tokens with a specific audience; Kubernetes advises that an application should always define the audience it accepts | Every service that accepts Kubernetes tokens checks audience, ideally via the TokenReview API |
| Secrets protected | Encryption at rest for Secrets, least-privilege RBAC on Secrets, access limited to specific containers, external secret store providers | Encryption at rest is configured and RBAC read access to Secrets is limited to named accounts |
| Audit logging on | API server audit policy (--audit-policy-file) and a log or webhook backend | Audit events for service account activity reach central storage; see monitoring and detection |
| Owner recorded | Labels 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-sincelists 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.automountServiceAccountTokenshows 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 risk | Where it shows up in Kubernetes | Control above |
|---|---|---|
| NHI1 Improper Offboarding | Accounts and token Secrets left after a workload is removed | Inventory queries; owner recorded |
| NHI2 Secret Leakage | Token or cloud key readable from a Secret or a container image | Secrets protected; cloud access without keys |
| NHI5 Overprivileged NHI | Service account bound to cluster-wide or wildcard roles | Least-privilege RBAC |
| NHI7 Long-Lived Secrets | kubernetes.io/service-account-token Secrets | No long-lived token Secrets |
| NHI8 Environment Isolation | Test and production workloads sharing a cluster identity or cloud role | One account per workload; cloud trust scoped per namespace and account |
| NHI9 NHI Reuse | Many workloads running as default | One 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
- Kubernetes documentation, Service Accounts, Kubernetes project, accessed 10 Oct 2026
- Kubernetes documentation, Managing Service Accounts, Kubernetes project, accessed 10 Oct 2026
- Kubernetes documentation, Configure Service Accounts for Pods, Kubernetes project, accessed 10 Oct 2026
- Kubernetes documentation, Authenticating, Kubernetes project, accessed 10 Oct 2026
- Kubernetes documentation, Secrets, Kubernetes project, accessed 10 Oct 2026
- Kubernetes documentation, Auditing, Kubernetes project, accessed 10 Oct 2026
- Kubernetes feature gate record, LegacyServiceAccountTokenCleanUp, Kubernetes project, accessed 10 Oct 2026
- Amazon EKS User Guide, EKS Pod Identities, Amazon Web Services, accessed 16 Oct 2026
- Google Cloud, About Workload Identity Federation for GKE, Google Cloud, accessed 16 Oct 2026
- Microsoft Learn, Workload identity federation, Microsoft, accessed 16 Oct 2026
- OWASP Non-Human Identities Top 10 (2025), OWASP Foundation, 2025
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.