CVE-2024-37168: @grpc/grpc js @grpc/grpc-js Can Allocate Memory For Vulnerability

MODERATE
Advisory Identifier: GHSA-7v5v-9h63-cj86
CVSS 5.3
CWE-789
Published
Advisory Summary

CVE-2024-37168 is a MODERATE (CVSS 5.3) @grpc/grpc-js can allocate memory for vulnerability (CWE-789: Memory Allocation with Excessive Size Value) affecting @grpc/grpc js libraries in the npm ecosystem. The issue involves @grpc/grpc-js can allocate memory for incoming messages well above configured limits. Remediation is available by upgrading affected packages to version 1.10.9, 1.9.15, 1.8.22.

CVE-2024-37168 at a Glance

CVE Identifier CVE-2024-37168
GHSA Identifier GHSA-7v5v-9h63-cj86
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-789: Memory Allocation with Excessive Size Value
Affected Product @grpc/grpc js
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.3

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:L).

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 Low (A:L)

How to Fix CVE-2024-37168

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

@grpc/grpc-js fixed: 1.10.9
npm install @grpc/grpc-js@1.10.9
@grpc/grpc-js fixed: 1.9.15
npm install @grpc/grpc-js@1.9.15
@grpc/grpc-js fixed: 1.8.22
npm install @grpc/grpc-js@1.8.22
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 @grpc/grpc-js

How to Check if You Are Affected

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

npm ls @grpc/grpc-js

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

Note: The npm ls @grpc/grpc-js 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-789: Memory Allocation with Excessive Size Value, where the product allocates memory based on an untrusted, large size value, but it does not ensure that the size is within expected limits, allowing arbitrary amounts of memory to be allocated. In @grpc/grpc js, 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 There are two separate code paths in which memory can be allocated per message in excess of the `grpc.max_receive_message_length` channel option: 1. If an incoming message has a size on the wire greater than the configured limit, the entire message is buffered before it is discarded. 2. If an incoming message has a size within the limit on the wire but decompresses to a size greater than the limit, the entire message is decompressed into memory, and on the server is not discarded. ### Patches This has been patched in versions 1.10.9, 1.9.15, and 1.8.22

CVE-2024-37168 Affected @grpc/grpc js Versions

3 component(s)
Fixed Versions:
1.10.91.9.151.8.22
Product / Package Ecosystem Affected Versions Fixed Version
@grpc/grpc-js
npm
≥ 1.10.0
< 1.10.9
1.10.9
@grpc/grpc-js
npm
≥ 1.9.0
< 1.9.15
1.9.15
@grpc/grpc-js
npm
< 1.8.22
1.8.22

References

Frequently Asked Questions

What is CVE-2024-37168?
CVE-2024-37168 is a security vulnerability in @grpc/grpc js involving @grpc/grpc-js can allocate memory for incoming messages well above configured limits under CWE-789: Memory Allocation with Excessive Size Value.
Which @grpc/grpc js versions are affected?
Affected versions include releases prior to 1.10.9, 1.9.15, 1.8.22 across affected packages: @grpc/grpc-js.
What version fixes CVE-2024-37168?
Upgrading to 1.10.9, 1.9.15, 1.8.22 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @grpc/grpc-js affected?
Yes, @grpc/grpc-js is affected in releases prior to 1.10.9, 1.9.15, 1.8.22. Upgrade your dependency to 1.10.9, 1.9.15, 1.8.22 or later.
What is the CVSS score of CVE-2024-37168?
CVE-2024-37168 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.
What CWE is associated with CVE-2024-37168?
CVE-2024-37168 is classified under CWE-789: Memory Allocation with Excessive Size Value (The product allocates memory based on an untrusted, large size value, but it does not ensure that the size is within expected limits, allowing arbitrary amounts of memory to be allocated.).
How can I check npm dependencies for CVE-2024-37168?
Run the dependency tree command: 'npm ls @grpc/grpc-js'. 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-7v5v-9h63-cj86",
  "modified" : "2024-06-11T18:28:02Z",
  "published" : "2024-06-10T21:38:05Z",
  "aliases" : [ "CVE-2024-37168" ],
  "summary" : "@grpc/grpc-js can allocate memory for incoming messages well above configured limits",
  "details" : "### Impact\nThere are two separate code paths in which memory can be allocated per message in excess of the `grpc.max_receive_message_length` channel option:\n\n 1. If an incoming message has a size on the wire greater than the configured limit, the entire message is buffered before it is discarded.\n 2. If an incoming message has a size within the limit on the wire but decompresses to a size greater than the limit, the entire message is decompressed into memory, and on the server is not discarded.\n\n### Patches\n\nThis has been patched in versions 1.10.9, 1.9.15, and 1.8.22\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@grpc/grpc-js"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.10.0"
      }, {
        "fixed" : "1.10.9"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@grpc/grpc-js"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.9.0"
      }, {
        "fixed" : "1.9.15"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@grpc/grpc-js"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.8.22"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/grpc/grpc-node/security/advisories/GHSA-7v5v-9h63-cj86"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-37168"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/grpc/grpc-node/commit/08b0422dae56467ecae1007e899efe66a8c4a650"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/grpc/grpc-node/commit/674f4e351a619fd4532f84ae6dff96b8ee4e1ed3"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/grpc/grpc-node/commit/a8a020339c7eab1347a343a512ad17a4aea4bfdb"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/grpc/grpc-node"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-789" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-06-10T21:38:05Z",
    "nvd_published_at" : "2024-06-10T22:15:12Z"
  }
}