CVE-2022-24921: Stack exhaustion when compiling deeply nested expressions in regexp

stdlib Updated 02 Oct 2025

Summary

23/05/2022
Yes i
Unrated
Not published

CVE-2022-24921: Stack exhaustion when compiling deeply nested expressions in regexp. Affects stdlib across 2 version ranges.

< 1.16.15 >= 1.17.0-0, < 1.17.8

Fixed in 1.16.15 or 1.17.8, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2022-24921 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

The stdlib package in Go is a collection of standard libraries that provide fundamental functionality for Go programs. One of the packages in the stdlib is 'regexp', which provides regular expression matching. Regular expressions are widely used for pattern matching and text manipulation in various applications.

Vulnerability Detail

This vulnerability, identified as CVE-2022-24921, affects the 'regexp.Compile' function in the 'regexp' package. On 64-bit platforms, when compiling an extremely deeply nested expression, the function can cause stack exhaustion in goroutines. This can lead to the program exiting unexpectedly. It's important to note that this vulnerability only applies to very large expressions, typically on the order of 2MB.

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.16.15 1.16.15
    go get stdlib@v1.16.15
  • >= 1.17.0-0, < 1.17.8 1.17.8
    go get stdlib@v1.17.8

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.

Conclusion

In conclusion, the 'regexp.Compile' function in the Go stdlib's 'regexp' package is vulnerable to stack exhaustion when compiling deeply nested expressions. This can lead to unexpected program termination. It is recommended to update to a fixed version of the Go stdlib to mitigate this vulnerability. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for stdlib →

Share this vulnerability

FAQ

The vulnerability can cause goroutine stack exhaustion, leading to the program exiting unexpectedly. This can result in denial of service or unexpected termination of the affected application.

Versions 0.0.0 to 1.16.14 and versions 1.17.0-0 to 1.17.7 of the Go stdlib are affected by this vulnerability.

There are no known exploits for this vulnerability at the time of this report.

Yes, the fix for this vulnerability is available in versions 1.16.15 and 1.17.8 of the Go stdlib.

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 vulnerabilities.

Related vulnerabilities

Recent vulnerabilities recorded for stdlib.

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.16.15 1.16.15
    go get stdlib@v1.16.15
  • >= 1.17.0-0, < 1.17.8 1.17.8
    go get stdlib@v1.17.8

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback