Skip to main content

More Info:

Verifies no pod sets hostPID, hostIPC or hostNetwork. Sharing a host namespace breaks the isolation boundary between the pod and the node.

Risk Level

Critical

Address

Security

Compliance Standards

  • Cloudanix Best Practice

Triage and Remediation

Remediation

Manual Steps

  1. List all non-system pods that share any host namespace (run on any machine with kubectl access):
  2. For each offending pod, identify its controller (Deployment/DaemonSet/StatefulSet/Job/etc.) and namespace (run on any machine with kubectl access; replace NAMESPACE and POD_NAME):
    If empty, the pod is standalone and must be deleted and recreated from a corrected manifest.
  3. Edit the owning workload to remove host namespace sharing (run on any machine with kubectl access; choose the correct kind and set NAMESPACE/NAME):
    In the editor, under spec.template.spec, ensure these fields are either removed or explicitly set to false:
    Save and exit; Kubernetes will roll out updated pods.
  4. For standalone pods not managed by a controller (run on any machine with kubectl access; replace NAMESPACE and POD_NAME):
    Edit /tmp/pod-POD_NAME.yaml and under spec remove hostPID, hostIPC, and hostNetwork or set them to false. Also remove metadata.resourceVersion, metadata.uid, metadata.creationTimestamp, metadata.managedFields, status, and any ownerReferences. Then recreate:
  5. Repeat steps 2–4 for each non-compliant pod until all workloads have hostPID, hostIPC, and hostNetwork omitted or set to false in their pod specs.
  6. Verify no remaining non-system pods share host namespaces (run on any machine with kubectl access):
On any machine with kubectl access:
  1. Identify all pods using host namespaces (excluding core namespaces, as per the audit):
  1. For each non-compliant pod, edit its controller manifest (Deployment, StatefulSet, DaemonSet, Job, etc.) to ensure hostPID, hostIPC, and hostNetwork are not set to true.
Example: patch a Deployment to explicitly disable them:
Example: if the running pod is not controlled by a higher-level object (standalone Pod), export, modify, and re-apply:
Edit /tmp/pod-fixed.yaml and in spec remove hostPID, hostIPC, and hostNetwork fields entirely, or set them to false:
Delete and recreate the pod from the fixed manifest:
Note: changing these fields causes pods to be recreated by their controllers, which may briefly disrupt workloads using host namespaces.
  1. Verification (on any machine with kubectl access):
Re-run the audit command; it should now report is_compliant=true for all remaining rows or a single is_compliant=true line: