CVE-2024-34155: Stack exhaustion in all Parse functions in go/parser
Summary
CVE-2024-34155: Stack exhaustion in all Parse functions in go/parser. Affects stdlib across 2 version ranges.
< 1.22.7
>= 1.23.0-0, < 1.23.1
Fixed in 1.22.7 or 1.23.1, depending on the release line you run. How to fix ↓
Also tracked for
- golang · Bitnami
- golang-1.15 · Debian:11
The same CVE-2024-34155 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 the Go ecosystem provides a collection of standard libraries for the Go programming language. It includes various modules and functions that enable developers to build robust and efficient applications. One of the packages within the stdlib is go/parser, which offers parsing functionality for Go source code. This package is responsible for parsing Go source code and extracting relevant information for further processing.
Vulnerability Detail
The vulnerability identified as CVE-2024-34155 affects all Parse functions in the go/parser package. When any of these functions are called on Go source code containing deeply nested literals, it can lead to a panic due to stack exhaustion. This vulnerability arises from the inability of the parser to handle excessively nested literals, causing the stack to overflow and resulting in a panic. The impact of this vulnerability can range from application crashes to potential remote code execution if the panic is not properly handled.
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.22.71.22.7go get stdlib@v1.22.7 -
>= 1.23.0-0, < 1.23.11.23.1go get stdlib@v1.23.1
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
As a temporary workaround, developers can manually limit the depth of nested literals in their Go source code to avoid triggering the stack exhaustion. This can be achieved by refactoring the code to reduce the nesting level or by splitting complex literals into smaller, more manageable parts. Here is an example of how to limit the nesting depth:
package main
import (
"go/parser"
"go/token"
)
func main() {
fset := token.NewFileSet()
// Limit the nesting depth to 10
f, err := parser.ParseFile(fset, "example.go", nil, parser.ParseComments, 10)
if err != nil {
panic(err)
}
// Rest of the code
}
Conclusion
The vulnerability identified as CVE-2024-34155 in the go/parser package can lead to stack exhaustion when parsing Go source code with deeply nested literals. This can result in application crashes or potential remote code execution. It is crucial to update the affected package to version 1.23.1 or later to mitigate this vulnerability. Additionally, developers can apply a temporary workaround by limiting the depth of nested literals in their code.
See every vulnerability recorded for stdlib →
FAQ
The impact of this vulnerability can range from application crashes to potential remote code execution if the panic is not properly handled. It is crucial to address this vulnerability to ensure the stability and security of Go applications.
All versions of the go/parser package prior to version 1.23.1 are affected by this vulnerability.
At the time of this report, there are no known exploits for this vulnerability. However, it is important to apply the recommended fix to mitigate any potential risks.
Yes, if the panic resulting from stack exhaustion is not properly handled, it could potentially lead to remote code execution. It is crucial to update the affected package to prevent any remote exploitation.
Yes, developers can limit the depth of nested literals in their Go source code as a temporary workaround. By reducing the nesting level or splitting complex literals, the risk of triggering stack exhaustion can be mitigated.
References
Related vulnerabilities
Recent vulnerabilities recorded for stdlib.