CVE-2022-2596: Node fetch Node-fetch Inefficient Regular Expression Complexity Vulnerability

MODERATE
Advisory Identifier: GHSA-vp56-6g26-6827
CVSS 5.9
CWE-400 CWE-1333
Published
Advisory Summary

CVE-2022-2596 is a MODERATE (CVSS 5.9) node-fetch inefficient regular expression complexity vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Node fetch libraries in the npm ecosystem. The issue involves node-fetch inefficient regular expression complexity. Remediation is available by upgrading affected packages to version 3.2.10.

CVE-2022-2596 at a Glance

CVE Identifier CVE-2022-2596
GHSA Identifier GHSA-vp56-6g26-6827
Severity MODERATE
CVSS v3.1 Base Score 5.9
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Node fetch
Package Ecosystem npm
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-2022-2596

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

node-fetch fixed: 3.2.10
npm install node-fetch@3.2.10
Verify Direct and Transitive Dependencies

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

npm ls node-fetch

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2022-2596, inspect your project dependencies using npm:

npm ls node-fetch

Analyze the terminal output to locate any version of Node fetch in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.2.10), your application is affected.

Note: The npm ls node-fetch command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

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 Node fetch, 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

[node-fetch](https://www.npmjs.com/package/node-fetch) is a light-weight module that brings window.fetch to node.js. Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) in the `isOriginPotentiallyTrustworthy()` function in `referrer.js`, when processing a URL string with alternating letters and periods, such as `'http://' + 'a.a.'.repeat(i) + 'a'`.

CVE-2022-2596 Affected Node fetch Versions

1 component(s)
Fixed Versions:
3.2.10
Product / Package Ecosystem Affected Versions Fixed Version
node-fetch
npm
≥ 3.0.0
< 3.2.10
3.2.10

References

Frequently Asked Questions

What is CVE-2022-2596?
CVE-2022-2596 is a security vulnerability in Node fetch involving node-fetch Inefficient Regular Expression Complexity under CWE-400: Uncontrolled Resource Consumption.
Which Node fetch versions are affected?
Affected versions include releases prior to 3.2.10 across affected packages: node-fetch.
What version fixes CVE-2022-2596?
Upgrading to 3.2.10 (or the latest patched release for your respective branch) resolves the vulnerability.
Is node-fetch affected?
Yes, node-fetch is affected in releases prior to 3.2.10. Upgrade your dependency to 3.2.10 or later.
What is the CVSS score of CVE-2022-2596?
CVE-2022-2596 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-2022-2596?
CVE-2022-2596 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 npm dependencies for CVE-2022-2596?
Run the dependency tree command: 'npm ls node-fetch'. 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-vp56-6g26-6827",
  "modified" : "2022-08-04T17:37:24Z",
  "published" : "2022-08-02T00:00:25Z",
  "aliases" : [ "CVE-2022-2596" ],
  "summary" : "node-fetch Inefficient Regular Expression Complexity ",
  "details" : "[node-fetch](https://www.npmjs.com/package/node-fetch) is a light-weight module that brings window.fetch to node.js.\n\nAffected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) in the `isOriginPotentiallyTrustworthy()` function in `referrer.js`, when processing a URL string with alternating letters and periods, such as `'http://' + 'a.a.'.repeat(i) + 'a'`.",
  "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" : "npm",
      "name" : "node-fetch"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0"
      }, {
        "fixed" : "3.2.10"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-2596"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/node-fetch/node-fetch/pull/1611"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/node-fetch/node-fetch/commit/28802387292baee467e042e168d92597b5bbbe3d"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/node-fetch/node-fetch"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/node-fetch/node-fetch/releases/tag/v3.2.10"
  }, {
    "type" : "WEB",
    "url" : "https://huntr.dev/bounties/a7e6a136-0a4b-46c4-ad20-802f1dd60bf7"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333", "CWE-400" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-08-04T17:37:24Z",
    "nvd_published_at" : "2022-08-01T15:15:00Z"
  }
}