More Info:
Verifies no pod mounts a hostPath volume. hostPath exposes the node filesystem to the pod and can be used to escape to the host.Risk Level
HighAddress
SecurityCompliance Standards
- Cloudanix Best Practice
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
On any machine with kubectl access, list all non-system pods using hostPath and identify owners (Deployments, DaemonSets, etc.):
-
For each affected pod, get the full manifest of its controller (example for a Deployment; run on any machine with kubectl access):
For other controllers, change
deploytostatefulset,daemonset,job, orcronjobas appropriate. -
Edit the saved manifest to remove
hostPathvolumes and references (any machine with kubectl access):- Open the file:
- Under
spec.template.spec.volumes, delete any entries containinghostPath:, including thepathfield. - Under
spec.template.spec.containers[].volumeMounts, delete mounts that reference the removed volume names. - Optionally add safer replacements such as
emptyDir: {}or PVC-backed volumes according to your application’s storage requirements.
- Open the file:
-
Apply the updated manifest (any machine with kubectl access):
Confirm old pods are being replaced and new pods are running:
-
For any stand-alone Pod objects (no controller ownerReference), edit them in place to remove
hostPath(any machine with kubectl access): -
Verify no non-system pods use hostPath (any machine with kubectl access):
Compliance is achieved when the output is exactly:
is_compliant=true
Using kubectl
Using kubectl
On any machine with kubectl access:Find the namespace and pod reported in the finding, then see what owns it:For a controller (example: Deployment; adjust kind/name as needed):And its mount:If storage is still needed, replace with one of:For a controller (example: Deployment):Kubernetes will roll out new pods without the
- Identify the offending pod and workload
- If
ownerReferencesis empty: it’s a naked Pod; you will edit/recreate the Pod. - If it shows a controller (
Deployment,StatefulSet,DaemonSet, etc.): you will edit that controller, not the pod.
- Export the current spec
- Edit the manifest to remove
hostPath
- Under
spec.volumes, delete any entries that containhostPath:. - Under each container’s
volumeMounts, delete mounts that refer to those deleted volumes.
-
emptyDir: -
A PersistentVolumeClaim (assuming it already exists):
app-data instead of the hostPath volume in volumeMounts.- Apply the updated manifest
hostPath volumes.- Verification
Automation
Automation

