Skip to main content

More Info:

Pods that automount service account tokens without needing them expand the attack surface. Token mounting should be disabled where API access is not required.

Risk Level

Medium

Address

Security

Compliance Standards

  • CIS GKE

Triage and Remediation

Remediation

Manual Steps

  1. Identify pods and service accounts that do not need API access
    • On any machine with kubectl access:
    • Based on application knowledge, list pods and service accounts that never call the Kubernetes API.
  2. Disable token automount on service accounts that do not need API access
    • On any machine with kubectl access, for each such service account:
    • For GitOps or manifest-based management, edit the ServiceAccount manifest and add:
      then apply:
  3. Disable token automount on pods that do not need API access (per‑pod override)
    • For standalone pods:
      (This affects the existing pod; ensure your controllers or manifests won’t immediately recreate it without the setting.)
  4. Disable token automount on controllers (Deployments, StatefulSets, DaemonSets, Jobs, CronJobs)
    • On any machine with kubectl access, for each controller whose workloads do not require API access:
    • Edit deployment.yaml and under spec.template.spec add:
    • Apply the change:
    • Repeat similarly for other controller kinds:
      Edit each file under spec.template.spec and add automountServiceAccountToken: false, then:
  5. Review for exceptions where API access is required
    • Confirm you did not change service accounts or pods that legitimately need to call the Kubernetes API (e.g., controllers, operators, metrics collectors).
    • For critical namespaces (like kube-system), review individually before applying changes:
  6. Verification
    • On any machine with kubectl access, re-run a refined audit to list only pods still mounting tokens:
    • Confirm that pods and service accounts which do not need API access no longer appear with automountServiceAccountToken set (either missing or true).
Update service accounts (preferred, so all attached pods default to no token unless overridden):
Update pod specs via their owning workload (Deployment/DaemonSet/StatefulSet/CronJob/Job):
Declarative manifest snippets (for future changes):
Apply manifests:
Verification (adapted from the audit):