Skip to main content

More Info:

Sharing the host PID namespace lets a container see and interact with all host processes, aiding escape and escalation. Restrict hostPID pods.

Risk Level

High

Address

Security

Compliance Standards

  • CIS Kubernetes

Triage and Remediation

Remediation

Manual Steps

  1. List and review current Pods using hostPID (any machine with kubectl access)
    For each listed Pod, decide if host PID access is strictly required. If not, plan to remove it; if yes, note the namespace so you can design exception policies (e.g., via labels).
  2. Create a restrictive PodSecurityPolicy or Pod Security Standards-style control (if PSP still in use) (any machine with kubectl access)
    If you still use PodSecurityPolicy, create one that forbids hostPID:
    If your cluster instead uses Pod Security Admission (PSA), apply a namespace-level policy that disallows host namespaces. For example, enforce restricted on a namespace:
    Repeat for each user-workload namespace, adjusting names as needed.
  3. Bind the policy to user-workload namespaces (if using PSP) (any machine with kubectl access)
    Repeat the RoleBinding stanza for each user-workload namespace by changing namespace: and the system:serviceaccounts:<namespace> group.
  4. Tighten admission using a validating admission policy (if PSA/PSP are not applicable) (any machine with kubectl access)
    If you rely on a generic admission controller (e.g., ValidatingAdmissionPolicy in newer Kubernetes), create a policy that rejects hostPID Pods, then selectively exempt namespaces that truly require it:
    Implement the webhook to reject any Pod with .spec.hostPID == true. Label only the namespaces that genuinely require hostPID with allow-hostpid=true to exempt them.
  5. Update or recreate non-essential hostPID Pods without hostPID (any machine with kubectl access)
    For any Pod/Deployment/DaemonSet/Job where hostPID is not strictly required, edit the manifest to remove or set hostPID: false, then apply:
    For standalone Pods, delete and recreate them from updated manifests without hostPID: true.
  6. Verify no non-exempt Pods use hostPID (any machine with kubectl access)
    Confirm that any is_compliant: false Pods exist only in namespaces you have explicitly designated as allowed to use hostPID and that they are strictly necessary.