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
MediumAddress
SecurityCompliance Standards
- CIS Kubernetes
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
List all default service accounts and their token mounting setting
Run on: any machine with kubectl access -
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. -
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 namespacemy-namespaceand service accountapp-sa):Adjust verbs/resources to your security requirements. -
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 setserviceAccountNameexplicitly (example for a deployment):Repeat for all workloads currently using thedefaultservice account that require API access. -
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 setautomountServiceAccountToken: false: -
Verify that default service accounts are not actively used and have token mounting disabled
Run on: any machine with kubectl access
ConfirmautomountServiceAccountTokenis false on all default service accounts:Confirm no pods are usingdefaultwhere that is not an intentional decision:
Using kubectl
Using kubectl
Automation
Automation

