More Info:
Advisory: avoid long-lived ServiceAccount token Secrets; use projected (TokenRequest) tokens with an audience and expiry instead.Risk Level
InformationalAddress
SecurityCompliance Standards
- Cloudanix Best Practice
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
List all ServiceAccount token Secrets and map them to identities
- On any machine with kubectl access:
- Record which applications (Deployments/Pods) use each ServiceAccount.
- On any machine with kubectl access:
-
Identify workloads actually mounting these token Secrets
- On any machine with kubectl access:
- Flag Pods where a
secretvolume mounts a ServiceAccount token Secret.
- On any machine with kubectl access:
-
Decide whether each workload actually needs a Kubernetes API token
- For each flagged Pod/Deployment, review its code/configuration to see if it calls the Kubernetes API.
- If it does not need API access, plan to:
- Remove the ServiceAccount reference (fall back to
defaultonly if default SA is locked down), and - Ensure no
secretvolume or env var uses a ServiceAccount token Secret.
- Remove the ServiceAccount reference (fall back to
-
Migrate workloads that do need API access to use projected tokens
- For each workload that truly needs a token, update the Pod spec (Deployment/StatefulSet/Job, etc.) to use a projected ServiceAccount token volume with audience and expiry, instead of a
secretvolume. Example pattern (adapt to your manifest): - Apply the change on any machine with kubectl access:
- For each workload that truly needs a token, update the Pod spec (Deployment/StatefulSet/Job, etc.) to use a projected ServiceAccount token volume with audience and expiry, instead of a
-
Clean up legacy ServiceAccount token Secrets once unused
- After updating workloads and confirming they run correctly, check whether a token Secret is still referenced:
- For any ServiceAccount token Secret no longer referenced by Pods and not needed for external systems, delete it:
- After updating workloads and confirming they run correctly, check whether a token Secret is still referenced:
-
Re-verify and document exceptions
- On any machine with kubectl access, re-run:
- For any remaining ServiceAccount token Secrets, document:
- Which workload or external system uses them,
- Why projected tokens cannot be used yet, and
- A plan or decision to accept the residual risk.
- On any machine with kubectl access, re-run:
Using kubectl
Using kubectl
kubernetes.io/service-account-token Secrets, especially in application namespaces, indicates widespread use of long‑lived SA token Secrets and is a concern.type: kubernetes.io/service-account-token- Mounted in Pods as a volume (see step 3)
- No process in place to rotate or prune these Secrets.
secretName matches names from step 1 show Pods mounting SA token Secrets explicitly. These Pods should be reviewed to migrate to projected tokens (TokenRequest) via projected volumes.automountServiceAccountTokenis empty (inheritstruefrom the ServiceAccount) or explicitlytruefor Pods in application namespaces, meaning they get a long‑lived token mounted unless the SA is configured otherwise.
- ServiceAccounts in application namespaces with
automountServiceAccountToken: trueor unset (defaults to true), combined with use in Pods from step 4.
- Token Secrets with very old
CREATEDtimestamps that are still referenced by running Pods or external systems.
- Which Pods/Workloads still depend on classic SA token Secrets.
- Where you can disable automatic SA token mounting and refactor to projected tokens with explicit audiences and expiries.
Automation
Automation

