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
-
Identify noncompliant pods and their owners (run on any machine with kubectl access):
Review each listed workload and decide whether it legitimately needs to call the Kubernetes API; only proceed for those that do not.
-
For workloads managed by controllers (Deployment/StatefulSet/DaemonSet/Job/CronJob), edit the controller to set
automountServiceAccountToken: falseat the pod spec level (run on any machine with kubectl access):In the opened manifest, underspec.template.spec, add or change:Save and exit; Kubernetes will roll out updated pods. -
For standalone Pods you control directly (no controller ownerReference), edit the Pod spec and re-create it (run on any machine with kubectl access):
Edit
/tmp/pod-POD_NAME.yamland underspecadd:Then delete and re-create: -
Optionally harden shared ServiceAccounts so all attached pods disable token automount by default (run on any machine with kubectl access):
Add:Be sure this ServiceAccount is not used by workloads that need Kubernetes API access.
-
For pods that legitimately need the Kubernetes API, document the decision and ensure least-privilege RBAC:
Adjust Roles/ClusterRoles separately so the token, where kept, has only necessary permissions.
-
Verify remediation (run on any machine with kubectl access):
Confirm the output is
is_compliant=trueor that remaining flagged pods are those you intentionally allowed to keep tokens.
Using kubectl
Using kubectl
On any machine with kubectl access to the cluster:Check For other controllers, replace Apply it:
- Identify one non‑compliant pod (example):
- Get the owning workload and current pod spec:
.metadata.ownerReferences to see if it is owned by a Deployment, StatefulSet, Job, CronJob, etc. You must edit the owning workload, not the live Pod.- Patch a Deployment to disable token automount for pods that do not need the API (example for a Deployment owner):
deployment with statefulset, daemonset, job, or cronjob as appropriate.- If the pod is standalone (no ownerReferences), edit the Pod manifest source and re‑apply it declaratively. Example manifest snippet:
- Verification (matches the audit intent):
Automation
Automation

