Skip to main content

More Info:

Default service accounts should not be granted permissions or used by workloads. Their tokens should not be auto-mounted.

Risk Level

Medium

Address

Security

Compliance Standards

  • CIS Kubernetes

Triage and Remediation

Remediation

Manual Steps

  1. Identify all default service accounts and their automount setting
    • Run on: any machine with kubectl access
  2. Review workloads currently using default service accounts and decide whether to change them
    • Run on: any machine with kubectl access
    • For any pod that is not a system or vendor-managed component and still uses the default service account, plan to create and assign a dedicated ServiceAccount with only the permissions it needs.
  3. Create explicit service accounts for affected workloads (per namespace)
    • Run on: any machine with kubectl access
    • Example for one namespace (replace NAMESPACE and APP-SA with your values):
    • Update the corresponding RBAC (Roles/ClusterRoles and RoleBindings/ClusterRoleBindings) to grant only the minimum required permissions to app-sa. For example:
  4. Update workloads to stop using the default service account
    • Run on: any machine with kubectl access
    • Edit each affected workload (Deployment/StatefulSet/DaemonSet/CronJob/Job/Pod) to use the new explicit service account, e.g.:
    • Under spec.template.spec, set:
    • Save and exit the editor; Kubernetes will roll out updated pods using the explicit service account.
  5. Disable token automount on default service accounts
    • Run on: any machine with kubectl access
    • For each namespace that has a default service account:
    • Repeat for all namespaces where you want to prevent automatic token mounting on the default service account.
  6. Verify that default service accounts are no longer actively used and have automount disabled
    • Run on: any machine with kubectl access
On any machine with kubectl access:
  1. Export all existing default ServiceAccounts to manifests (for review and backup)
  1. Patch all existing default ServiceAccounts to disable token auto-mount
  1. (Optional) Enforce the setting declaratively for a specific namespace
Example manifest (save as sa-default-patch.yaml):
Apply it:
  1. Ensure new or existing workloads do not rely on the default ServiceAccount
For each deployment/statefulset/cronjob/etc., set an explicit non-default ServiceAccount and (optionally) disable auto-mount at pod level. Example manifest snippet:
Apply:
  1. Verification