Vulnerabilities in pkg:npm/workerd

PACKAGE
Advisory Identifier: GHSA-8vx6-69vg-c46f
Advisory Summary

CVE-2023-2512 is a MODERATE (CVSS 6.5) buffer under-read vulnerability (CWE-190: Integer Overflow or Wraparound) affecting Workerd libraries in the npm ecosystem. The issue involves buffer under-read in workerd. Remediation is available by upgrading affected packages to version 1.20230419.0.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/workerd

1 Known Advisory Record(s)

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

Advisory ID CVE / NVD Severity Summary
GHSA-8vx6-69vg-c46f CVE-2023-2512 MODERATE Buffer under-read in workerd

CVE-2023-2512 at a Glance

CVE Identifier CVE-2023-2512
GHSA Identifier GHSA-8vx6-69vg-c46f
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-190: Integer Overflow or Wraparound
Affected Product Workerd
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.5

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:L/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 Low (C:L)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2023-2512

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

workerd fixed: 1.20230419.0
npm install workerd@1.20230419.0
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 workerd

How to Check if You Are Affected

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

npm ls workerd

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

Note: The npm ls workerd 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-190: Integer Overflow or Wraparound, where the product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. this occurs when an integer value is incremented to a value that is too large to store in the associated representation. when this occurs, the value may become a very small or negative number. In Workerd, 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 Prior to version v1.20230419.0, the FormData API implementation was subject to an integer overflow. If a FormData instance contained more than 2^31 elements, the `forEach()` method could end up reading from the wrong location in memory while iterating over elements. This would most likely lead to a segmentation fault, but could theoretically allow arbitrary undefined behavior. In order for the bug to be exploitable, the process would need to be able to allocate 160GB of RAM. Due to this, the bug was never exploitable on the Cloudflare Workers platform, but could theoretically be exploitable on deployments of workerd running on machines with a huge amount of memory. Moreover, in order to be remotely exploited, an attacker would have to upload a single form-encoded HTTP request of at least tens of gigabytes in size. The application code would then have to use `request.formData()` to parse the request and `formData.forEach()` to iterate over this data. Due to these limitations, the exploitation likelihood was considered Low. ### Patches A fix that addresses this vulnerability has been released in version v1.20230419.0 and users are encouraged to update to the latest version available. ### References Release - https://github.com/cloudflare/workerd/releases/tag/v1.20230419.0

CVE-2023-2512 Affected Workerd Versions

1 component(s)
Fixed Versions:
1.20230419.0
Product / Package Ecosystem Affected Versions Fixed Version
workerd
npm
< 1.20230419.0
1.20230419.0

References

Frequently Asked Questions

What is CVE-2023-2512?
CVE-2023-2512 is a security vulnerability in Workerd involving Buffer under-read in workerd under CWE-190: Integer Overflow or Wraparound.
Which Workerd versions are affected?
Affected versions include releases prior to 1.20230419.0 across affected packages: workerd.
What version fixes CVE-2023-2512?
Upgrading to 1.20230419.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is workerd affected?
Yes, workerd is affected in releases prior to 1.20230419.0. Upgrade your dependency to 1.20230419.0 or later.
What is the CVSS score of CVE-2023-2512?
CVE-2023-2512 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:H.
What CWE is associated with CVE-2023-2512?
CVE-2023-2512 is classified under CWE-190: Integer Overflow or Wraparound (The product performs a calculation that can produce an integer overflow or wraparound when the logic assumes that the resulting value will always be larger than the original value. This occurs when an integer value is incremented to a value that is too large to store in the associated representation. When this occurs, the value may become a very small or negative number.).
How can I check npm dependencies for CVE-2023-2512?
Run the dependency tree command: 'npm ls workerd'. 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-8vx6-69vg-c46f",
  "modified" : "2023-05-12T20:16:38Z",
  "published" : "2023-05-12T20:16:38Z",
  "aliases" : [ "CVE-2023-2512" ],
  "summary" : "Buffer under-read in workerd",
  "details" : "### Impact\nPrior to version v1.20230419.0, the FormData API implementation was subject to an integer overflow. If a FormData instance contained more than 2^31 elements, the `forEach()` method could end up reading from the wrong location in memory while iterating over elements. This would most likely lead to a segmentation fault, but could theoretically allow arbitrary undefined behavior.\n\nIn order for the bug to be exploitable, the process would need to be able to allocate 160GB of RAM. Due to this, the bug was never exploitable on the Cloudflare Workers platform, but could theoretically be exploitable on deployments of workerd running on machines with a huge amount of memory. Moreover, in order to be remotely exploited, an attacker would have to upload a single form-encoded HTTP request of at least tens of gigabytes in size. The application code would then have to use `request.formData()` to parse the request and `formData.forEach()` to iterate over this data. Due to these limitations, the exploitation likelihood was considered Low.\n\n### Patches\nA fix that addresses this vulnerability has been released in version v1.20230419.0 and users are encouraged to update to the latest version available.\n\n### References\nRelease - https://github.com/cloudflare/workerd/releases/tag/v1.20230419.0",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "workerd"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.20230419.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/cloudflare/workerd/security/advisories/GHSA-8vx6-69vg-c46f"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-2512"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/cloudflare/workerd"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/cloudflare/workerd/releases/tag/v1.20230419.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-125", "CWE-127", "CWE-190" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-05-12T20:16:38Z",
    "nvd_published_at" : "2023-05-12T11:15:13Z"
  }
}