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 pods using
hostPathvolumes
Run on: any machine with kubectl access -
Export the owning workload manifest(s)
For each non‑compliant pod line, note theowner=field (e.g.,Deployment/ns/name/uid). Then export that owner resource. Examples:
Run on: any machine with kubectl access -
Edit manifests to remove
hostPathvolumes and use safer alternatives
Run on: any machine with kubectl access (local file edits)
Open each exported YAML file and in thespec.template.spec.volumes(orspec.volumesfor standalone pods), remove entries that definehostPath. Example before/after: Before:Replace with an approved alternative, such asemptyDiror apersistentVolumeClaim(if appropriate for the application):emptyDirexample:PVC example (requires an existing PVC or one you create separately):Ensure matchingvolumeMountsrefer to the updated volume name and that any dependency on the host filesystem is addressed functionally (e.g., by moving data to PV-backed storage). -
Apply the updated manifests
Run on: any machine with kubectl accessThe workloads will be recreated/rolled out with the new volume configuration; expect pod restarts as part of this change. -
Confirm there are no remaining
hostPathvolumes in non‑system namespaces
Run on: any machine with kubectl accessCompliance is achieved when the output is either a single lineis_compliant=trueor no lines containis_compliant=false.
Using kubectl
Using kubectl
On any machine with kubectl access:If you use manifests in Git or files, update them and apply declaratively:Edit
- Identify noncompliant Pods (and their controllers)
- For each violating controller (Deployment, DaemonSet, StatefulSet, Job, etc.), edit the manifest to remove
hostPathvolumes and replace them withemptyDir, a PersistentVolumeClaim, or another non-hostPath type.
hostPath with emptyDir (adjust names, namespace, volume names as needed):- For standalone Pods (no controller ownerReference), recreate them without
hostPath:
/absolute/path/to/example-pod.yaml:- Remove any
hostPath:blocks underspec.volumes. - Adjust containers’
volumeMountsto use the new volume types.
- Verification (same command as audit)
Automation
Automation

