container-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 container and easing container escape.
object.spec.containers.all(c,
!has(c.securityContext) ||
!has(c.securityContext.procMount) ||
c.securityContext.procMount == "Default"
)
spec.containers[*].securityContext.procMount must be undefined or "Default".
Remove securityContext.procMount from every container or set it back to Default instead of Unmasked. Field: spec.containers[*].securityContext.procMount.
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
name: container-procmount
annotations:
kubeapt.io/uuid: "0ceb2a31-3447-4a3c-9e67-ea7fbb65f581"
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 container and easing container escape."
security.kubeapt.io/resource: "Containers"
security.kubeapt.io/severity: "High"
security.kubeapt.io/remediation: "Remove securityContext.procMount from every container or set it back to Default instead of Unmasked. Field: spec.containers[*].securityContext.procMount."
security.kubeapt.io/product: "Kubernetes"
spec:
failurePolicy: Fail
matchConstraints:
resourceRules:
- apiGroups:
- ''
apiVersions:
- v1
operations:
- CREATE
- UPDATE
resources:
- pods
validations:
- expression: |
object.spec.containers.all(c,
!has(c.securityContext) ||
!has(c.securityContext.procMount) ||
c.securityContext.procMount == "Default"
)
message: |
spec.containers[*].securityContext.procMount must be undefined or "Default".Save it as container-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 ./container-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 container-procmount -r ./manifestsOr against every namespace in the cluster your kubeconfig points at:
$ kubeapt validate --policy-name container-procmount -A