Kubernetes check

Service account token auto-mounted

K8S-SEC-006MediumSecurity

Trigger condition

For a Deployment template: the effective automountServiceAccountToken resolves to true -- an explicit Pod-template value, then an explicit value on the referenced ServiceAccount (the default ServiceAccount in the workload's namespace when serviceAccountName is omitted), then Kubernetes' own default of true once the account was actually found -- and at least one regular or init container would actually receive the token (a container that already mounts something at the standard token path is skipped by admission). If the Pod-template value is unset and the account cannot be resolved at all, the effective policy is unknown and never flagged. For an already-admitted Pod: evidence-based, not policy-based -- a regular, init, or live ephemeral container's own volumeMount genuinely references one of that Pod's real volumes that is itself a default-audience, kube-api-access-* service-account-token projection (an explicitly configured custom-audience projection is out of scope even under a matching volume name, since the admitted spec alone cannot establish who injected it), and the matching volumeMount's own selected portion of that volume actually includes the token file: no subPath at all, or subPath: token, both qualify, while a subPath naming a different file (e.g. ca.crt) does not, and a dynamic subPathExpr is treated as unresolved since its actual target cannot be established from the spec alone. A volume name alone, an unused or custom-audience token projection, a subPath that excludes the token, or the current ServiceAccount setting alone are each insufficient; an older Pod can still carry the mount after its ServiceAccount or template was later changed to disable it. A Deployment-owned Pod's own finding is suppressed only when its owning Deployment's own template resolution is itself enabled, resolved the same ServiceAccount name, and its own receiving containers are a superset of this Pod's own affected containers.

Evidence

States the resolved ServiceAccount name and, for a template, which setting or default enabled automounting; for an already-admitted Pod, each affected container's name and its own real, observed mountPath -- never assumed to be the standard one.

Impact

An auto-mounted service-account token lets any process in the affected container authenticate to the Kubernetes API as this ServiceAccount. A container compromised through any other means (a vulnerable dependency, a supply-chain compromise, an unauthenticated debug endpoint) could use this token to act as that ServiceAccount against the cluster -- the specific actions actually available depend entirely on the permissions (RBAC Roles/RoleBindings or ClusterRoles) granted to this ServiceAccount, not on this setting alone.

Recommendation

Set automountServiceAccountToken: false in the workload's Pod template (or standalone Pod source manifest) if it does not need the default API token, after checking application dependencies for anything that relies on it. For a workload that does need API access, use a dedicated, least-privilege ServiceAccount scoped to only the permissions it actually requires and, where appropriate, project a short-lived token only into the container(s) that need it, rather than relying on the broadly auto-mounted default. For a Deployment-managed template, make the change in the Deployment's own Pod template and roll out the change. For a Pod with no verified owning Deployment, if a controller manages it (e.g. a DaemonSet or StatefulSet), make the change in that workload's own source configuration and follow its normal update process; if the Pod is standalone, make the change in its own source manifest and recreate it. When a live Pod's own finding is not fully covered by its owning Deployment's own finding, the recommendation names the exact reason directly -- the template's policy is explicitly disabled, the template's policy could not be resolved, the template's policy resolves to enabled but every one of its containers already blocks the standard mount path (so the template itself produced no finding), the resolved ServiceAccount differs, or the Pod exposes the token to an additional container -- and directs investigation through the owning controller rather than editing the Pod directly.

Important limitations

This check evaluates only the standard, default-audience, auto-mounted service-account token, identified by a kube-api-access-* projected volume and a volumeMount whose own selected portion includes the token file. It does not evaluate a manually projected token for a custom audience, a legacy Secret-backed token, a mount reached only through a dynamic subPathExpr (treated as unresolved, never flagged), or the permissions actually granted to the ServiceAccount itself.

← Back to the check catalogue