Vulnerabilities in pkg:npm/node-fetch

PACKAGE
Advisory Identifier: GHSA-w7rc-rwvf-8q5r
Advisory Summary

CVE-2020-15168 is a LOW (CVSS 2.6) the `size` option isn't honored vulnerability (CWE-20: Improper Input Validation) affecting Node fetch libraries in the npm ecosystem. The issue involves the `size` option isn't honored after following a redirect in node-fetch. Remediation is available by upgrading affected packages to version 2.6.1, 3.0.0-beta.9.

3 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/node-fetch

3 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/node-fetch. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-w7rc-rwvf-8q5r CVE-2020-15168 LOW The `size` option isn't honored after following a redirect in node-fetch
GHSA-r683-j2x4-v87g CVE-2022-0235 HIGH node-fetch forwards secure headers to untrusted sites
GHSA-vp56-6g26-6827 CVE-2022-2596 MODERATE node-fetch Inefficient Regular Expression Complexity

CVE-2020-15168 at a Glance

CVE Identifier CVE-2020-15168
GHSA Identifier GHSA-w7rc-rwvf-8q5r
Severity LOW
CVSS v3.1 Base Score 2.6
CWE Classification CWE-20: Improper Input Validation
Affected Product Node fetch
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 2.6

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

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

How to Fix CVE-2020-15168

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: 2.6.1
npm install node-fetch@2.6.1
node-fetch fixed: 3.0.0-beta.9
npm install node-fetch@3.0.0-beta.9
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-2020-15168, 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 2.6.1), 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-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. 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

### Impact Node Fetch did not honor the `size` option after following a redirect, which means that when a content size was over the limit, a `FetchError` would never get thrown and the process would end without failure. For most people, this fix will have a little or no impact. However, if you are relying on node-fetch to gate files above a size, the impact could be significant, for example: If you don't double-check the size of the data after `fetch()` has completed, your JS thread could get tied up doing work on a large file (DoS) and/or cost you money in computing. ### Patches We released patched versions for both stable and beta channels: - For `v2`: 2.6.1 - For `v3`: 3.0.0-beta.9 ### Workarounds None, it is strongly recommended to update as soon as possible. ### For more information If you have any questions or comments about this advisory: * Open an issue in [node-fetch](https://github.com/node-fetch/node-fetch/issues/new?assignees=&labels=question&template=support-or-usage.md&title=Question%3A+) * Contact one of the core maintainers.

CVE-2020-15168 Affected Node fetch Versions

2 component(s)
Fixed Versions:
2.6.13.0.0-beta.9
Product / Package Ecosystem Affected Versions Fixed Version
node-fetch
npm
≥ 2.0.0
< 2.6.1
2.6.1
node-fetch
npm
≥ 3.0.0-beta.1
< 3.0.0-beta.9
3.0.0-beta.9

References

Frequently Asked Questions

What is CVE-2020-15168?
CVE-2020-15168 is a security vulnerability in Node fetch involving The `size` option isn't honored after following a redirect in node-fetch under CWE-20: Improper Input Validation.
Which Node fetch versions are affected?
Affected versions include releases prior to 2.6.1, 3.0.0-beta.9 across affected packages: node-fetch.
What version fixes CVE-2020-15168?
Upgrading to 2.6.1, 3.0.0-beta.9 (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 2.6.1, 3.0.0-beta.9. Upgrade your dependency to 2.6.1, 3.0.0-beta.9 or later.
What is the CVSS score of CVE-2020-15168?
CVE-2020-15168 has a CVSS v3.1 base score of 2.6 (LOW) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2020-15168?
CVE-2020-15168 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check npm dependencies for CVE-2020-15168?
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-w7rc-rwvf-8q5r",
  "modified" : "2024-07-15T19:46:22Z",
  "published" : "2020-09-10T17:46:21Z",
  "aliases" : [ "CVE-2020-15168" ],
  "summary" : "The `size` option isn't honored after following a redirect in node-fetch",
  "details" : "### Impact\nNode Fetch did not honor the `size` option after following a redirect, which means that when a content size was over the limit, a `FetchError` would never get thrown and the process would end without failure.\n\nFor most people, this fix will have a little or no impact. However, if you are relying on node-fetch to gate files above a size, the impact could be significant, for example: If you don't double-check the size of the data after `fetch()` has completed, your JS thread could get tied up doing work on a large file (DoS) and/or cost you money in computing.\n\n### Patches\nWe released patched versions for both stable and beta channels:\n\n- For `v2`: 2.6.1\n- For `v3`: 3.0.0-beta.9\n\n### Workarounds\nNone, it is strongly recommended to update as soon as possible.\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [node-fetch](https://github.com/node-fetch/node-fetch/issues/new?assignees=&labels=question&template=support-or-usage.md&title=Question%3A+)\n* Contact one of the core maintainers.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "node-fetch"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.6.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "node-fetch"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0-beta.1"
      }, {
        "fixed" : "3.0.0-beta.9"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.0.0-beta.8"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/node-fetch/node-fetch/security/advisories/GHSA-w7rc-rwvf-8q5r"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-15168"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/node-fetch/node-fetch/commit/2358a6c2563d1730a0cdaccc197c611949f6a334"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/node-fetch/node-fetch/commit/eaff0094c4dfdd5b78711a8c4f1b61e33d282072"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/node-fetch/node-fetch"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20", "CWE-770" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2020-09-10T17:44:09Z",
    "nvd_published_at" : null
  }
}