CVE-2020-14040: Golang.org/x/text Golang.org/x/text Infinite Loop Vulnerability

MODERATE
Advisory Identifier: GHSA-5rcv-m4m3-hfh7
CVSS 7.5
CWE-400 CWE-835
Published
Advisory Summary

CVE-2020-14040 is a MODERATE (CVSS 7.5) golang.org/x/text infinite loop vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Golang.org/x/text libraries in the Go ecosystem. The issue involves golang.org/x/text infinite loop. Remediation is available by upgrading affected packages to version 0.3.3.

CVE-2020-14040 at a Glance

CVE Identifier CVE-2020-14040
GHSA Identifier GHSA-5rcv-m4m3-hfh7
Severity MODERATE
CVSS v3.1 Base Score 7.5
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Golang.org/x/text
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 7.5

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

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
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-2020-14040

To remediate this vulnerability, upgrade all affected Golang.org/x/text 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/text fixed: 0.3.3
Upgrade golang.org/x/text to 0.3.3
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/text

How to Check if You Are Affected

To determine whether your application is affected by CVE-2020-14040, inspect your project dependencies for Golang.org/x/text:

inspect dependencies for golang.org/x/text

Analyze the terminal output to locate any version of Golang.org/x/text in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.3.3), 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-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Golang.org/x/text, 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

Go version v0.3.3 of the x/text package fixes a vulnerability in encoding/unicode that could lead to the UTF-16 decoder entering an infinite loop, causing the program to crash or run out of memory. An attacker could provide a single byte to a UTF16 decoder instantiated with UseBOM or ExpectBOM to trigger an infinite loop if the String function on the Decoder is called, or the Decoder is passed to golang.org/x/text/transform.String. ### Specific Go Packages Affected golang.org/x/text/encoding/unicode golang.org/x/text/transform

CVE-2020-14040 Affected Golang.org/x/text Versions

1 component(s)
Fixed Versions:
0.3.3
Product / Package Ecosystem Affected Versions Fixed Version
golang.org/x/text
Go
< 0.3.3
0.3.3

References

Frequently Asked Questions

What is CVE-2020-14040?
CVE-2020-14040 is a security vulnerability in Golang.org/x/text involving golang.org/x/text Infinite loop under CWE-400: Uncontrolled Resource Consumption.
Which Golang.org/x/text versions are affected?
Affected versions include releases prior to 0.3.3 across affected packages: golang.org/x/text.
What version fixes CVE-2020-14040?
Upgrading to 0.3.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is golang.org/x/text affected?
Yes, golang.org/x/text is affected in releases prior to 0.3.3. Upgrade your dependency to 0.3.3 or later.
What is the CVSS score of CVE-2020-14040?
CVE-2020-14040 has a CVSS v3.1 base score of 7.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C.
What CWE is associated with CVE-2020-14040?
CVE-2020-14040 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check Go dependencies for CVE-2020-14040?
Run the dependency tree command: 'inspect dependencies for golang.org/x/text'. 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-5rcv-m4m3-hfh7",
  "modified" : "2024-05-20T19:24:15Z",
  "published" : "2021-05-18T18:34:35Z",
  "aliases" : [ "CVE-2020-14040" ],
  "summary" : "golang.org/x/text Infinite loop",
  "details" : "Go version v0.3.3 of the x/text package fixes a vulnerability in encoding/unicode that could lead to the UTF-16 decoder entering an infinite loop, causing the program to crash or run out of memory. An attacker could provide a single byte to a UTF16 decoder instantiated with UseBOM or ExpectBOM to trigger an infinite loop if the String function on the Decoder is called, or the Decoder is passed to golang.org/x/text/transform.String.\n\n### Specific Go Packages Affected\ngolang.org/x/text/encoding/unicode\ngolang.org/x/text/transform",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "golang.org/x/text"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.3.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-14040"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/golang/go/issues/39491"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/golang/text/commit/23ae387dee1f90d29a23c0e87ee0b46038fbed0e"
  }, {
    "type" : "WEB",
    "url" : "https://go-review.googlesource.com/c/text/+/238238"
  }, {
    "type" : "WEB",
    "url" : "https://go.dev/cl/238238"
  }, {
    "type" : "WEB",
    "url" : "https://go.dev/issue/39491"
  }, {
    "type" : "WEB",
    "url" : "https://go.googlesource.com/text/+/23ae387dee1f90d29a23c0e87ee0b46038fbed0e"
  }, {
    "type" : "WEB",
    "url" : "https://groups.google.com/forum/#!topic/golang-announce/bXVeAmGOqz0"
  }, {
    "type" : "WEB",
    "url" : "https://groups.google.com/g/golang-announce/c/bXVeAmGOqz0"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/TACQFZDPA7AUR6TRZBCX2RGRFSDYLI7O"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400", "CWE-835" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-05-12T14:54:58Z",
    "nvd_published_at" : null
  }
}