CVE-2022-1962: Stack exhaustion due to deeply nested types in go/parser

stdlib Updated 02 Oct 2025

Summary

20/07/2022
Yes i
Unrated
Not published

CVE-2022-1962: Stack exhaustion due to deeply nested types in go/parser. Affects stdlib across 2 version ranges.

< 1.17.12 >= 1.18.0-0, < 1.18.4

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

Also tracked for

The same CVE-2022-1962 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 the Go ecosystem provides a set of standard libraries for the Go programming language. It includes various modules and functionalities that developers can utilize in their applications. One of the packages within stdlib is go/parser, which is responsible for parsing Go source code. This package allows developers to analyze and manipulate Go code programmatically. However, a vulnerability has been discovered in go/parser that can lead to stack exhaustion when parsing Go source code containing deeply nested types or declarations.

Vulnerability Detail

The vulnerability (CVE-2022-1962) arises when any of the Parse functions in go/parser are called on Go source code with deeply nested types or declarations. This can trigger a panic due to stack exhaustion, potentially causing the application to crash. The issue originates from the parser's inability to handle excessive nesting levels, leading to an uncontrolled growth of the call stack. Attackers could potentially exploit this vulnerability to disrupt the functioning of affected applications or launch denial-of-service attacks.

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.17.12 1.17.12
    go get stdlib@v1.17.12
  • >= 1.18.0-0, < 1.18.4 1.18.4
    go get stdlib@v1.18.4

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 manually limit the nesting levels in their Go source code to avoid triggering the stack exhaustion issue. By reducing the depth of nested types or declarations, the vulnerability can be mitigated. Here's an example of how to limit nesting levels in Go code:

package main

// Limit the nesting level of types

type Level1 struct {
    Level2 struct {
        Level3 struct {
            // ... Continue nesting as needed
        }
    }
}

func main() {
    // Code using the limited nesting level types
}

Conclusion

The stack exhaustion vulnerability in go/parser (CVE-2022-1962) can cause applications to crash when parsing Go source code with deeply nested types or declarations. To mitigate this issue, developers should update their Go version to 1.17.12 or 1.18.4. Additionally, manually limiting nesting levels in the code can serve as a temporary workaround. For further support on vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for stdlib →

Share this vulnerability

FAQ

The vulnerability can lead to stack exhaustion, causing the application to crash. This can result in service disruptions and potential denial-of-service attacks.

You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability. Vulert monitors and alerts in real-time for open-source vulnerabilities, using Gopkg.lock as input.

No, not all versions of Go are affected. Versions 1.17.12 and 1.18.4 include the necessary fixes to mitigate the vulnerability. It is recommended to update to these versions or later.

No, this vulnerability does not allow remote code execution. However, it can be exploited by an attacker who can provide Go source code with deeply nested types or declarations to the affected application.

Currently, limiting nesting levels is the recommended workaround. It is important to update to the fixed versions of Go to fully mitigate the vulnerability.

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.17.12 1.17.12
    go get stdlib@v1.17.12
  • >= 1.18.0-0, < 1.18.4 1.18.4
    go get stdlib@v1.18.4

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