More Info:
Do not generally permit containers to be run with the hostPID flag set to true.Risk Level
HighAddress
SecurityCompliance Standards
- CIS Kubernetes
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Identify pods using
hostPID: true(any machine with kubectl access) -
Review and decide which workloads are allowed to use
hostPID(any machine with kubectl access)
For each non-compliant pod from step 1, inspect its purpose and manifests (Deployments, DaemonSets, etc.) and decide:- Is
hostPIDtruly required (e.g., low-level node monitoring / debugging)? - If yes, explicitly document the exception (namespace, workload name, business owner, justification).
- If no, plan to remove
hostPIDfrom the workload spec or replace it with a safer pattern.
- Is
-
Remove
hostPID: truefrom workloads that do not require it (any machine with kubectl access)
For each non-exempt workload, edit the owning controller and removehostPID: truefromspec.template.spec:In the editor, delete the line:Save and exit to trigger a rollout without hostPID.
For workloads managed via GitOps/IaC, make the same edit in the source manifests and re-apply: -
Define a restrictive policy for each user-workload namespace (PodSecurityPolicy alternative: Pod Security Admission / admission controller) (any machine with kubectl access)
Since this control is MANUAL, you must choose and implement a policy mechanism appropriate for your cluster (e.g., built-in Pod Security Admission, Kyverno, OPA/Gatekeeper). Example using built-in Pod Security Admission labels to disallowhostPID(applies if your cluster supports Pod Security Admission):Then explicitly document exceptions (e.g., a dedicated namespace with a less restrictive policy) and ensure they are tightly controlled. -
Optionally create a dedicated namespace for justified
hostPIDworkloads (any machine with kubectl access)
If you must allow some hostPID workloads, isolate them:Apply a clearly documented, less restrictive policy only to this namespace (mechanism depends on your chosen admission controller) and ensure RBAC limits who can deploy there. -
Verification (any machine with kubectl access)
Re-run the audit to confirm no unintendedhostPID: truepods remain:Confirm that only explicitly approved exception workloads (if any) showis_pod_hostpid: trueand are documented as such.
Using kubectl
Using kubectl
PodSecurity Baseline / restricted combo that disallows hostPID everywhere
(except where you explicitly override it later):hostPID, run:hostPID (e.g. system diagnostics), you consciously
opt out by not setting these labels or by setting a lower level and documenting the exception:hostPID except in explicitly allowed namespaces):Automation
Automation

