Skip to main content

More Info:

Service account tokens are intended for workloads, not users, and provide weak user authentication. Use OIDC instead.

Risk Level

High

Address

Security

Compliance Standards

  • CIS Kubernetes

Triage and Remediation

Remediation

Manual Steps

  1. Identify any user-facing processes or scripts using service account tokens
    • On any machine with access to your clusters and automation code, search your repos and scripts for common SA token usage patterns:
    • Review CI/CD pipelines, jump-host scripts, and local dev scripts for:
      • curl/kubectl using Authorization: Bearer <token> where the token is from /var/run/secrets/kubernetes.io/serviceaccount/token or a long-lived SA secret.
      • Saved token files used for “user logins” to the API server.
  2. List all service accounts and check for suspicious “user-like” usage
    • On any machine with kubectl access, list SAs and related secrets:
    • For any SA that looks like a human user (names like alice, devops-john, admin-user), inspect annotations and usage:
    • Check if those SAs are referenced in kubeconfigs or scripts used by humans.
  3. Verify API server authentication configuration on each control plane node
    • On every control plane node, inspect the API server manifest to understand supported user auth methods:
    • In command: flags, note presence/absence of:
      • --oidc-issuer-url, --oidc-client-id, --oidc-username-claim, --oidc-groups-claim
      • Any --token-auth-file or --authentication-token-webhook-config-file indicating token-based user auth
    • This does not by itself prove misuse, but it shows whether OIDC (preferred) is available as an alternative.
  4. Review kubeconfigs and access methods used by human users
    • On any machine with kubectl access, list configured contexts:
    • For each user entry, check the user section for:
      • token: fields that are static, long-lived tokens (especially if they match SA tokens from step 2).
      • auth-provider: or exec: sections that use OIDC (preferred) or other stronger mechanisms.
    • Any kubeconfig distributed to humans that directly embeds an SA token should be flagged for remediation.
  5. Plan and implement migration from service account token usage to OIDC (or other approved user auth)
    • For each identified human user or script using an SA token:
      • Create or map to an identity in your IdP (e.g., OIDC provider).
      • Configure OIDC on the API server if not already present by adding flags in /etc/kubernetes/manifests/kube-apiserver.yaml (this will restart the API server when saved):
      • Update RBAC to bind roles to OIDC identities/groups instead of SAs:
      • Regenerate kubeconfigs or client auth flows so humans authenticate via OIDC (or your chosen strong method), not via SA tokens.
  6. Verify no human access depends on service account tokens
    • After migration, search again for SA token usage in user tools:
    • Confirm that any remaining token: entries are:
      • Bound only to non-human workloads, and
      • Not distributed outside the workload environment.
    • Optionally, rotate or delete any SA secrets previously used by humans:
kubectl cannot fix this finding because it requires changing the kube-apiserver configuration on each control plane node, specifically /etc/kubernetes/manifests/kube-apiserver.yaml, and configuring an alternative auth mechanism such as OIDC. Refer to the Manual Steps section for host-level remediation guidance on disabling user access via service account tokens and enabling OIDC-based authentication.