CVE-2022-41715: Memory exhaustion in regexp/syntax package
Summary
CVE-2022-41715: Memory exhaustion when compiling regular expressions in regexp/syntax. Affects stdlib across 2 version ranges.
< 1.18.7
>= 1.19.0-0, < 1.19.2
Fixed in 1.18.7 or 1.19.2, depending on the release line you run. How to fix ↓
Also tracked for
- golang · Bitnami
- golang-1.15 · Debian:11
The same CVE-2022-41715 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 set of standard libraries and modules for various functionalities. One of these packages is regexp/syntax, which is responsible for compiling regular expressions. Regular expressions are widely used for pattern matching and text manipulation. However, programs that compile regular expressions from untrusted sources may be vulnerable to memory exhaustion or denial of service attacks. The vulnerability arises due to the linear size of the parsed regexp representation, which can result in a significant memory footprint. This can lead to memory exhaustion and impact the performance and stability of the affected program.
Vulnerability Detail
The vulnerability, identified as CVE-2022-41715, allows an attacker to exploit the memory exhaustion issue in the regexp/syntax package. By providing specially crafted regular expressions, an attacker can cause the program to consume excessive amounts of memory, leading to denial of service or degradation of performance. The constant factor in the memory consumption can be as high as 40,000, making even small regexps consume significantly larger amounts of memory. To mitigate this vulnerability, a fix has been implemented that limits the memory footprint of each parsed regexp to 256 MB. Regular expressions that would exceed this limit are rejected, ensuring normal use of regular expressions remains unaffected.
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.18.71.18.7go get stdlib@v1.18.7 -
>= 1.19.0-0, < 1.19.21.19.2go get stdlib@v1.19.2
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
There is no specific workaround mentioned for this vulnerability. However, developers can consider implementing input validation and sanitization techniques to mitigate the risk of untrusted regular expressions causing memory exhaustion. Additionally, monitoring memory usage and setting resource limits for the affected program can help prevent excessive memory consumption.
Conclusion
The memory exhaustion vulnerability in the regexp/syntax package can be mitigated by updating the affected package to the recommended versions. Developers should ensure their applications are using the latest version of the stdlib package to protect against this vulnerability. Input validation and monitoring memory usage can provide additional safeguards. For further support on vulnerability remediation, you can reach out to DevNack.com.
See every vulnerability recorded for stdlib →
FAQ
The vulnerability can lead to memory exhaustion or denial of service attacks in programs that compile regular expressions from untrusted sources. It can cause excessive memory consumption and degrade the performance and stability of the affected program.
You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. The Vulert Playground allows you to analyze your application without requiring access to the code or installation.
No, not all versions of the stdlib package are vulnerable. The vulnerability exists in versions prior to 1.18.7 for Go 1.18.x and versions prior to 1.19.2 for Go 1.19.x. It is recommended to update to the latest version to ensure protection against this vulnerability.
Yes, a fix has been implemented in versions 1.18.7 and 1.19.2 of the stdlib package. These versions limit the memory footprint of parsed regexps to mitigate the memory exhaustion issue. It is advised to update to the latest version to fix the vulnerability.
Yes, normal use of regular expressions is unaffected by the fix for this vulnerability. The memory footprint limitation only applies to regexps that would exceed 256 MB in size. Regular expressions within this limit can still be used without any impact on functionality.
References
Related vulnerabilities
Recent vulnerabilities recorded for stdlib.