CVE-2022-41720: Vulnerability in golang package allows unauthorized access to restricted files
Summary
CVE-2022-41720: Restricted file access on Windows in os and net/http. Affects golang across 2 version ranges.
< 1.18.9
>= 1.19.0, < 1.19.4
Fixed in 1.18.9 or 1.19.4, depending on the release line you run. How to fix ↓
Also tracked for
- golang-1.15 · Debian:11
- stdlib · Go
The same CVE-2022-41720 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 golang package is a popular open-source programming language that provides a robust set of tools and libraries for building efficient and reliable applications. It is widely used for developing various types of software, including web applications, network servers, and command-line tools. However, a vulnerability has been discovered in the golang package that allows unauthorized access to restricted files on Windows systems. This vulnerability affects versions 0.0.0 to 1.18.9 and 1.19.0 to 1.19.4 of the golang package.
Vulnerability Detail
The vulnerability in the golang package on Windows systems allows access to restricted files through the os.DirFS and http.Dir functions. These functions provide read-only access to a directory tree rooted at a specified directory. However, they also allow access to Windows device files, such as COM1, which can be exploited by malicious actors. Additionally, on Windows, an os.DirFS for the root directory of the current drive can be manipulated to escape the drive and access any path on the system. This vulnerability poses a high risk as it allows unauthorized access to sensitive files and potential system compromise.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
< 1.18.91.18.9 -
>= 1.19.0, < 1.19.41.19.4
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 golang package is not immediately feasible, a temporary workaround can be implemented by restricting access to the vulnerable functions. This can be achieved by modifying the code to explicitly deny access to restricted files or by implementing access control mechanisms to prevent unauthorized access. Here is an example of how to restrict access to the os.DirFS function:
dir := os.DirFS("C:/tmp")
if !isAllowed(dir) {
return nil, errors.New("Access denied")
}
file, err := dir.Open("COM1")
Conclusion
The vulnerability in the golang package allows unauthorized access to restricted files on Windows systems. It is crucial to update the golang package to version 1.18.9 or 1.19.4 to mitigate this vulnerability. If immediate update is not possible, implementing access restrictions to the vulnerable functions can serve as a temporary workaround. For further assistance and support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for golang →
FAQ
This vulnerability allows unauthorized access to restricted files on Windows systems, potentially leading to the exposure of sensitive information and system compromise.
Versions 0.0.0 to 1.18.9 and 1.19.0 to 1.19.4 of the golang package are affected by this vulnerability.
No, this vulnerability only affects Windows systems.
Yes, updating the golang package to version 1.18.9 or 1.19.4 will fix this vulnerability.
No, this vulnerability requires local access to the affected system.
References
Related vulnerabilities
Recent vulnerabilities recorded for golang.