Red Hat OpenShift
TMA-OPENSHIFT-5.1.6
Ensure that Service Account Tokens are only mounted where necessary
Description
Service accounts tokens should not be mounted in pods except where the workload running in the pod explicitly needs to communicate with the API server The benchmark marks this recommendation Manual.
How it is checked
Audit method: Manual review
Review pod and service account objects in the cluster and ensure automatically mounting the service account token is disabled (automountServiceAccountToken: false), unless the resource explicitly requires this access. Find all pods that automatically mount service account tokens: oc get pods -A -o json | jq '.items[] | select(.spec.automountServiceAccountToken) | .metadata.name' Find all service accounts that automatically mount service tokens: oc get serviceaccounts -A -o json | jq '.items[] | select(.automountServiceAccountToken) | .metadata.name'
How it is fixed
Fix method: Guidance or infrastructure patch
Modify the definition of pods and service accounts which do not need to mount service account tokens to disable it.
Properties
- Operating systems
- Any
- Tags
- openshiftpoliciesrbac
- Reference
- CIS Red Hat OpenShift Container Platform Benchmark v2.0.0 - 5.1.6 Ensure that Service Account Tokens are only mounted where necessary