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
HighAddress
SecurityCompliance Standards
- CIS EKS
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
List all namespaces that contain user workloads (exclude system namespaces)
Run on: any machine with kubectl accessDecide which namespaces should be protected (e.g., everything except kube-system, kube-public, kube-node-lease, etc.). -
For each target namespace, create or update a Pod Security admission label set to
restricted(which forbidshostPID: true)
Run on: any machine with kubectl access
Replace<NAMESPACE>with the actual namespace name: -
Optionally add warnings/audit labels (recommended to catch violations before enforcement)
Run on: any machine with kubectl access -
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: truein the target namespaces.
Run on: any machine with kubectl access
Example Kyverno policy manifest (save asdeny-hostpid.yamland apply):Apply it: -
Review and update existing manifests or Helm charts for user workloads to remove
hostPID: truewhere it is not strictly required.- Search manifests locally:
- For any Pod/Deployment/DaemonSet/etc. manifest that contains
hostPID: true, edit the file and set:
- Search manifests locally:
-
Verification (no pods with
hostPID: trueshould exist)
Run on: any machine with kubectl accessConfirm the output is:
Using kubectl
Using kubectl
Automation
Automation

