More Info:
hostPath volumes mount node filesystem paths into containers, enabling access to sensitive host files and escape. Restrict their admission.Risk Level
HighAddress
SecurityCompliance Standards
- CIS Kubernetes
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
Identify current use of
hostPathvolumes across the cluster- Run on: any machine with kubectl access
- Command:
- Review which namespaces and pods are using
hostPath, and whether they are system components (e.g., inkube-system) or user workloads.
-
Determine which namespaces require protection (user workloads)
- Run on: any machine with kubectl access
- Command to list namespaces:
- Classify namespaces into:
- System/control-plane (e.g.,
kube-system,kube-node-lease,kube-public) - Add-on/infra namespaces where
hostPathmay be intentionally required - User workload namespaces (targets for strong restriction)
- System/control-plane (e.g.,
-
Design the admission policy for
hostPathin user namespaces- Decide, per user namespace, whether:
hostPathshould be completely disallowed, or- Only specific, narrowly scoped paths are allowed (e.g., a CSI driver)
- If using an admission controller framework (e.g., ValidatingAdmissionPolicy, Kyverno, Gatekeeper), select the mechanism you will use to enforce
hostPathrestrictions in those namespaces.
- Decide, per user namespace, whether:
-
Implement or update policies to restrict
hostPathin user namespaces- Run on: any machine with kubectl access
- Example: create a strict
ValidatingAdmissionPolicythat denies allhostPathvolumes in selected namespaces (adjust namespaces as needed): - If you must allow specific
hostPathpaths, adjust theexpressionto allow only those paths instead of denying allhostPath.
-
Test enforcement and handle existing workloads
- Run on: any machine with kubectl access
- Try to deploy a test pod with a
hostPathvolume into a protected namespace and confirm it is rejected: - For existing pods using
hostPathin user namespaces, review whether they are justified; if not, plan to:- Update the workloads to remove
hostPath, then - Redeploy them so that policy is applied on the next create/update.
- Update the workloads to remove
-
Re-verify cluster state after changes
- Run on: any machine with kubectl access
- Confirm no unintended
hostPathuse remains in user namespaces: - Confirm the admission policy objects are present and active:
Using kubectl
Using kubectl
kube-*, kubernetes-dashboard, istio-system, etc., depending on your environment). Those are the ones that must have a restriction policy.- Any line showing
hostPath.path(e.g./var/run/docker.sock,/,/var/lib/kubelet,/etc, etc.) is a Pod that mounts the node filesystem. - Each such Pod must be manually reviewed for necessity and scope of the hostPath.
- Any user workload namespace with Pods listed here is using hostPath.
- Broad or sensitive paths (like
/,/var,/etc,/var/lib,/var/run) are higher risk.
.spec.volumes[*].hostPath.pathmounted withhostPath.type: ""orDirectorywithout constraints.- Combined with
securityContext.privileged: true,allowPrivilegeEscalation: true, orrunAsUser: 0indicates high breakout risk.
- Absence of PSPs (on clusters that still support them) or PSPs that allow
hostPathvolumes without restriction in namespaces where you found hostPath Pods.
- For user namespaces, labels like
pod-security.kubernetes.io/enforce: privileged(or no labels at all) combined with hostPath usage means there is no baseline/restricted control to constrain such volumes.
- No admission webhooks addressing
hostPathin a cluster where you depend on external policy (OPA Gatekeeper, Kyverno, etc.) to restrict such volumes.
Use these commands to:
- Enumerate where hostPath is used.
- Determine which namespaces run hostPath workloads.
- Verify whether any admission control mechanism currently restricts hostPath. Human review is required to decide which hostPath uses are justified and what policies to apply to each namespace.
Automation
Automation
- Any line in the summaries indicates a pod that is using a
hostPathvolume. - Focus review on:
- Non‑system namespaces (third section).
- Sensitive paths (examples:
/,/var/run,/var/lib/kubelet,/etc,/var/lib/docker,/var/run/docker.sock,/run/containerd,/var/lib/containerd,/host,/proc,/sys). - Pods running under broadly scoped or shared service accounts.
- Pods in user/workload namespaces using
hostPathare candidates for:- Refactoring to use PVCs or other volume types.
- Being constrained by admission policy (e.g., Pod Security / ValidatingAdmissionPolicy / external admission controllers) to prevent or tightly control
hostPathusage.

