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 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 go/build/constraint package is part of the Go standard library and provides functionality for parsing build constraints in Go source files. Build constraints are special comments that control which source files are included in the build based on the target platform or other conditions. The Parse function in go/build/constraint is responsible for parsing these build constraints. However, a vulnerability exists in the Parse function that can lead to stack exhaustion when processing deeply nested expressions in build tag lines.

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 panic and crash. The impact of this vulnerability depends on the context in which the vulnerable code is used, but it has the potential to disrupt the availability of affected applications.

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

There is no known workaround for this vulnerability. Developers are advised to update their Go installations to the fixed versions.

Conclusion

The go/build/constraint package in the Go standard library is vulnerable to a stack exhaustion issue in the Parse function. This vulnerability can be exploited by providing a malicious Go source file with a specially crafted build tag line. To mitigate this vulnerability, developers should update their Go installations to version 1.23.1 or later. It is important to stay up to date with the latest stable version of Go to ensure the security and stability of applications.

See every vulnerability recorded for stdlib →

Share this vulnerability

FAQ

The go/build/constraint package is part of the Go standard library and provides functionality for parsing build constraints in Go source files. Build constraints are special comments that control which source files are included in the build based on the target platform or other conditions.

The Parse function in go/build/constraint is responsible for parsing build constraints in Go source files. It processes the build tag lines and extracts the relevant information to determine which source files should be included in the build.

The vulnerability occurs 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.

The impact of this vulnerability depends on the context in which the vulnerable code is used. In general, it can lead to a denial of service (DoS) condition, causing the affected application to crash and become unavailable.

Developers should update their Go installations to version 1.23.1 or later. The fix for this vulnerability was introduced in Go version 1.22.7 and further improved in version 1.23.0-0. It is recommended to always use the latest stable version of Go to ensure the latest security patches and bug fixes are applied.

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