Overview
Service accounts tokens should not be mounted in pods except where the workload running in the pod explicitly needs to communicate with the API server.
Rationale
Mounting service account tokens inside pods can provide an avenue for privilege escalation attacks where an attacker is able to compromise a single pod in the cluster. Avoiding mounting these tokens removes this attack avenue.
Impact
Pods mounted without service account tokens will not be able to communicate with the API server, except where the resource is available to unauthenticated principals.
Default value
By default, all pods get a service account token mounted in them.
Remediation guidance
Modify the definition of pods and service accounts which do not need to mount service account tokens to disable it.
References
Multiple Remediation Paths
SERVICE-WIDE (RECOMMENDED when many resources are affected): Apply organization/tenant-level guardrails and baseline policies for the entire platform.
ASSET-LEVEL: Fix only the affected resources identified by this control.
PREVENTIVE: Add preventive policy checks to CI/CD and periodic posture scans.
References for Service-Wide Patterns
- Platform policy/governance and preventive control patterns should be applied tenant-wide where supported.
Query logic
These are the stored checks tied to this control.
Kubernetes CronJobs pod template which automounts service accounts
Connectors
Covered asset types
Expected check: eq []
{
cronJobs(
where: {
podTemplate: {
isAutomountServiceAccountTokenSet: true
automountServiceAccountToken: true
}
}
) {
...AssetFragment
}
}Kubernetes Jobs pod templates which automounts service accounts
Connectors
Covered asset types
Expected check: eq []
{
jobs(
where: {
cronJobName: ""
podTemplate: {
isAutomountServiceAccountTokenSet: true
automountServiceAccountToken: true
}
}
) {
...AssetFragment
}
}Kubernetes DaemonSets pod templates which automounts service accounts
Connectors
Covered asset types
Expected check: eq []
{
daemonSets(
where: {
podTemplate: {
isAutomountServiceAccountTokenSet: true
automountServiceAccountToken: true
}
}
) {
...AssetFragment
}
}Kubernetes Deployments pod templates which automounts service accounts
Connectors
Covered asset types
Expected check: eq []
{
deployments(
where: {
podTemplate: {
isAutomountServiceAccountTokenSet: true
automountServiceAccountToken: true
}
}
) {
...AssetFragment
}
}Kubernetes ReplicaSets pod templates which automounts service accounts
Connectors
Covered asset types
Expected check: eq []
{
replicaSets(
where: {
deploymentName: ""
podTemplate: {
isAutomountServiceAccountTokenSet: true
automountServiceAccountToken: true
}
}
) {
...AssetFragment
}
}
Kubernetes StatefulSets pod templates which automounts service accounts
Connectors
Covered asset types
Expected check: eq []
{
statefulSets(
where: {
podTemplate: {
isAutomountServiceAccountTokenSet: true
automountServiceAccountToken: true
}
}
) {
...AssetFragment
}
}
Kubernetes