The vulnerability analysis identified multiple path traversal issues across different components of the go-billy library. The root cause is insufficient path sanitization and boundary enforcement, allowing crafted paths (e.g., using ..) to escape the intended base directories.
The analysis of the patches revealed several key areas of vulnerability:
-
helper/chroot/chroot.go: The isCrossBoundaries function, which is central to the security of ChrootHelper, had a flawed implementation that could be easily bypassed. This affected all filesystem operations within the chroot environment, such as Create, Open, etc.
-
osfs/os_chroot.go: The newChrootOS constructor was vulnerable because it did not resolve symbolic links in the base directory path. This allowed for a scenario where a symlink could point to a location outside the intended chroot jail.
-
osfs/os_bound.go: The BoundOS implementation, intended as a more secure alternative to ChrootOS, had its own set of issues. It failed to properly handle paths starting with a dot (.), which could be exploited for path traversal. The abs helper function also suppressed errors, potentially hiding security issues.
-
helper/iofs/iofs.go: The iofs adapter used platform-dependent functions like filepath.Clean for path validation, leading to inconsistent security across different operating systems. The patch corrected this by using the platform-agnostic fs.ValidPath and adding explicit checks for backslashes.
The identified vulnerable functions are the entry points for filesystem operations that take a user-provided path. An attacker could exploit these vulnerabilities by providing a crafted path to read or write files outside of the intended directory, leading to information disclosure or arbitrary code execution, depending on the application's context.