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