Join our Newsletter — 33% off our NHI Course

What breaks when Kubernetes CSI drivers trust filepath.Join for untrusted volume identifiers?

filepath.Join only normalizes a path. It does not enforce that the result stays inside a base directory, so traversal input can resolve outside the intended tenant path. In a CSI driver, that can turn a volume mount into cross-tenant read, write, or delete access, especially if the driver later performs recursive deletion on the computed path.

Why This Matters for Security Teams

This issue matters because Kubernetes CSI drivers often sit at the boundary between orchestration and storage, where a small path-handling mistake becomes a cluster-level data exposure. NIST SP 800-53 Rev 5 Security and Privacy Controls treats access enforcement, least privilege, and system integrity as core controls, and this flaw undermines all three when untrusted volume identifiers influence filesystem paths.

The operational risk is not limited to a malformed mount. If the driver computes a tenant directory from attacker-controlled input and later uses that path for recursive operations, a path traversal can become cross-tenant read, write, or deletion. That is especially dangerous in shared clusters, where storage isolation is often assumed to be enforced by the platform rather than the application code. Security teams also miss this issue when they review RBAC and network policy but do not inspect how storage plugins translate identifiers into filesystem locations.

In practice, many security teams encounter this only after an unexpected delete or data bleed has already occurred, rather than through intentional hardening of the CSI path handling logic.

How It Works in Practice

filepath.Join is useful for normalizing path segments, but it is not a confinement control. If a CSI driver accepts a volume name, tenant ID, or mount suffix from an external request and passes it into filepath.Join(baseDir, userInput), the result may still resolve outside the intended directory when the input contains traversal elements or other path tricks. The key failure is that normalization is not the same as authorization.

Secure implementations usually pair path construction with an explicit containment check. In practice, that means resolving the candidate path, confirming it remains under the expected base directory, and rejecting anything that escapes the namespace before any create, mount, chown, or delete action occurs. This should be treated as a defense-in-depth control, not a substitute for upstream validation of volume names and identifiers.

  • Validate volume identifiers against a strict allowlist before path construction.
  • Resolve the final path and verify it is still within the tenant or plugin base directory.
  • Fail closed before recursive operations such as delete, rename, or cleanup.
  • Log rejected identifiers and preserve enough context for incident response.

For broader filesystem hardening guidance, the OWASP Path Traversal guidance remains directly relevant, and the Kubernetes volumes documentation is useful for understanding where storage abstractions end and driver responsibility begins. These controls tend to break down when CSI plugins run with elevated host access and perform recursive cleanup on shared backing directories, because a single bad path can propagate into destructive filesystem operations.

Common Variations and Edge Cases

Tighter path validation often increases implementation complexity and can expose compatibility issues, so organisations need to balance tenant isolation against legacy naming conventions and storage automation. Best practice is evolving for CSI drivers that support multiple backends, because a rule that is safe for one filesystem or object layout may be too strict for another.

Edge cases usually appear when drivers accept encoded input, symlinked directories, or platform-specific path separators. A containment check that looks correct on the source string can still fail if the resolved filesystem location differs after symlink resolution or normalization. Current guidance suggests treating the resolved path, not the raw string, as the security boundary.

Teams should also be careful with partial fixes. Sanitizing obvious .. sequences is not enough if the driver later concatenates additional segments or reuses the same identifier for cleanup. The safest pattern is to separate identity from filesystem location, map trusted identifiers to internal storage records, and reserve path creation for values that have already been authorized.

Where CSI drivers are multi-tenant, run privileged, or responsible for deletion workflows, this becomes a high-impact control issue rather than a simple input-validation bug. For operational resilience mappings, NIST control families around access enforcement and system integrity are the right reference point, while the NIST SP 800-53 Rev 5 Security and Privacy Controls helps frame the containment and audit expectations.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

NIST CSF 2.0 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
NIST CSF 2.0 PR.AC Filesystem path bugs can defeat access enforcement and tenant isolation.
NIST SP 800-53 Rev 5 AC-6 Least privilege limits damage if a CSI path escapes its intended directory.

Treat storage path confinement as part of access control design and verify tenant boundaries before every mount.