More Info:
Containers sharing the host PID namespace can view and interact with all processes on the node. Their admission should be restricted via Pod Security Admission policies.Risk Level
HighAddress
SecurityCompliance Standards
- CIS AKS
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Identify pods using
hostPIDacross all namespaces
Run on: any machine withkubectlaccessSave the list and, for each pod found, inspect who runs it and why: -
Decide which workloads (if any) truly require
hostPID
For each pod withhostPID: true, review its purpose with the owning team (e.g., node monitoring/diagnostics agents may have a requirement; most app workloads do not).- If
hostPIDis not strictly required, plan to remove it from the pod spec. - If it is required, note the namespace, pod name, and service account for later RBAC tightening:
- If
-
Harden namespaces with Pod Security Admission labels
Decide which namespaces must be strictly protected (nohostPIDallowed) and which, if any, can host exceptional workloads.- To enforce restricted (disallowing
hostPID) on a namespace: - To enable baseline warnings cluster-wide (helps detect issues without blocking):
hostPID-dependent workloads intorestrictednamespaces. - To enforce restricted (disallowing
-
Tighten RBAC for namespaces that legitimately use
hostPID
For any namespace that truly needshostPID, ensure only a dedicated service account can create such pods:- Identify who can create pods now:
- Based on this output, reduce
create/updatepermissions onpodsso that only the specific service account(s) used by the approvedhostPIDworkloads retain that ability.
- Identify who can create pods now:
-
Refactor or remove non-essential
hostPIDusage
For pods wherehostPIDis not required, update their manifests or Helm charts to removehostPID: truefrom.specand re-deploy. Use your normal deployment mechanism (kubectl apply, GitOps, or Helm) and ensure that application behavior remains correct without host PID access. -
Verify the policy and current state
Run on: any machine withkubectlaccess- Confirm no remaining
hostPIDpods except in approved namespaces: - Confirm Pod Security Admission labels are set as intended:
- Optionally, attempt to create a test pod with
hostPID: truein arestrictednamespace and ensure it is rejected.
- Confirm no remaining
Using kubectl
Using kubectl
Using kubectl
1. List pods that request hostPID: true
Run on: any machine with kubectl access.- Any line of output means that pod is running with
hostPID: trueand must be manually reviewed to confirm if this is strictly necessary.
2. Inspect a specific pod’s spec
For each pod identified above:spec.hostPID: truewithout a clear, documented operational need.- Pods using default service accounts or broadly scoped service accounts when
hostPID: trueis set.
3. Check Pod Security Admission labels on namespaces
List PSA labels for all namespaces:- Namespaces lacking
pod-security.kubernetes.io/enforce=restrictedwherehostPIDshould generally be disallowed. - Sensitive or multi-tenant namespaces with
ENFORCEunset or set toprivileged/baseline. - Namespaces allowing
hostPIDbut not clearly segregated for that purpose.
4. Review RBAC for namespaces that legitimately need hostPID
First, list service accounts in a namespace that is allowed to use hostPID:- Service accounts used by
hostPIDpods are bound to roles that are overly broad or reused widely across other workloads. - No clear, dedicated service account for
hostPIDworkloads (e.g., usingdefaultservice account).
Automation
Automation
- Any non-system namespace (or any namespace you do not explicitly trust for privileged workloads) that:
- Lacks
ENFORCE=restricted, and/or - Contains pods listed with
HOSTPID=true.
- Lacks
- Service accounts shown in the hostPID list that are also used widely by non-privileged pods.

