Skip to main content

More Info:

Containers sharing the host PID namespace can view and interact with all processes on the node. Restrict admission of hostPID containers via namespace policies.

Risk Level

High

Address

Security

Compliance Standards

  • CIS EKS

Triage and Remediation

Remediation

Manual Steps

  1. List all namespaces that contain user workloads (exclude system namespaces)
    Run on: any machine with kubectl access
    Decide which namespaces should be protected (e.g., everything except kube-system, kube-public, kube-node-lease, etc.).
  2. For each target namespace, create or update a Pod Security admission label set to restricted (which forbids hostPID: true)
    Run on: any machine with kubectl access
    Replace <NAMESPACE> with the actual namespace name:
  3. Optionally add warnings/audit labels (recommended to catch violations before enforcement)
    Run on: any machine with kubectl access
  4. For clusters not using Pod Security Admission and instead using an existing Validating/MutatingWebhookPolicy controller (e.g., OPA Gatekeeper, Kyverno), create a policy in that system denying spec.hostPID: true in the target namespaces.
    Run on: any machine with kubectl access
    Example Kyverno policy manifest (save as deny-hostpid.yaml and apply):
    Apply it:
  5. Review and update existing manifests or Helm charts for user workloads to remove hostPID: true where it is not strictly required.
    • Search manifests locally:
    • For any Pod/Deployment/DaemonSet/etc. manifest that contains hostPID: true, edit the file and set:
    Then re-apply:
  6. Verification (no pods with hostPID: true should exist)
    Run on: any machine with kubectl access
    Confirm the output is: