More Info:
Do not generally admit containers which make use of hostPath volumes.Risk Level
LowAddress
SecurityCompliance Standards
- CIS Kubernetes
Triage and Remediation
- Remediation
Remediation
Manual Steps
Manual Steps
-
List all workloads using
hostPathvolumes
Run on: any machine with kubectl accessUse this to identify which namespaces and pods currently depend onhostPathand why (logging, runtime, node access, etc.). -
Review each namespace’s existing admission controls
Run on: any machine with kubectl accessDetermine which namespaces host user workloads and whether they already enforce Pod Security Standards or other policies that restricthostPath. -
Decide namespace policy for
hostPathusage
For each namespace with user workloads:- Decide if
hostPathshould be:
a) Fully disallowed,
b) Allowed only for specific paths (e.g.,/var/log,/var/run), or
c) Temporarily allowed while refactoring workloads.
Document required exceptions (namespaces, deployments, and exact host paths).
- Decide if
-
Implement or tighten policy to restrict
hostPath
Run on: any machine with kubectl access
Examples (adapt to your chosen mechanism; apply only where appropriate):- If using Pod Security admission labels:
- If using Kyverno (example policy – edit namespace selector, allowed paths):
- If using Pod Security admission labels:
-
Refactor or explicitly approve remaining
hostPathusers
For each pod identified in step 1 in namespaces wherehostPathshould be minimized:- Prefer alternatives (emptyDir, PVC, projected volumes, CSI drivers) and update manifests:
- Where
hostPathis strictly necessary, ensure it is:- Limited to the minimal directory.
- Read-only where possible.
- Covered by an explicit, narrowly scoped policy exception.
- Prefer alternatives (emptyDir, PVC, projected volumes, CSI drivers) and update manifests:
-
Verify policies and current workloads
Run on: any machine with kubectl access- Confirm namespace labels / policy objects:
- Re-run
hostPathusage discovery to ensure only approved cases remain: - Optionally, perform a dry run of a pod using
hostPathin a locked-down namespace to confirm it is rejected:
- Confirm namespace labels / policy objects:
Using kubectl
Using kubectl
Using kubectl
1. List all namespaces to scope your review
Run on: any machine with kubectl accesskube-system, kube-public, kube-node-lease, and provider-specific system namespaces unless you intentionally run user apps there).2. Check for pods using hostPath in each namespace
Run on: any machine with kubectl access- Any pod in a user-workload namespace shows
volume: ... hostPath: /some/path. - Especially concerning paths:
/var/run,/var/run/docker.sock,/,/var/lib/kubelet,/etc,/var/lib/docker, or other sensitive host directories.
3. Identify which controllers define those pods
Use labels or ownerReferences to find the workload owning a pod that useshostPath.Example (replace names as needed):.metadata.ownerReferences for kind (Deployment, DaemonSet, StatefulSet, Job, etc.), then inspect that controller:- Any user-managed controller spec includes
hostPath:under.spec.template.spec.volumes.
4. Check for PodSecurity or admission controls that restrict hostPath
4.1 Pod Security Admission (PSA) labels on namespaces
pod-security.kubernetes.io/enforcepod-security.kubernetes.io/auditpod-security.kubernetes.io/warn
- User-workload namespaces have no Pod Security labels, or:
- They are set to profiles (
baselineorprivileged) that allow broadhostPathusage when your policy should be more restrictive (e.g., targetingrestrictedand specific allowed host paths).
4.2 PodSecurityPolicy (legacy, if still present)
volumesallowshostPathand:.spec.allowedHostPathsis empty, orpathPrefix: /or other very broad prefixes withoutreadOnly: truewhere appropriate.
- PSPs with broad
hostPathallowances are bound to service accounts used in user-workload namespaces.
5. Check for validating/mutating admission webhooks related to hostPath
hostPath in webhook configs and related CRDs/policies:- No admission webhooks or policies mention
hostPathwhile your security model expects centralized enforcement (e.g., Kyverno, OPA Gatekeeper) to restrict or forbidhostPath. - Policies exist but are in
audit/warnmode only, notenforcefor hostPath usage.
6. If using common policy engines, surface hostPath-related rules
Examples (run only if the CRDs exist):Kyverno:- No constraints/policies reference
hostPathat all. - Constraints exist but target only limited namespaces, leaving user-workload namespaces unprotected.
7. What you decide from the review (human judgement required)
Based on the above data, you must decide:- Which
hostPathusages are strictly required for functionality and acceptable by policy. - Where you should:
- Remove
hostPathentirely, - Replace it with a safer volume type (e.g.,
emptyDir, PVC), - Or constrain it via namespace policies/Pod Security/admission controls to a small set of approved paths and workloads.
- Remove
Automation
Automation

