pod-hostipc
Sharing the host IPC namespace exposes the node shared memory segments, semaphores and message queues to the container, letting it read in-memory data and tamper with host processes and other pods that share it.
!has(object.spec.hostIPC) || object.spec.hostIPC == false
Using hostIPC is disallowed. spec.hostIPC must be undefined or set to false.
Remove spec.hostIPC or set it to false. Field: spec.hostIPC.
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
name: pod-hostipc
annotations:
kubeapt.io/uuid: "29c502b6-a8aa-4cd7-a309-482332dd9a52"
security.kubeapt.io/displayName: "Shares the Host IPC Namespace"
security.kubeapt.io/description: "Sharing the host IPC namespace exposes the node shared memory segments, semaphores and message queues to the container, letting it read in-memory data and tamper with host processes and other pods that share it."
security.kubeapt.io/resource: "Pods"
security.kubeapt.io/severity: "High"
security.kubeapt.io/remediation: "Remove spec.hostIPC or set it to false. Field: spec.hostIPC."
security.kubeapt.io/product: "Kubernetes"
spec:
failurePolicy: Fail
matchConstraints:
resourceRules:
- apiGroups:
- ''
apiVersions:
- v1
operations:
- CREATE
- UPDATE
resources:
- pods
validations:
- expression: |
!has(object.spec.hostIPC) || object.spec.hostIPC == false
message: |
Using hostIPC is disallowed. spec.hostIPC must be undefined or set to false.Save it as pod-hostipc.yaml — the commands below assume that name.
Check a workload against this one policy, before anything is installed on a cluster.
$ kubeapt validate -p ./pod-hostipc.yaml -r ./workload.yamlOr without the file, from the published policy set — -r takes a directory too:
$ kubeapt policies download && kubeapt validate --policy-name pod-hostipc -r ./manifestsOr against every namespace in the cluster your kubeconfig points at:
$ kubeapt validate --policy-name pod-hostipc -A