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
HighAddress
SecurityCompliance Standards
- CIS Kubernetes
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
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). -
Create a restrictive
PodSecurityPolicyorPod 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, enforcerestrictedon a namespace:Repeat for each user-workload namespace, adjusting names as needed. -
Bind the policy to user-workload namespaces (if using PSP) (any machine with kubectl access)
Repeat the
RoleBindingstanza for each user-workload namespace by changingnamespace:and thesystem:serviceaccounts:<namespace>group. -
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 withallow-hostpid=trueto exempt them. -
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 sethostPID: false, then apply:For standalone Pods, delete and recreate them from updated manifests withouthostPID: true. -
Verify no non-exempt Pods use hostPID (any machine with kubectl access)
Confirm that any
is_compliant: falsePods exist only in namespaces you have explicitly designated as allowed to use hostPID and that they are strictly necessary.
Using kubectl
Using kubectl
Automation
Automation

