pod-share-process-namespace
A shared process namespace lets every container in the pod inspect and signal the others, reading secrets from sibling command lines and /proc environment files, so compromising one sidecar reaches them all.
!has(object.spec.shareProcessNamespace) || object.spec.shareProcessNamespace == false
Sharing a process namespace is disallowed. spec.shareProcessNamespace must be undefined or set to false.
Remove spec.shareProcessNamespace or set it to false. Field: spec.shareProcessNamespace.
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
name: pod-share-process-namespace
annotations:
kubeapt.io/uuid: "a317749c-d7dc-4c9c-b549-ffad9806c111"
security.kubeapt.io/displayName: "Shares a Process Namespace Between Containers"
security.kubeapt.io/description: "A shared process namespace lets every container in the pod inspect and signal the others, reading secrets from sibling command lines and /proc environment files, so compromising one sidecar reaches them all."
security.kubeapt.io/resource: "Pods"
security.kubeapt.io/severity: "Moderate"
security.kubeapt.io/remediation: "Remove spec.shareProcessNamespace or set it to false. Field: spec.shareProcessNamespace."
security.kubeapt.io/product: "Kubernetes"
spec:
failurePolicy: Fail
matchConstraints:
resourceRules:
- apiGroups:
- ''
apiVersions:
- v1
operations:
- CREATE
- UPDATE
resources:
- pods
validations:
- expression: |
!has(object.spec.shareProcessNamespace) || object.spec.shareProcessNamespace == false
message: |
Sharing a process namespace is disallowed. spec.shareProcessNamespace must be undefined or set to false.Save it as pod-share-process-namespace.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-share-process-namespace.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-share-process-namespace -r ./manifestsOr against every namespace in the cluster your kubeconfig points at:
$ kubeapt validate --policy-name pod-share-process-namespace -A