CVE-2022-29804: Path Traversal Vulnerability in stdlib package
Summary
CVE-2022-29804: Path traversal via Clean on Windows in path/filepath. Affects stdlib across 2 version ranges.
< 1.17.11
>= 1.18.0-0, < 1.18.3
Fixed in 1.17.11 or 1.18.3, depending on the release line you run. How to fix ↓
Also tracked for
The same CVE-2022-29804 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 stdlib package is a part of the Go ecosystem and provides a collection of standard libraries for various functionalities. It includes the path/filepath package, which offers functions for manipulating file paths. This vulnerability specifically affects the Clean function in the path/filepath package on Windows operating systems.
Vulnerability Detail
The Clean function in the path/filepath package on Windows can convert certain invalid paths to valid, absolute paths. This behavior can potentially be exploited by an attacker to perform a directory traversal attack. For example, the Clean(.\c:) function call returns c:, which is a valid absolute path. This vulnerability can lead to unauthorized access to sensitive files or directories outside the intended scope.
How To Fix
Latest published version: go1.25.5 as of 22 Oct 2026
go get stdlib@vgo1.25.5
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
< 1.17.111.17.11go get stdlib@v1.17.11 -
>= 1.18.0-0, < 1.18.31.18.3go get stdlib@v1.18.3
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
If updating the package is not immediately feasible, a temporary workaround can be implemented by manually validating and sanitizing user-provided file paths. This can be done by ensuring that the file paths only contain allowed characters and do not include any directory traversal sequences. Here's an example of how to perform basic path validation in Go:
import (
"path/filepath"
"strings"
)
func validatePath(path string) bool {
// Check if the path contains any directory traversal sequences
if strings.Contains(path, "..") {
return false
}
// Additional validation logic can be added as per requirements
return true
}
Conclusion
In conclusion, the stdlib package in Go is vulnerable to a path traversal attack on Windows systems. It is crucial to update the affected package to the recommended versions or apply the provided workaround to mitigate the risk. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for stdlib →
FAQ
This vulnerability can allow an attacker to traverse directories and potentially access sensitive files or directories outside the intended scope. It can lead to unauthorized information disclosure or even remote code execution depending on the specific context of the application.
The vulnerability affects versions 0.0.0 to 1.17.10 and 1.18.0-0 to 1.18.2 of the stdlib package.
No, this vulnerability specifically affects the Clean function in the path/filepath package on Windows operating systems. Linux and macOS systems are not impacted.
At the time of this report, there are no known public exploits specifically targeting this vulnerability. However, it is important to promptly update the affected package to mitigate any potential risks.
Yes, you can use Vulert's online playground at Vulert Scanner to check if your application is affected by this vulnerability. Vulert monitors and alerts in real-time for open-source vulnerabilities, using only Gopkg.lock file without requiring access to the code or installation.
References
Related vulnerabilities
Recent vulnerabilities recorded for stdlib.