CVE-2024-34158: Stack Exhaustion in Parse in go/build/constraint

stdlib Updated 02 Oct 2025

Summary

06/09/2024
Yes i
Unrated
Not published

CVE-2024-34158: Stack exhaustion in Parse in go/build/constraint. 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-34158 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 Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

The 'go/build/constraint' package is a part of the Go standard library. It provides functionality for parsing build tags in Go source files. Build tags are special comments that control which files are included in the build process based on specific conditions. The 'Parse' function in this package is responsible for parsing these build tags. However, a vulnerability exists in the 'Parse' function that can lead to stack exhaustion when processing deeply nested expressions.

Vulnerability Detail

The vulnerability arises when the 'Parse' function is called with a '// +build' build tag line that contains deeply nested expressions. This can cause a panic due to stack exhaustion, potentially leading to a denial-of-service (DoS) condition. An attacker could exploit this vulnerability by crafting a malicious Go source file with a specially crafted build tag line, causing the application to crash or become unresponsive.

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 workaround, developers can avoid using deeply nested expressions in their build tag lines. By simplifying the expressions or restructuring the build tags, the risk of triggering stack exhaustion can be mitigated. Here's an example of a simplified build tag line:

// +build tag1 tag2

This workaround reduces the complexity of the expression and minimizes the chances of encountering the vulnerability.

Conclusion

The 'go/build/constraint' package in the Go standard library is vulnerable to a stack exhaustion issue when parsing deeply nested expressions in build tag lines. This vulnerability can lead to a denial-of-service condition in affected applications. Developers should update their Go installation to version 1.23.1 or later to mitigate this vulnerability. Additionally, simplifying build tag expressions can serve as a temporary workaround.

See every vulnerability recorded for stdlib →

Share this vulnerability

FAQ

The 'go/build/constraint' package is a part of the Go standard library and provides functionality for parsing build tags in Go source files. Build tags are special comments that control which files are included in the build process based on specific conditions.

The vulnerability can lead to a denial-of-service (DoS) condition in applications that process Go source files with deeply nested build tag expressions. An attacker could exploit this vulnerability to crash or render the application unresponsive.

To fix this vulnerability, update your Go standard library to version 1.23.1 or later. This update includes a fix for the 'Parse' function in the 'go/build/constraint' package, preventing stack exhaustion when processing deeply nested expressions.

Yes, developers can avoid using deeply nested expressions in their build tag lines to mitigate the risk of triggering stack exhaustion. Simplifying the expressions or restructuring the build tags can help minimize the chances of encountering the vulnerability.

You can find more information about this vulnerability, including technical details and the fix, in the official Go vulnerability database: https://pkg.go.dev/vuln/GO-2024-3107

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