More Info:
Verifies automountServiceAccountToken is false for pods that do not call the Kubernetes API. A mounted token is a ready-made credential for an attacker who lands in the pod.Risk Level
MediumAddress
SecurityCompliance Standards
- Cloudanix Best Practice
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
On any machine with kubectl access, list the non-compliant pods and choose one to review (replace NAMESPACE and POD_NAME in the next steps accordingly):
-
Still on any machine with kubectl access, inspect the chosen pod to determine whether it legitimately calls the Kubernetes API (look for in-cluster client libraries, API server URLs, or service account token usage in args/env/config):
If the workload needs to call the Kubernetes API, document the exception and do not change
automountServiceAccountTokenfor this pod. -
If the pod does not need Kubernetes API access and is controlled by a higher-level object (Deployment, StatefulSet, DaemonSet, Job, CronJob, etc.), identify that owner:
Then edit the owner resource’s pod template to disable token automount:In the opened YAML, under
spec.template.spec, add or set:Save and exit to trigger a rolling update of the pods. -
If the pod is not controlled by a higher-level object (no ownerReferences or kind is “Pod”), edit the pod spec directly (note this will not persist across re-creates from external systems):
Under
spec, add or set: -
As an alternative (and where appropriate), you may set this at the ServiceAccount level so all pods using it disable token automount by default. On any machine with kubectl access:
Add or set:Then ensure pods that should not have tokens use this ServiceAccount in their pod templates.
-
Verify compliance on any machine with kubectl access:
Confirm that pods which do not need API access now show
automountServiceAccountToken=falseandis_compliant=true.
Using kubectl
Using kubectl
On any machine with kubectl access:
-
Identify the noncompliant pod and its owner (from the audit output), for example:
- Namespace:
my-namespace - Pod name:
my-app-6f7b9d8c7d-abcde - Owner:
Deployment/my-app
- Namespace:
- Export the owning workload manifest (example for a Deployment):
- Edit the manifest locally (
my-app-deployment.yaml) and setautomountServiceAccountToken: falsein the pod spec. For example:
- Apply the updated manifest:
- (Optional) If the pod is created directly (no owner), patch it in place:
- Verification (same style as the audit, on any kubectl machine):
Automation
Automation

