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):
-
For each listed workload, decide if it legitimately calls the Kubernetes API (run on any machine with kubectl access):
- Inspect container images, args, and env for in-cluster API use:
- If the app needs to talk to the API (client libraries,
KUBERNETES_SERVICE_HOST, in-cluster config, orcurltohttps://kubernetes.default.svc), do not disable the token; instead, review RBAC separately. - Only proceed to the next step for workloads that do not need API access.
- Inspect container images, args, and env for in-cluster API use:
-
Disable token automount at the Pod spec level for controller-managed workloads (recommended) (run on any machine with kubectl access, adjust
kindas appropriate: Deployment, DaemonSet, StatefulSet, Job, etc.):Example for a StatefulSet: -
For standalone Pods not managed by a controller, recreate them with token automount disabled (run on any machine with kubectl access):
-
Optionally, disable token automount on the ServiceAccount used by multiple non-API workloads (use only if all pods using it do not need the API) (run on any machine with kubectl access):
-
Verify compliance (run on any machine with kubectl access):
Ensure the output is
is_compliant=trueor that no remaining noncompliant Pods correspond to workloads that can safely disable token automount.
Using kubectl
Using kubectl
On any machine with kubectl access to the cluster:Edit Apply:
-
Identify a noncompliant pod and its owner (from the audit output), for example:
- Namespace:
prod - Pod name:
web-abc123 - Owner:
Deployment/prod/web
- Namespace:
- Export the owning workload manifest and edit it locally (example for a Deployment):
- In
/tmp/deployment-web.yaml, underspec.template.spec, setautomountServiceAccountToken: false. For example:
- Apply the updated manifest:
- If the pod is created directly (no controller), patch it in place (note: this recreates the pod, not the spec from a controller):
- If you choose to set this at the ServiceAccount instead (applies to all pods using it):
/tmp/sa-web-sa.yaml:- Verification (rerun the audit on any machine with kubectl access):
Automation
Automation

