Automatic service account token mounting not disabled

Automatically mounting service account tokens in Pods that do not need them unnecessarily exposes Kubernetes API credentials.

Description

Set automountServiceAccountToken: false on Pods that need no Kubernetes API token. A Pod inherits the ServiceAccount setting when its own value is absent. An explicit Pod value takes precedence.

Potential impact

An unneeded token exposed through an application or a debugging tool can be used with the account’s API permissions.

Remediation

Check the volume mounts on a newly created Pod. For workloads that need tokens, assign a dedicated ServiceAccount and grant only the required permissions.

Examples

Before

yaml
apiVersion: v1
kind: Pod
metadata:
  name: security.context.demo
spec:
  automountServiceAccountToken: true
  containers:
    - name: sec-ctx-demo
      image: busybox

After

yaml
apiVersion: v1
kind: Pod
metadata:
  name: security-context-demo
spec:
  automountServiceAccountToken: false
  containers:
    - name: sec-ctx-demo
      image: busybox

Explanation:

  • Before: true enables automatic mounting of the service account token on this Pod.
  • After: false disables automounting on the new Pod. Also check the account’s RBAC permissions and any credentials supplied separately.

References