Summary
Multiple path traversal flaws in the go-billy filesystem abstraction allow crafted paths (for example those containing ..) to escape intended base directories.
Applications that assume go-billy enforces directory boundaries for isolation may inadvertently expose access to unintended filesystem locations, potentially enabling read or write operations outside the expected scope.
Affected context
This vulnerability affects Go applications that use go-billy as a filesystem abstraction and rely on it to restrict file operations to a particular base directory or virtual filesystem.
The risk is elevated when:
- User-controlled or externally supplied paths are passed directly into go-billy operations
- The application assumes that go-billy consistently enforces path boundaries across its implementations
- go-billy is used as part of a sandbox, isolation layer, or multi-tenant boundary
In such scenarios, inadequate path sanitization may allow access outside the intended directory tree.
Exploit preconditions
- Attack surface: Any API endpoint, RPC handler, CLI command, or plugin interface that accepts path input and uses go-billy for filesystem operations.
- Required access: Ability to supply or influence file paths passed into go-billy (for example, through HTTP parameters, request bodies, configuration, or user input).
- Trigger point: Invocation of go-billy methods (such as open, create, remove, stat, or list) with crafted paths that include traversal sequences (e.g.,
../) or equivalent encodings. - Why exploitation is possible: Some go-billy filesystem implementations perform insufficient normalization and boundary checks, allowing traversal sequences to resolve to locations outside the configured base directory, despite callers expecting isolation.
Why this happens
The core issue aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Internally, go-billy components are responsible for mapping logical paths to real filesystem locations or backing stores. In affected versions, certain implementations do not robustly normalize and validate incoming paths before resolution. They may:
- Concatenate user-supplied paths to a base path without canonicalization
- Inconsistently handle
..,.and redundant separators - Fail to re-check that the resolved path remains under the intended root
This leads to a mismatch between the caller's mental model (that go-billy provides a bounded filesystem rooted at a base directory) and the actual behavior, where crafted traversal paths can escape that boundary.
Potential impact
- Read access to files outside the intended working directory, including configuration or data files that the process can read.
- Overwriting, creating, or deleting files in unintended filesystem locations, depending on the permissions of the running process.
- Corruption or manipulation of application data stored outside the expected virtual filesystem.
- Escalation of impact when combined with other vulnerabilities (e.g., writing to configuration or script directories to influence subsequent code execution).
- Unauthorized disclosure of sensitive information through exfiltration of logs, keys, or other secrets stored on disk and reachable by the application.
General mitigation guidance
Mitigation typically focuses on defensive path handling and clear isolation boundaries in applications that use go-billy:
- Treat all paths influenced by untrusted input as unsafe until they are canonicalized and validated against an allowed root.
- Normalize paths (resolving
..,., and redundant separators) and then enforce that the canonical path remains strictly under an expected base directory before passing it into filesystem operations. - Introduce an explicit path validation layer in the application that is independent of library-specific behavior, rather than assuming library-level isolation guarantees.
- Prefer whitelisting of allowed path patterns or resource identifiers over exposing raw filesystem paths directly to users.
- Run components that handle user-supplied paths with the least filesystem privileges necessary (e.g., restricted service accounts, minimal directory access, containers with scoped volumes).
- Clearly document internally that filesystem abstraction libraries like go-billy are convenience layers and not full security sandboxes unless explicitly designed and verified as such.
How teams detect issues like this
Effective detection combines code-level inspection with policy controls:
- Static analysis and code review:
- Identify call sites where user-controlled input is passed directly as a path argument into go-billy methods without prior normalization or validation.
- Look for direct string concatenation of base directories with user-supplied segments (e.g.,
base + "/" + userPath) before go-billy is invoked. - Flag implementations that do not check that resolved paths remain within an expected root after resolution.
- Policy and architectural review:
- Review components that treat go-billy-backed filesystems as security boundaries or sandboxes; confirm that assumptions about isolation are explicit and verified.
- Enforce guidelines that all filesystem accesses derived from external input must pass through a centralized path validation utility.
- Automated tooling:
- Configure static analysis tools or custom linters for Go to search for path traversal patterns and insufficient path sanitization.
- Integrate these checks into CI pipelines so that new uses of go-billy with unsanitized paths are surfaced early in development.

