Skip to main content

More Info:

Default service accounts should not be granted permissions or actively used by workloads. Create explicit service accounts and disable token automounting on default accounts.

Risk Level

Medium

Address

Security

Compliance Standards

  • CIS OKE

Triage and Remediation

Remediation

Manual Steps

  1. From any machine with kubectl access, list all namespaces and identify which have a default service account using tokens:
  2. For each namespace, identify workloads that are implicitly or explicitly using the default service account:
    Review pods that show an empty serviceAccountName (implicitly default) or serviceAccountName: default to determine whether they truly need API access.
  3. For pods using the default service account, inspect their specs for explicit token mounting or inherited defaults:
    Decide whether each workload needs Kubernetes API access and, if so, what minimum permissions it needs.
  4. Where workloads require API access, design explicit, least-privilege service accounts and RBAC:
    Update the corresponding Deployment/StatefulSet/Job manifests to set spec.template.spec.serviceAccountName: <sa-name> and, if needed, automountServiceAccountToken: true there instead of relying on defaults.
  5. After migrating workloads off the default service account in a namespace, disable token automount on that default account:
    If using GitOps/manifests, ensure the same setting is defined in the ServiceAccount manifest rather than patching only live state.
  6. Verify that:
    • No workloads are using the default service account except where consciously accepted, and
    • All default service accounts have token automount disabled:
Problem indication:
  • Every namespace will have a default ServiceAccount; that alone is not an issue.
  • Note any namespaces where workloads exist and you expect them to use dedicated service accounts instead of default.

Problem indication:
  • automountServiceAccountToken: true (explicit) on a default ServiceAccount is a concern.
  • Missing automountServiceAccountToken means it inherits from pod spec / cluster defaults; treat as needing review.
  • Tokens listed under secrets: confirm token creation, but not necessarily active use.

Problem indication:
  • Any pod where the third column is default is actively using the default ServiceAccount.
  • Focus on namespaces with sensitive workloads or where API access should be tightly scoped.

Problem indication:
  • true means the pod is set to mount a token.
  • null means it may inherit from the ServiceAccount (or cluster default); requires manual review of both pod and SA.
If jq is not available, inspect specific pods:
Problem indication in pod YAML:
  • spec.serviceAccountName: default AND
  • spec.automountServiceAccountToken: true (or absent when SA/cluster default is true) AND
  • A projected service account token volume in spec.volumes or a token under /var/run/secrets/kubernetes.io/serviceaccount.

Problem indication:
  • Any RoleBinding or ClusterRoleBinding whose subjects include:
    • kind: ServiceAccount
    • name: default
    • plus a namespace: value
  • Especially concerning if bound to powerful Role/ClusterRole (e.g., cluster-admin, broad * verbs/resources).

Problem indication:
  • Any line returned indicates a default ServiceAccount is granted explicit RBAC permissions.
  • The more privileged the referenced Role/ClusterRole, the higher the concern.
Use these outputs to decide:
  • Where new, explicit ServiceAccounts should be created.
  • Where to stop using default in pod specs.
  • Where automountServiceAccountToken: false should be set on default ServiceAccounts and/or pods.