CVE-2022-30630: Stack exhaustion in Glob on certain paths in io/fs
Summary
CVE-2022-30630: Stack exhaustion in Glob on certain paths in io/fs. Affects stdlib across 2 version ranges.
< 1.17.12
>= 1.18.0-0, < 1.18.4
Fixed in 1.17.12 or 1.18.4, depending on the release line you run. How to fix ↓
Also tracked for
- golang · Bitnami
- golang-1.19 · Debian:12
The same CVE-2022-30630 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 in Go provides a collection of standard libraries for the Go programming language. One of the packages in the stdlib is io/fs, which offers a set of interfaces and functions for working with the file system. The Glob function in io/fs is used to match file paths against a pattern containing wildcards. This allows users to easily find files that match a specific pattern. However, a vulnerability has been discovered in the Glob function that can lead to a stack exhaustion when called on a path with a large number of path separators.
Vulnerability Detail
The vulnerability (CVE-2022-30630) arises when the Glob function is invoked on a path that contains an excessive number of path separators. This can cause a panic due to stack exhaustion, leading to a denial of service (DoS) condition. An attacker could potentially exploit this vulnerability by providing a specially crafted path to the Glob function, causing the Go program to crash. The impact of this vulnerability is limited to applications that use the affected version of the stdlib package and invoke the Glob function on user-supplied paths. It is important to note that this vulnerability does not allow arbitrary code execution or unauthorized access to sensitive information.
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.121.17.12go get stdlib@v1.17.12 -
>= 1.18.0-0, < 1.18.41.18.4go get stdlib@v1.18.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 stdlib package is not immediately feasible, a temporary workaround can be implemented by avoiding the use of the Glob function on user-supplied paths. Instead, developers can manually validate and sanitize user input to ensure it does not contain an excessive number of path separators before invoking the Glob function. Here is an example of how this can be done in Go:
import (
"io/fs"
"strings"
)
func safeGlob(path string) ([]string, error) {
if strings.Count(path, string(fs.Separator)) > 100 {
return nil, fmt.Errorf("Path contains too many separators")
}
return fs.Glob(path)
}
Conclusion
In conclusion, the stdlib package in Go is vulnerable to a stack exhaustion issue in the Glob function when invoked on paths with a large number of path separators. This can lead to a denial of service (DoS) condition. To mitigate this vulnerability, it is crucial to update the stdlib package to the fixed versions or implement the provided workaround. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for stdlib →
FAQ
The vulnerability can lead to a denial of service (DoS) condition, causing the affected Go program to crash. However, it does not allow arbitrary code execution or unauthorized access to sensitive information.
Versions 0.0.0 to 1.17.12 and versions 1.18.0-0 to 1.18.4 of the stdlib package are affected by this vulnerability.
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 the playground will analyze it for any open-source vulnerabilities, including this one.
Yes, a temporary workaround is to avoid using the Glob function on user-supplied paths. Instead, developers can manually validate and sanitize user input to ensure it does not contain an excessive number of path separators before invoking the Glob function.
To fix this vulnerability, it is recommended to update the stdlib package to version 1.17.12 or 1.18.4, depending on the version being used. After updating the package, recompile and redeploy the affected application to ensure the fix is applied.
References
Related vulnerabilities
Recent vulnerabilities recorded for stdlib.