CVE-2021-31525: Golang.org/x/net Golang.org/x/net/http/httpguts Vulnerable To Uncontrolled Recursion Vulnerability

MODERATE
Advisory Identifier: GHSA-h86h-8ppg-mxmh
CVSS 5.9
CWE-674
Published
Advisory Summary

CVE-2021-31525 is a MODERATE (CVSS 5.9) golang.org/x/net/http/httpguts vulnerable to uncontrolled recursion vulnerability (CWE-674: Uncontrolled Recursion) affecting Golang.org/x/net libraries in the Go ecosystem. The issue involves golang.org/x/net/http/httpguts vulnerable to uncontrolled recursion. Remediation is available by upgrading affected packages to version 0.0.0-20210428140749-89ef3d95e781.

CVE-2021-31525 at a Glance

CVE Identifier CVE-2021-31525
GHSA Identifier GHSA-h86h-8ppg-mxmh
Severity MODERATE
CVSS v3.1 Base Score 5.9
CWE Classification CWE-674: Uncontrolled Recursion
Affected Product Golang.org/x/net
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 5.9

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2021-31525

To remediate this vulnerability, upgrade all affected Golang.org/x/net dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

golang.org/x/net fixed: 0.0.0-20210428140749-89ef3d95e781
Upgrade golang.org/x/net to 0.0.0-20210428140749-89ef3d95e781
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for golang.org/x/net

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-31525, inspect your project dependencies for Golang.org/x/net:

inspect dependencies for golang.org/x/net

Analyze the terminal output to locate any version of Golang.org/x/net in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.0.0-20210428140749-89ef3d95e781), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-674: Uncontrolled Recursion, where the product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack. In Golang.org/x/net, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

golang.org/x/net/http/httpguts in Go before 1.15.12 and 1.16.x before 1.16.4 allows remote attackers to cause a denial of service (panic) via a large header to ReadRequest or ReadResponse. Server, Transport, and Client can each be affected in some configurations.

CVE-2021-31525 Affected Golang.org/x/net Versions

1 component(s)
Fixed Versions:
0.0.0-20210428140749-89ef3d95e781
Product / Package Ecosystem Affected Versions Fixed Version
golang.org/x/net
Go
< 0.0.0-20210428140749-89ef3d95e781
0.0.0-20210428140749-89ef3d95e781

References

Frequently Asked Questions

What is CVE-2021-31525?
CVE-2021-31525 is a security vulnerability in Golang.org/x/net involving golang.org/x/net/http/httpguts vulnerable to Uncontrolled Recursion under CWE-674: Uncontrolled Recursion.
Which Golang.org/x/net versions are affected?
Affected versions include releases prior to 0.0.0-20210428140749-89ef3d95e781 across affected packages: golang.org/x/net.
What version fixes CVE-2021-31525?
Upgrading to 0.0.0-20210428140749-89ef3d95e781 (or the latest patched release for your respective branch) resolves the vulnerability.
Is golang.org/x/net affected?
Yes, golang.org/x/net is affected in releases prior to 0.0.0-20210428140749-89ef3d95e781. Upgrade your dependency to 0.0.0-20210428140749-89ef3d95e781 or later.
What is the CVSS score of CVE-2021-31525?
CVE-2021-31525 has a CVSS v3.1 base score of 5.9 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2021-31525?
CVE-2021-31525 is classified under CWE-674: Uncontrolled Recursion (The product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack.).
How can I check Go dependencies for CVE-2021-31525?
Run the dependency tree command: 'inspect dependencies for golang.org/x/net'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-h86h-8ppg-mxmh",
  "modified" : "2024-05-20T20:30:58Z",
  "published" : "2022-05-24T19:03:29Z",
  "aliases" : [ "CVE-2021-31525" ],
  "summary" : "golang.org/x/net/http/httpguts vulnerable to Uncontrolled Recursion",
  "details" : "golang.org/x/net/http/httpguts in Go before 1.15.12 and 1.16.x before 1.16.4 allows remote attackers to cause a denial of service (panic) via a large header to ReadRequest or ReadResponse. Server, Transport, and Client can each be affected in some configurations.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "golang.org/x/net"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.0.0-20210428140749-89ef3d95e781"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-31525"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/golang/go/issues/45710"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/golang/go"
  }, {
    "type" : "WEB",
    "url" : "https://go.dev/cl/313069"
  }, {
    "type" : "WEB",
    "url" : "https://go.dev/issue/45710"
  }, {
    "type" : "WEB",
    "url" : "https://go.googlesource.com/net/+/89ef3d95e781148a0951956029c92a211477f7f9"
  }, {
    "type" : "WEB",
    "url" : "https://groups.google.com/g/golang-announce/c/cu9SP4eSXMc"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ISRZZ6NY5R2TBYE72KZFOCO25TEUQTBF"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/vuln/GO-2022-0236"
  }, {
    "type" : "WEB",
    "url" : "https://security.gentoo.org/glsa/202208-02"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-674" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-02-08T00:35:49Z",
    "nvd_published_at" : "2021-05-27T13:15:00Z"
  }
}