CVE-2018-25046: Path Traversal in code.cloudfoundry.org/archiver
Summary
CVE-2018-25046: Path traversal in code.cloudfoundry.org/archiver. Affects code.cloudfoundry.org/archiver versions < 0.0.0-20180523222229-09b5706aa936. Fixed in 0.0.0-20180523222229-09b5706aa936. How to fix ↓
Also tracked for
The same CVE-2018-25046 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The code.cloudfoundry.org/archiver package is a Go library that provides functionality for creating and extracting archives. It is commonly used in applications that need to compress or decompress files. The vulnerability in this package allows for path traversal, which means that an attacker can manipulate file paths in a way that allows them to access files outside of the intended target directory.
Vulnerability Detail
The vulnerability arises from improper path sanitization in the code.cloudfoundry.org/archiver package. When processing archives that contain relative file paths, the package does not properly validate and sanitize these paths. As a result, an attacker can craft an archive that includes file paths that traverse outside of the intended directory. This can lead to files being written or overwritten in unintended locations, potentially allowing an attacker to overwrite critical system files or gain unauthorized access to sensitive information.
How To Fix
Minimum fixed version
0.0.0-20180523222229-09b5706aa936
This is the first release that contains the fix.
go get code.cloudfoundry.org/archiver@v0.0.0-20180523222229-09b5706aa936
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If updating the package is not immediately feasible, a possible workaround is to implement additional path validation and sanitization when processing archives. This can involve checking that the file paths are within the intended directory and rejecting any paths that attempt to traverse outside of it. Here is an example of how this can be done in Go:
import (
"code.cloudfoundry.org/archiver"
"path/filepath"
)
func processArchive(archivePath string) error {
targetDir := "/path/to/target/directory"
archive, err := archiver.New(archivePath)
if err != nil {
return err
}
for _, file := range archive.Files() {
filePath := filepath.Join(targetDir, file.Path())
if !filepath.HasPrefix(filePath, targetDir) {
return fmt.Errorf("Invalid file path: %s", file.Path())
}
// Process the file
}
return nil
}
Conclusion
The code.cloudfoundry.org/archiver package is vulnerable to a path traversal vulnerability that can allow an attacker to access files outside of the intended target directory. To mitigate this vulnerability, it is recommended to update the package to a fixed version. If immediate updating is not possible, implementing additional path validation and sanitization can serve as a temporary workaround. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for code.cloudfoundry.org/archiver →
FAQ
Path traversal is a vulnerability that allows an attacker to access files or directories outside of the intended target directory. It occurs when an application does not properly validate and sanitize user-supplied file paths, allowing for the traversal of directory structures.
The consequences of this vulnerability can vary depending on the context in which the code.cloudfoundry.org/archiver package is used. In some cases, it can lead to the overwriting or deletion of critical system files, causing system instability or denial of service. In other cases, it can allow an attacker to access sensitive information by reading files outside of the intended directory.
You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply provide your Gopkg.lock file, and Vulert will analyze it to identify any open-source vulnerabilities, including this one.
Yes, a fix for this vulnerability is available. It is recommended to update the code.cloudfoundry.org/archiver package to version 0.0.0-20180523222229-09b5706aa936 or any subsequent version that includes the fix.
If updating the package is not immediately feasible, you can implement additional path validation and sanitization when processing archives. This involves checking that the file paths are within the intended directory and rejecting any paths that attempt to traverse outside of it.