More Info:
Service account tokens are intended for workloads, not users, and provide weak user authentication. Use OIDC instead.Risk Level
HighAddress
SecurityCompliance Standards
- CIS Kubernetes
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
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/kubectlusingAuthorization: Bearer <token>where the token is from/var/run/secrets/kubernetes.io/serviceaccount/tokenor a long-lived SA secret.- Saved token files used for “user logins” to the API server.
- On any machine with access to your clusters and automation code, search your repos and scripts for common SA token usage patterns:
-
List all service accounts and check for suspicious “user-like” usage
- On any machine with
kubectlaccess, 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.
- On any machine with
-
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-fileor--authentication-token-webhook-config-fileindicating token-based user auth
- This does not by itself prove misuse, but it shows whether OIDC (preferred) is available as an alternative.
- On every control plane node, inspect the API server manifest to understand supported user auth methods:
-
Review kubeconfigs and access methods used by human users
- On any machine with
kubectlaccess, list configured contexts: - For each user entry, check the
usersection for:token:fields that are static, long-lived tokens (especially if they match SA tokens from step 2).auth-provider:orexec: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.
- On any machine with
-
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.
- For each identified human user or script using an SA token:
-
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:
- After migration, search again for SA token usage in user tools:
Using kubectl
Using kubectl
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.Automation
Automation

