Skip to main content

More Info:

Assign each pod a dedicated service account instead of relying on the default service account, so that permissions can be scoped per workload.

Risk Level

Medium

Address

Security

Compliance Standards

  • CIS OKE

Triage and Remediation

Remediation

Manual Steps

  1. List all workloads and their service accounts
    • Run on: any machine with kubectl access
    • Command (per namespace; start with production namespaces):
    • Identify pods where SA is empty or default, especially for internet-facing, privileged, or data-sensitive workloads.
  2. Review namespace-level usage of the default service account
    • Run on: any machine with kubectl access
    • Commands:
    • Decide per namespace whether the default service account is (a) unused and should stay unprivileged, or (b) used by many workloads and should be replaced with per-workload service accounts.
  3. Design dedicated service accounts and permissions (IaC / control-plane configuration)
    • In your cloud/IaC configuration (e.g., Helm values, Terraform, CD pipeline manifests, or cloud console workload configuration screens), for each application:
      • Define a dedicated ServiceAccount object name (e.g., orders-api-sa).
      • Bind that service account only to the minimal Role/ClusterRole needed.
    • Example manifest snippet to model in IaC (do not apply with kubectl if you manage via IaC):
  4. Update workload definitions to use dedicated service accounts
    • In your cloud provider console, CLI, or IaC for each deployment/statefulset/cronjob:
      • Set spec.template.spec.serviceAccountName to the dedicated service account.
    • Example pod template snippet for IaC/console:
    • Redeploy workloads via your normal CI/CD or cloud provider deployment mechanism.
  5. Optionally restrict the default service account
    • In namespaces where dedicated service accounts are now used for all meaningful workloads:
      • Ensure the default service account has no elevated RoleBinding/ClusterRoleBinding. Remove or adjust bindings in IaC/cloud console where they reference default.
    • If your provider supports toggling “automount service account token” at namespace or service account level, disable it for default where practical.
  6. Verify that dedicated service accounts are in use
    • Run on: any machine with kubectl access
    • Commands:
      Confirm that all non-trivial workloads show a specific, non-default service account. For a spot check, inspect a pod’s full spec:
kubectl cannot remediate this finding because it concerns how workloads are defined and deployed in your cloud provider / IaC configuration, not a one-off API change. Make the changes in your cloud console, CI/CD pipeline, or IaC templates to assign explicit, non-default service accounts to pods, and follow the guidance in the Manual Steps section to review and update those definitions.
How to interpret the output
  • Any line in the first table shows a pod currently using the default service account in its namespace.
  • Namespaces with a non-zero pods_using_default_sa count in the summary need review.
  • For each such pod, decide (manually) whether:
    • It is acceptable for it to use the namespace’s default service account with its current RBAC, or
    • You should create and assign a dedicated, least-privilege service account via your cloud/IaC configuration.