Skip to main content

Impact & Risk Analysis

  • Severity: High
  • CIS Benchmark: CIS 5.2.11
  • Impact: Host Filesystem Compromise. A container with a hostPath volume has direct access to the filesystem of the underlying node. If configured incorrectly (e.g., mounting /, /etc, or /var/run/docker.sock), an attacker can read sensitive system configuration, steal credentials, or modify system binaries to gain persistence on the node.

Common Misconfiguration

Using hostPath for persistence in single-node clusters or for “convenience” when sharing files between the node and the pod. This breaks portability and creates a massive security hole.

Vulnerable Example

Secure Example

Audit Procedure

List the policies in use for each namespace or scan running pods for hostPath usage. Check Running Pods:
  • Analyze: Look for any output containing paths (e.g., {"path":"/..."}).
  • Fail: If any user workload uses hostPath. (Note: System components like kube-proxy or CNI plugins often require it, but user apps should not).

Remediation

Add policies to each namespace in the cluster to restrict the admission of hostPath volumes. Using Pod Security Admission: Apply the baseline or restricted profile to your namespaces. Both profiles generally forbid hostPath (with very specific exceptions in baseline for log collection, but restricted is safer).
If you must use hostPath (e.g., for a node monitoring agent), isolate it in a separate namespace with a specific exemption policy.