Skip to main content

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

Medium

Address

Security

Compliance Standards

  • Cloudanix Best Practice

Triage and Remediation

Remediation

Manual Steps

  1. 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.
  2. For workloads managed by controllers (Deployment/StatefulSet/DaemonSet/Job/CronJob), edit the controller to set automountServiceAccountToken: false at the pod spec level (run on any machine with kubectl access):
    In the opened manifest, under spec.template.spec, add or change:
    Save and exit; Kubernetes will roll out updated pods.
  3. 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.yaml and under spec add:
    Then delete and re-create:
  4. 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.
  5. 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.
  6. Verify remediation (run on any machine with kubectl access):
    Confirm the output is is_compliant=true or that remaining flagged pods are those you intentionally allowed to keep tokens.
On any machine with kubectl access to the cluster:
  1. Identify one non‑compliant pod (example):
  1. Get the owning workload and current pod spec:
Check .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.
  1. Patch a Deployment to disable token automount for pods that do not need the API (example for a Deployment owner):
For other controllers, replace deployment with statefulset, daemonset, job, or cronjob as appropriate.
  1. If the pod is standalone (no ownerReferences), edit the Pod manifest source and re‑apply it declaratively. Example manifest snippet:
Apply it:
  1. Verification (matches the audit intent):