51 lines
1.6 KiB
YAML
51 lines
1.6 KiB
YAML
|
|
apiVersion: kyverno.io/v1
|
||
|
|
kind: ClusterPolicy
|
||
|
|
metadata:
|
||
|
|
name: deny-privileged
|
||
|
|
annotations:
|
||
|
|
policies.kyverno.io/title: Deny privileged containers
|
||
|
|
policies.kyverno.io/category: Pod Security
|
||
|
|
policies.kyverno.io/severity: high
|
||
|
|
policies.kyverno.io/description: >-
|
||
|
|
Flag containers with privileged: true. Host storage exporters should use
|
||
|
|
narrow capabilities instead of full privileged where possible.
|
||
|
|
spec:
|
||
|
|
validationFailureAction: Enforce
|
||
|
|
background: true
|
||
|
|
rules:
|
||
|
|
- name: deny-privileged-containers
|
||
|
|
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 not set privileged: true. Prefer drop ALL plus the
|
||
|
|
minimal capabilities and hostPaths required for the workload.
|
||
|
|
foreach:
|
||
|
|
- list: "request.object.spec.[initContainers, ephemeralContainers, containers][]"
|
||
|
|
deny:
|
||
|
|
conditions:
|
||
|
|
any:
|
||
|
|
- key: "{{ element.securityContext.privileged || false }}"
|
||
|
|
operator: Equals
|
||
|
|
value: true
|