initcontainer-procmount
An unmasked /proc strips the default masks and read-only paths the runtime applies, exposing kernel memory and tunables such as /proc/kcore and /proc/sys to the init container and easing container escape.
!has(object.spec.initContainers) || object.spec.initContainers.all(ic,
!has(ic.securityContext) ||
!has(ic.securityContext.procMount) ||
ic.securityContext.procMount == "Default"
)
spec.initContainers[*].securityContext.procMount must be undefined or "Default".
Remove securityContext.procMount from every init container or set it back to Default instead of Unmasked. Field: spec.initContainers[*].securityContext.procMount.
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
name: initcontainer-procmount
annotations:
kubeapt.io/uuid: "5de6bf0d-2a03-45c3-91ce-197bced1ee21"
security.kubeapt.io/displayName: "Uses an Unmasked /proc Mount"
security.kubeapt.io/description: "An unmasked /proc strips the default masks and read-only paths the runtime applies, exposing kernel memory and tunables such as /proc/kcore and /proc/sys to the init container and easing container escape."
security.kubeapt.io/resource: "InitContainers"
security.kubeapt.io/severity: "High"
security.kubeapt.io/remediation: "Remove securityContext.procMount from every init container or set it back to Default instead of Unmasked. Field: spec.initContainers[*].securityContext.procMount."
security.kubeapt.io/product: "Kubernetes"
spec:
failurePolicy: Fail
matchConstraints:
resourceRules:
- apiGroups:
- ''
apiVersions:
- v1
operations:
- CREATE
- UPDATE
resources:
- pods
validations:
- expression: |
!has(object.spec.initContainers) || object.spec.initContainers.all(ic,
!has(ic.securityContext) ||
!has(ic.securityContext.procMount) ||
ic.securityContext.procMount == "Default"
)
message: |
spec.initContainers[*].securityContext.procMount must be undefined or "Default".Save it as initcontainer-procmount.yaml — the commands below assume that name.
Check a workload against this one policy, before anything is installed on a cluster.
$ kubeapt validate -p ./initcontainer-procmount.yaml -r ./workload.yamlOr without the file, from the published policy set — -r takes a directory too:
$ kubeapt policies download && kubeapt validate --policy-name initcontainer-procmount -r ./manifestsOr against every namespace in the cluster your kubeconfig points at:
$ kubeapt validate --policy-name initcontainer-procmount -A