CVE-2024-34155: Stack exhaustion in all Parse functions in go/parser

stdlib Updated 02 Oct 2025

Summary

06/09/2024
Yes i
Unrated
Not published

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

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.

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 MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

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.7 1.22.7
    go get stdlib@v1.22.7
  • >= 1.23.0-0, < 1.23.1 1.23.1
    go 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 →

Share this vulnerability

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.

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.22.7 1.22.7
    go get stdlib@v1.22.7
  • >= 1.23.0-0, < 1.23.1 1.23.1
    go 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 →

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