More Info:
Default service accounts should not be granted permissions or used by workloads. Their tokens should not be auto-mounted.Risk Level
MediumAddress
SecurityCompliance Standards
- CIS Kubernetes
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Identify all default service accounts and their automount setting
- Run on: any machine with kubectl access
-
Review workloads currently using default service accounts and decide whether to change them
- Run on: any machine with kubectl access
- For any pod that is not a system or vendor-managed component and still uses the default service account, plan to create and assign a dedicated ServiceAccount with only the permissions it needs.
-
Create explicit service accounts for affected workloads (per namespace)
- Run on: any machine with kubectl access
- Example for one namespace (replace
NAMESPACEandAPP-SAwith your values):
- Update the corresponding RBAC (Roles/ClusterRoles and RoleBindings/ClusterRoleBindings) to grant only the minimum required permissions to
app-sa. For example:
-
Update workloads to stop using the default service account
- Run on: any machine with kubectl access
- Edit each affected workload (Deployment/StatefulSet/DaemonSet/CronJob/Job/Pod) to use the new explicit service account, e.g.:
- Under
spec.template.spec, set:
- Save and exit the editor; Kubernetes will roll out updated pods using the explicit service account.
-
Disable token automount on default service accounts
- Run on: any machine with kubectl access
- For each namespace that has a
defaultservice account:
- Repeat for all namespaces where you want to prevent automatic token mounting on the default service account.
-
Verify that default service accounts are no longer actively used and have automount disabled
- Run on: any machine with kubectl access
Using kubectl
Using kubectl
On any machine with kubectl access:Apply it:Apply:
- Export all existing default ServiceAccounts to manifests (for review and backup)
- Patch all existing default ServiceAccounts to disable token auto-mount
- (Optional) Enforce the setting declaratively for a specific namespace
sa-default-patch.yaml):- Ensure new or existing workloads do not rely on the default ServiceAccount
- Verification
Automation
Automation

