# Enforced everywhere except the namespaces listed under exclude. Every entry # there is a place an attacker can create a privileged pod, so keep it short # and review it like a firewall rule. --- apiVersion: kyverno.io/v1 kind: ClusterPolicy metadata: name: pod-security-baseline annotations: policies.kyverno.io/description: Refuses privileged pods, host paths, and host namespaces. spec: background: true rules: - name: no-privileged match: any: - resources: kinds: [Pod] exclude: any: - resources: namespaces: [kube-system, kyverno, falco] validate: failureAction: Enforce message: "Privileged mode is not allowed." pattern: spec: =(ephemeralContainers): - =(securityContext): =(privileged): "false" =(initContainers): - =(securityContext): =(privileged): "false" containers: - =(securityContext): =(privileged): "false" - name: no-host-path match: any: - resources: kinds: [Pod] exclude: any: - resources: namespaces: [kube-system, kyverno, falco] validate: failureAction: Enforce message: "hostPath volumes are not allowed." pattern: spec: =(volumes): - X(hostPath): "null" - name: no-host-namespaces match: any: - resources: kinds: [Pod] exclude: any: - resources: namespaces: [kube-system, kyverno, falco] validate: failureAction: Enforce message: "hostPID, hostIPC, and hostNetwork are not allowed." pattern: spec: =(hostPID): "false" =(hostIPC): "false" =(hostNetwork): "false"