apiVersion: kyverno.io/v1 kind: ClusterPolicy metadata: name: disallow-automount-sa-token annotations: policies.kyverno.io/title: Disallow Automount Service Account Token policies.kyverno.io/category: DoD STIG policies.kyverno.io/severity: medium policies.kyverno.io/description: >- STIG V-242382: Pods that do not need to communicate with the Kubernetes API server should have automountServiceAccountToken set to false to prevent credential exposure. pod-policies.kyverno.io/autogen-controllers: none spec: validationFailureAction: Audit background: true rules: - name: validate-automount skipBackgroundRequests: true match: any: - resources: kinds: - Pod exclude: any: - resources: namespaces: - kube-system - kube-public - kube-node-lease - kyverno - istio-system - cert-manager - cnpg-system - external-secrets - vault - rook-ceph - prometheus - argocd - envoy-gateway-system - kiali-operator - mariadb-system - redis-operator - reloader - scylla-operator - crowdsec - external-dns - frigate - gitlab - grafana - guacamole - home-assistant - mqtt - netbird - nextcloud - teslamate - unpoller - authentik - checkov - n8n - nessus validate: allowExistingViolations: true message: >- Pods should set automountServiceAccountToken to false unless API access is required (STIG V-242382). pattern: spec: automountServiceAccountToken: false