← Policy catalog
</> ValidatingAdmissionPolicy · Apache-2.0

Shares a Process Namespace Between Containers

pod-share-process-namespace

severityModerate resourcePods productKubernetes bundles1

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.

Rejects unless

!has(object.spec.shareProcessNamespace) || object.spec.shareProcessNamespace == false

Sharing a process namespace is disallowed. spec.shareProcessNamespace must be undefined or set to false.

Remediation

Remove spec.shareProcessNamespace or set it to false. Field: spec.shareProcessNamespace.

Applies to

  • pods · v1 · CREATE, UPDATE

Manifest

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.

Validate with kubeapt

Check a workload against this one policy, before anything is installed on a cluster.

$ kubeapt validate -p ./pod-share-process-namespace.yaml -r ./workload.yaml

Or 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 ./manifests

Or against every namespace in the cluster your kubeconfig points at:

$ kubeapt validate --policy-name pod-share-process-namespace -A