# CVE-2024-37168: @grpc/grpc-js can allocate memory for incoming messages well above configured limits

> Attackers can cause excessive memory allocation in @grpc/grpc-js by sending large or compressed messages, leading to denial of service.

- **Severity:** Medium 5.3 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 10 Jun 2024
- **Updated:** 2 Aug 2024
- **Also known as:** CLEANSTART-2026-QB50814, ECHO-066d-8cdc-cc6a, GHSA-7v5v-9h63-cj86, MINI-fhw2-2jg6-whjw, ROOT-APP-NPM-CVE-2024-37168

## What is CVE-2024-37168?

CVE-2024-37168 is a medium-severity denial of service vulnerability in grpc-node, published on 10 Jun 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

@grpc/grps-js implements the core functionality of gRPC purely in JavaScript, without a C++ addon. Prior to versions 1.10.9, 1.9.15, and 1.8.22, 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: If an incoming message has a size on the wire greater than the configured limit, the entire message is buffered before it is discarded; and/or 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. This has been patched in versions 1.10.9, 1.9.15, and 1.8.22.

Weakness: CWE-789 (Memory Allocation with Excessive Size Value)

## Which versions are affected by CVE-2024-37168?

6 open source packages ship an affected version, including @grpc/grpc-js.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `@grpc/grpc-js` | npm | All versions | 1.8.22 |
| `@grpc/grpc-js` | npm | All versions | 1.8.22 |
| `@grpc/grpc-js` | npm | From 1.10.0 | 1.10.9 |
| `@grpc/grpc-js` | npm | From 1.10.0 | 1.10.9 |
| `@grpc/grpc-js` | npm | From 1.9.0 | 1.9.15 |
| `@grpc/grpc-js` | npm | From 1.9.0 | 1.9.15 |

## How do I fix CVE-2024-37168?

Upgrade @grpc/grpc-js to a fixed version for your release line: 1.8.22, 1.10.9 or 1.9.15.

## Is CVE-2024-37168 being exploited?

There is no known exploitation of CVE-2024-37168 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-37168 and fix it if it is affected.

What it is: CVE-2024-37168 is a medium-severity denial of service vulnerability in grpc-node, published on 10 Jun 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2024-37168 in the wild and no public exploit code.

Affected packages and fixed versions:
- @grpc/grpc-js (npm): affected all versions; fixed in 1.8.22
- @grpc/grpc-js (npm): affected all versions; fixed in 1.8.22
- @grpc/grpc-js (npm): affected from 1.10.0; fixed in 1.10.9
- @grpc/grpc-js (npm): affected from 1.10.0; fixed in 1.10.9
- @grpc/grpc-js (npm): affected from 1.9.0; fixed in 1.9.15
- @grpc/grpc-js (npm): affected from 1.9.0; fixed in 1.9.15

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-37168/ (Markdown: https://insights.sbomify.com/CVE-2024-37168/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-37168
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-37168
- OSV: https://osv.dev/vulnerability/CVE-2024-37168

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-37168/
Summaries are generated and may contain mistakes; the official description above is the record.
