Skip to main content

More Info:

Default service accounts should not be actively used by workloads and should have token automounting disabled. Use explicit service accounts scoped to each workloads needs.

Risk Level

Medium

Address

Security

Compliance Standards

  • CIS EKS

Triage and Remediation

Remediation

Manual Steps

  1. Identify all default service accounts and namespaces
    Run on: any machine with kubectl access
  2. Disable token automount on every default service account
    Run on: any machine with kubectl access
    (Run once per namespace; default, kube-system, and any others in use.)
  3. List pods currently using the default service account
    Run on: any machine with kubectl access
  4. Create explicit service accounts for workloads that need API access
    Run on: any machine with kubectl access
    (Example for one namespace; repeat as needed, adjusting names and namespaces.)
  5. Update workloads to use the explicit service accounts and (optionally) disable pod-level automount
    Run on: any machine with kubectl access
    Edit each deployment/statefulset/cronjob/etc. that currently uses serviceAccountName: default:
    In .spec.template.spec:
  6. Verification
    Run on: any machine with kubectl access
On any machine with kubectl access:
  1. Disable token automounting on all existing default ServiceAccounts
  1. For workloads that need API access, create explicit ServiceAccounts and use them in Pod specs
Example (save as sa-and-deployment.yaml and apply):
Apply:
  1. Optionally, prevent default use in new workloads by setting an explicit ServiceAccount in your own pod/deployment manifests and avoiding serviceAccountName: default.
  2. Verification