More Info:
Default service accounts should not be used for workloads and should not automount tokens. Use dedicated service accounts scoped to only the permissions each workload needs.Risk Level
MediumAddress
SecurityCompliance Standards
- CIS AKS
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Identify namespaces using the default service account
- Run on: any machine with kubectl access
- Command (lists Pods that rely on the
defaultServiceAccount):
-
Review RBAC permissions granted to each namespace’s default ServiceAccount
- Run on: any machine with kubectl access
- Commands:
- Manually decide per namespace whether the default SA’s permissions are broader than needed for the Pods you found in step 1.
-
For each workload using a default ServiceAccount, design a dedicated ServiceAccount and RBAC
- For each
(namespace, pod)from step 1, decide:- What minimal API access (if any) the workload truly needs.
- Whether some Pods need no API access at all.
- Plan either:
- A new ServiceAccount with no extra permissions (
Role/ClusterRole& binding only if needed), or - The Pod running with
automountServiceAccountToken: falseif it doesn’t need any Kubernetes API access.
- A new ServiceAccount with no extra permissions (
- For each
-
Create dedicated ServiceAccounts and RBAC objects
- Run on: any machine with kubectl access
- Example template (adjust
NAMESPACE, names, and rules): - Update each workload manifest to set
spec.serviceAccountName: app-saand, where applicable,automountServiceAccountToken: falseif no API access is needed.
-
Disable token automounting for all default ServiceAccounts
- Run on: any machine with kubectl access
- Command:
- Verify:
-
Re-verify that no workloads rely on default ServiceAccounts and document exceptions
- Run on: any machine with kubectl access
- Command:
- Investigate any remaining Pods listed; either migrate them to dedicated ServiceAccounts or formally document and approve them as exceptions with a clear justification.
Using kubectl
Using kubectl
Using kubectl
Run these on any machine withkubectl access.1. List all default service accounts and their token automount setting
true(or blank/null, which means it inherits the namespace/pod default oftrue): the default SA in that namespace may be used by workloads and will get tokens by default. This is a risk and should be reviewed.false: the default SA is configured not to automount tokens; this is the recommended baseline.
true, the default SA in that namespace is not hardened.2. Identify pods that are using the default service account
List all pods with their namespace and service account:- Rows where
SERVICEACCOUNTisdefault(or empty, which means it defaults todefaultSA) indicate workloads actively using the default service account. Each such pod should be reviewed to see if it should instead use a dedicated, least-privilege service account.
.spec.serviceAccountNameor.spec.serviceAccount:defaultor omitted → using the default SA (needs review).- custom name → confirm that custom SA has only necessary permissions.
3. Check if pods using the default SA are actually mounting tokens
For all pods using the default SA in a namespace:- If the pod line shows
trueor is blank (and the namespace/SA defaults totrue), the pod is getting a service account token mounted; combined with use of the default SA, this is a configuration needing human review. - If it shows
false, the pod is not mounting a token despite using the default SA (lower risk, but still consider moving to a dedicated SA).
projected or secret volume for a service account token indicates the pod is using a token.4. Review RBAC permissions granted to the default service account
For each namespace with pods using the default SA, inspect RBAC bindings:- Any
RoleBindingorClusterRoleBindingthat grants non-trivial permissions (e.g.,edit,admin, custom roles with many verbs/resources) toServiceAccount/defaultis a red flag. - Such bindings, combined with pods using the default SA, indicate the default SA is actively used with elevated privileges and should be redesigned to use dedicated service accounts.
Automation
Automation

