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
-
Identify all non-system pods using hostPath (any machine with kubectl access):
-
For each non-compliant pod, identify its managing controller (any machine with kubectl access). Replace NAMESPACE and OWNER_NAME as needed:
If
.ownerReferencesis empty, you must edit the Pod manifest source in your own deployment process; do not edit live pods directly as they are not persistent. -
Export the controller manifest that creates the offending pods (any machine with kubectl access). Use the kind/name from ownerReferences, for example:
- Deployment:
- StatefulSet:
- DaemonSet:
- Deployment:
-
Edit the exported manifest locally to remove hostPath volumes and use safer alternatives (local file edit on your workstation):
- In
spec.template.spec.volumes[], delete any entries that containhostPath:. - Update corresponding
spec.template.spec.containers[].volumeMounts[]to either:- Remove the mount completely, or
- Point to a replacement volume, such as:
- In
-
Apply the updated controller manifest so new pods are created without hostPath (any machine with kubectl access):
Then, force recreation of existing pods that were using hostPath:
-
Verification (any machine with kubectl access): rerun the audit and confirm all remaining rows show
is_compliant=trueand none havehostPaths=:
Using kubectl
Using kubectl
On any machine with kubectl access:Edit Edit Delete and recreate the Pod:
- Identify Pods using
hostPath(and their controllers)
- For each affected workload, edit the owning object (Deployment, StatefulSet, DaemonSet, etc.) to remove
hostPathand use a safer volume type such asemptyDiror a PersistentVolumeClaim.
hostPath volume with emptyDir in a Deployment./tmp/deploy-no-hostpath.yaml:- In
.spec.template.spec.volumes[], remove entries like:
- Replace with:
- Ensure containers’
volumeMountsstill referencename: dataonly (no change usually needed).
- For standalone Pods not managed by a controller, recreate them from a manifest without
hostPath:
/tmp/pod-no-hostpath.yaml:- Remove
metadata.uid,metadata.resourceVersion,metadata.creationTimestamp,metadata.ownerReferences,statusfields. - In
.spec.volumes[], deletehostPathvolumes and replace withemptyDiror a PVC-backed volume, for example:
- Verification (same machine with kubectl access)
Automation
Automation

