Skip to main content

More Info:

The default service account should not be used to ensure that rights granted to applications can be more easily audited and reviewed.

Risk Level

Medium

Address

Security

Compliance Standards

  • CIS Kubernetes

Triage and Remediation

Remediation

Manual Steps

  1. List all default service accounts and their token mounting setting
    Run on: any machine with kubectl access
  2. Review workloads that currently use a default service account
    Run on: any machine with kubectl access
    For each namespace, list pods and their service accounts:
    Decide which workloads must access the API; plan to move those to explicit service accounts.
  3. Create explicit service accounts for workloads that need API access
    Run on: any machine with kubectl access
    For each namespace and workload that needs API access, create a dedicated service account, then bind appropriate RBAC (example for namespace my-namespace and service account app-sa):
    Adjust verbs/resources to your security requirements.
  4. Update workloads to stop using the default service account
    Run on: any machine with kubectl access
    For each deployment/statefulset/daemonset/etc. that should use a dedicated service account, patch the spec to set serviceAccountName explicitly (example for a deployment):
    Repeat for all workloads currently using the default service account that require API access.
  5. Disable token auto-mounting on all default service accounts
    Run on: any machine with kubectl access
    For each namespace that has a default service account, patch it to set automountServiceAccountToken: false:
  6. Verify that default service accounts are not actively used and have token mounting disabled
    Run on: any machine with kubectl access
    Confirm automountServiceAccountToken is false on all default service accounts:
    Confirm no pods are using default where that is not an intentional decision:

Additional Reading: