Skip to main content

More Info:

Default service accounts should not be used for workloads and should not automount tokens. Use dedicated service accounts scoped to only the permissions each workload needs.

Risk Level

Medium

Address

Security

Compliance Standards

  • CIS AKS

Triage and Remediation

Remediation

Manual Steps

  1. Identify namespaces using the default service account
    • Run on: any machine with kubectl access
    • Command (lists Pods that rely on the default ServiceAccount):
  2. Review RBAC permissions granted to each namespace’s default ServiceAccount
    • Run on: any machine with kubectl access
    • Commands:
    • Manually decide per namespace whether the default SA’s permissions are broader than needed for the Pods you found in step 1.
  3. For each workload using a default ServiceAccount, design a dedicated ServiceAccount and RBAC
    • For each (namespace, pod) from step 1, decide:
      • What minimal API access (if any) the workload truly needs.
      • Whether some Pods need no API access at all.
    • Plan either:
      • A new ServiceAccount with no extra permissions (Role/ClusterRole & binding only if needed), or
      • The Pod running with automountServiceAccountToken: false if it doesn’t need any Kubernetes API access.
  4. Create dedicated ServiceAccounts and RBAC objects
    • Run on: any machine with kubectl access
    • Example template (adjust NAMESPACE, names, and rules):
    • Update each workload manifest to set spec.serviceAccountName: app-sa and, where applicable, automountServiceAccountToken: false if no API access is needed.
  5. Disable token automounting for all default ServiceAccounts
    • Run on: any machine with kubectl access
    • Command:
    • Verify:
  6. Re-verify that no workloads rely on default ServiceAccounts and document exceptions
    • Run on: any machine with kubectl access
    • Command:
    • Investigate any remaining Pods listed; either migrate them to dedicated ServiceAccounts or formally document and approve them as exceptions with a clear justification.

Using kubectl

Run these on any machine with kubectl access.

1. List all default service accounts and their token automount setting

Interpretation:
  • true (or blank/null, which means it inherits the namespace/pod default of true): the default SA in that namespace may be used by workloads and will get tokens by default. This is a risk and should be reviewed.
  • false: the default SA is configured not to automount tokens; this is the recommended baseline.
To see the full object for a specific namespace:
Look for:
If this field is missing or true, the default SA in that namespace is not hardened.

2. Identify pods that are using the default service account

List all pods with their namespace and service account:
Interpretation:
  • Rows where SERVICEACCOUNT is default (or empty, which means it defaults to default SA) indicate workloads actively using the default service account. Each such pod should be reviewed to see if it should instead use a dedicated, least-privilege service account.
For more detail in a specific namespace:
Check:
  • .spec.serviceAccountName or .spec.serviceAccount:
    • default or omitted → using the default SA (needs review).
    • custom name → confirm that custom SA has only necessary permissions.

3. Check if pods using the default SA are actually mounting tokens

For all pods using the default SA in a namespace:
Interpretation:
  • If the pod line shows true or is blank (and the namespace/SA defaults to true), the pod is getting a service account token mounted; combined with use of the default SA, this is a configuration needing human review.
  • If it shows false, the pod is not mounting a token despite using the default SA (lower risk, but still consider moving to a dedicated SA).
To confirm token volume mounts on a specific pod:
Presence of a projected or secret volume for a service account token indicates the pod is using a token.

4. Review RBAC permissions granted to the default service account

For each namespace with pods using the default SA, inspect RBAC bindings:
Filter bindings that reference the default SA:
Interpretation:
  • Any RoleBinding or ClusterRoleBinding that grants non-trivial permissions (e.g., edit, admin, custom roles with many verbs/resources) to ServiceAccount/default is a red flag.
  • Such bindings, combined with pods using the default SA, indicate the default SA is actively used with elevated privileges and should be redesigned to use dedicated service accounts.