Kubernetes automatically mounts ServiceAccount credentials in each ServiceAccount. The ServiceAccount may be assigned roles allowing Pods to access API resources. Blocking this ability is an extension of the least privilege best practice and should be followed if Pods do not need to speak to the API server to function. This policy ensures that mounting of these ServiceAccount tokens is blocked.
apiVersion: kyverno.io/v1kind: ClusterPolicymetadata:name: restrict-sa-automount-sa-tokenannotations:policies.kyverno.io/title: Restrict Auto-Mount of Service Account Tokens in Service Accountpolicies.kyverno.io/category: Securitykyverno.io/kyverno-version: 1.11.1kyverno.io/kubernetes-version: "1.27"policies.kyverno.io/severity: mediumpolicies.kyverno.io/subject: Secret,ServiceAccountpolicies.kyverno.io/description: "Kubernetes automatically mounts ServiceAccount credentials in each ServiceAccount. The ServiceAccount may be assigned roles allowing Pods to access API resources. Blocking this ability is an extension of the least privilege best practice and should be followed if Pods do not need to speak to the API server to function. This policy ensures that mounting of these ServiceAccount tokens is blocked. "spec:validationFailureAction: Auditbackground: truerules:- name: validate-sa-automountServiceAccountTokenmatch:any:- resources:kinds:- ServiceAccountvalidate:message: ServiceAccounts must set automountServiceAccountToken to false.pattern:automountServiceAccountToken: false
This policy performs some best practices validation on Application fields. Path or chart must be specified but never both. And destination.name or destination.server must be specified but never both.
This policy prevents the use of the default project in an Application.
This policy prevents updates to the project field after an Application is created.