54 lines
1.6 KiB
YAML
54 lines
1.6 KiB
YAML
|
|
apiVersion: kyverno.io/v1
|
||
|
|
kind: ClusterPolicy
|
||
|
|
metadata:
|
||
|
|
name: require-allow-privilege-escalation-false
|
||
|
|
annotations:
|
||
|
|
policies.kyverno.io/title: Require allowPrivilegeEscalation false
|
||
|
|
policies.kyverno.io/category: Pod Security
|
||
|
|
policies.kyverno.io/severity: medium
|
||
|
|
policies.kyverno.io/description: >-
|
||
|
|
Require every container to set allowPrivilegeEscalation: false (unset is a
|
||
|
|
fail).
|
||
|
|
spec:
|
||
|
|
validationFailureAction: Enforce
|
||
|
|
background: true
|
||
|
|
rules:
|
||
|
|
- name: require-allow-privilege-escalation-false
|
||
|
|
match:
|
||
|
|
any:
|
||
|
|
- resources:
|
||
|
|
kinds:
|
||
|
|
- Pod
|
||
|
|
exclude:
|
||
|
|
any:
|
||
|
|
- resources:
|
||
|
|
namespaces:
|
||
|
|
- kube-system
|
||
|
|
- kube-public
|
||
|
|
- kube-node-lease
|
||
|
|
- flux-system
|
||
|
|
- flux-canary
|
||
|
|
- kyverno
|
||
|
|
- cert-manager
|
||
|
|
- cilium-secrets
|
||
|
|
- olm
|
||
|
|
- operators
|
||
|
|
- longhorn
|
||
|
|
- openebs
|
||
|
|
- intel-system
|
||
|
|
- nfd
|
||
|
|
validate:
|
||
|
|
message: >-
|
||
|
|
Containers must set securityContext.allowPrivilegeEscalation: false
|
||
|
|
(leaving the field unset is not sufficient).
|
||
|
|
pattern:
|
||
|
|
spec:
|
||
|
|
=(initContainers):
|
||
|
|
- securityContext:
|
||
|
|
allowPrivilegeEscalation: false
|
||
|
|
=(ephemeralContainers):
|
||
|
|
- securityContext:
|
||
|
|
allowPrivilegeEscalation: false
|
||
|
|
containers:
|
||
|
|
- securityContext:
|
||
|
|
allowPrivilegeEscalation: false
|