GHSA-96h4-vgxj-gvm2: Nest Unbounded Memory Growth Vulnerability

MODERATE
CVSS 6.5
CWE-770
Published
Advisory Summary

GHSA-96h4-vgxj-gvm2 is a MODERATE (CVSS 6.5) unbounded memory growth vulnerability (CWE-770: Allocation of Resources Without Limits or Throttling) affecting Nest libraries in the npm ecosystem. The issue involves unbounded memory growth in the nestjs tcp microservice transport. Remediation is available by upgrading affected packages to version 11.2.5, 12.0.3.

GHSA-96h4-vgxj-gvm2 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-96h4-vgxj-gvm2
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-770: Allocation of Resources Without Limits or Throttling
Affected Product Nest
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:A/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Adjacent (AV:A)
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 High (A:H)

How to Fix GHSA-96h4-vgxj-gvm2

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

@nestjs/microservices fixed: 11.2.5
npm install @nestjs/microservices@11.2.5
@nestjs/microservices fixed: 12.0.3
npm install @nestjs/microservices@12.0.3
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 @nestjs/microservices

How to Check if You Are Affected

To determine whether your Node.js application is affected by GHSA-96h4-vgxj-gvm2, inspect your project dependencies using npm:

npm ls @nestjs/microservices

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

Note: The npm ls @nestjs/microservices 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-770: Allocation of Resources Without Limits or Throttling, where the product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated. In Nest, 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

## Summary A peer that can open a TCP connection to a NestJS microservice using the built-in TCP transport can make the server process allocate memory without limit, on either side of the connection, until the process is killed by the OS or by its container memory limit. No authentication, no credentials, and no valid message are required. Applications are affected only if they start a microservice with `Transport.TCP` and the transport's port is reachable by an untrusted peer. ## Affected versions | Package | Affected | Patched | |---|---|---| | `@nestjs/microservices` | `>= 12.0.0, < 12.0.3` | **12.0.3** | | `@nestjs/microservices` | `< 11.2.5` | **11.2.5** | The same code is present in the 10.x line and earlier. Those lines are end-of-life and will not receive a patch; upgrade to a supported major. Only `@nestjs/microservices` is affected. No other package needs updating for this issue. ## Details Two independent paths let one peer grow the heap without bound. ### Partial packets are buffered with nothing to reap them The TCP transport frames messages as `<length>#<payload>`. A peer may declare a length, send part of the payload, and then stop. `JsonSocket` keeps the partial payload buffered while it waits for the rest, and nothing ever reclaimed it: there was no socket timeout, no cap on the number of connections, and no tracking of accepted sockets. `maxBufferSize` did not close this. It caps a single connection, defaulting to 128M characters, and is enforced per connection, so the effective ceiling was the number of connections an attacker chose to open. Ten connections that each send 20MB and then go silent: | | rss | heapUsed | |---|---|---| | baseline | 152.3MB | 28.1MB | | after 200MB sent, all stalled | 561.2MB | 229.5MB | The memory was held for as long as the connections stayed open. Closing them released it, so a peer could hold it indefinitely at negligible cost to itself. ### Response backpressure was ignored `JsonSocket#handleSend` discarded the return value of `socket.write`. A peer that issues requests and never reads the responses therefore made the process queue every response in memory, with no ceiling and no signal to stop producing more. Thirty requests from a client whose stream is paused, against a handler returning an 8MB payload, grew rss from 152.4MB to 419.1MB. The amplification here is roughly 1:1, because the response size is set by the application rather than by the attacker; the defect is that the server buffers all of it rather than applying backpressure or giving up. ## Impact An unauthenticated peer that can reach the transport's port can drive the process to an out-of-memory kill. Under a container memory limit this is fast and repeatable, and it restarts the pod rather than merely degrading it. There is no confidentiality or integrity impact. Nothing is read, written, or executed; the failure mode is availability only. Applications are not affected if the TCP transport is not used, or if the transport's port is reachable only by trusted peers. ## Patches Upgrade `@nestjs/microservices` to **12.0.3** or **11.2.5**. Three changes landed together: - **A stall timer drops a peer that stops sending mid-packet.** It is armed only while a packet is partially received and is refreshed on every read, so a slow but progressing transfer is never interrupted and a peer sitting idle between packets is left alone. Configurable as `incompleteMessageTimeout`, default 30000ms. - **Reading is suspended while a peer's outgoing buffer is backed up** and resumes on `drain`, so a peer that stops reading cannot keep issuing requests. - **Responses queued for a peer that reads nothing are capped.** Suspending reads is not sufficient on its own, because message handlers are asynchronous: a burst of pipelined requests is dispatched before the first response is written, and those responses still queue. Configurable as `maxSendBufferSize`, default 128MB. Both limits are configurable on the server and on the client, and either can be disabled by setting it to `0`. ### Behaviour change Both limits are enabled by default, following the precedent set by `maxBufferSize`. A peer that stops sending mid-packet for 30 seconds, or that lets more than 128MB of responses queue unread on a single connection, is now disconnected where previously it was not. The send cap can also drop a peer that is genuinely reading, if responses are produced faster than the socket drains for long enough. The default is set high for that reason. Applications that stream very large responses to deliberately slow consumers should raise `maxSendBufferSize` or set it to `0`. ## Workarounds For anyone who cannot upgrade immediately: - **Restrict who can reach the port.** The TCP transport is designed for trusted service-to-service traffic. A network policy, security group, or L4 firewall that limits the port to known peers removes the exposure entirely, and is worth doing regardless of version. - **Lower `maxBufferSize`.** This reduces what a single connection can pin on the receive side. It does not bound the total, because the limit is per connection and the number of connections is not capped, and it does nothing for the response-queueing path. - **Supply a custom `socketClass`.** An application-provided socket class can implement its own idle timeout and backpressure handling. This is the only pre-patch mitigation that addresses the sending side. Setting a process memory limit does not mitigate this. It converts the failure from an out-of-memory kill of the host into an out-of-memory kill of the process. ## Credit Reported by Salman Aljardan, who provided a detailed write-up and self-contained proofs of concept for each issue, and coordinated disclosure.

GHSA-96h4-vgxj-gvm2 Affected Nest Versions

2 component(s)
Fixed Versions:
11.2.512.0.3
Product / Package Ecosystem Affected Versions Fixed Version
@nestjs/microservices
npm
< 11.2.5
11.2.5
@nestjs/microservices
npm
≥ 12.0.0
< 12.0.3
12.0.3

References

Frequently Asked Questions

What is GHSA-96h4-vgxj-gvm2?
GHSA-96h4-vgxj-gvm2 is a security vulnerability in Nest involving Unbounded memory growth in the NestJS TCP microservice transport under CWE-770: Allocation of Resources Without Limits or Throttling.
Which Nest versions are affected?
Affected versions include releases prior to 11.2.5, 12.0.3 across affected packages: @nestjs/microservices.
What version fixes GHSA-96h4-vgxj-gvm2?
Upgrading to 11.2.5, 12.0.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @nestjs/microservices affected?
Yes, @nestjs/microservices is affected in releases prior to 11.2.5, 12.0.3. Upgrade your dependency to 11.2.5, 12.0.3 or later.
What is the CVSS score of GHSA-96h4-vgxj-gvm2?
GHSA-96h4-vgxj-gvm2 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with GHSA-96h4-vgxj-gvm2?
GHSA-96h4-vgxj-gvm2 is classified under CWE-770: Allocation of Resources Without Limits or Throttling (The product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated.).
How can I check npm dependencies for GHSA-96h4-vgxj-gvm2?
Run the dependency tree command: 'npm ls @nestjs/microservices'. 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-96h4-vgxj-gvm2",
  "modified" : "2026-09-30T14:44:21Z",
  "published" : "2026-09-30T14:44:21Z",
  "aliases" : [ ],
  "summary" : "Nest: Unbounded memory growth in the NestJS TCP microservice transport",
  "details" : "## Summary\n\nA peer that can open a TCP connection to a NestJS microservice using the built-in TCP\ntransport can make the server process allocate memory without limit, on either side of the\nconnection, until the process is killed by the OS or by its container memory limit. No\nauthentication, no credentials, and no valid message are required.\n\nApplications are affected only if they start a microservice with `Transport.TCP` and the\ntransport's port is reachable by an untrusted peer.\n\n\n## Affected versions\n\n| Package | Affected | Patched |\n|---|---|---|\n| `@nestjs/microservices` | `>= 12.0.0, < 12.0.3` | **12.0.3** |\n| `@nestjs/microservices` | `< 11.2.5` | **11.2.5** |\n\nThe same code is present in the 10.x line and earlier. Those lines are end-of-life and\nwill not receive a patch; upgrade to a supported major.\n\nOnly `@nestjs/microservices` is affected. No other package needs updating for this issue.\n\n## Details\n\nTwo independent paths let one peer grow the heap without bound.\n\n### Partial packets are buffered with nothing to reap them\n\nThe TCP transport frames messages as `<length>#<payload>`. A peer may declare a length,\nsend part of the payload, and then stop. `JsonSocket` keeps the partial payload buffered\nwhile it waits for the rest, and nothing ever reclaimed it: there was no socket timeout, no\ncap on the number of connections, and no tracking of accepted sockets.\n\n`maxBufferSize` did not close this. It caps a single connection, defaulting to 128M\ncharacters, and is enforced per connection, so the effective ceiling was the number of\nconnections an attacker chose to open.\n\nTen connections that each send 20MB and then go silent:\n\n| | rss | heapUsed |\n|---|---|---|\n| baseline | 152.3MB | 28.1MB |\n| after 200MB sent, all stalled | 561.2MB | 229.5MB |\n\nThe memory was held for as long as the connections stayed open. Closing them released it,\nso a peer could hold it indefinitely at negligible cost to itself.\n\n### Response backpressure was ignored\n\n`JsonSocket#handleSend` discarded the return value of `socket.write`. A peer that issues\nrequests and never reads the responses therefore made the process queue every response in\nmemory, with no ceiling and no signal to stop producing more.\n\nThirty requests from a client whose stream is paused, against a handler returning an 8MB\npayload, grew rss from 152.4MB to 419.1MB. The amplification here is roughly 1:1, because\nthe response size is set by the application rather than by the attacker; the defect is that\nthe server buffers all of it rather than applying backpressure or giving up.\n\n## Impact\n\nAn unauthenticated peer that can reach the transport's port can drive the process to an\nout-of-memory kill. Under a container memory limit this is fast and repeatable, and it\nrestarts the pod rather than merely degrading it.\n\nThere is no confidentiality or integrity impact. Nothing is read, written, or executed;\nthe failure mode is availability only.\n\nApplications are not affected if the TCP transport is not used, or if the transport's port\nis reachable only by trusted peers.\n\n## Patches\n\nUpgrade `@nestjs/microservices` to **12.0.3** or **11.2.5**.\n\nThree changes landed together:\n\n- **A stall timer drops a peer that stops sending mid-packet.** It is armed only while a\n  packet is partially received and is refreshed on every read, so a slow but progressing\n  transfer is never interrupted and a peer sitting idle between packets is left alone.\n  Configurable as `incompleteMessageTimeout`, default 30000ms.\n- **Reading is suspended while a peer's outgoing buffer is backed up** and resumes on\n  `drain`, so a peer that stops reading cannot keep issuing requests.\n- **Responses queued for a peer that reads nothing are capped.** Suspending reads is not\n  sufficient on its own, because message handlers are asynchronous: a burst of pipelined\n  requests is dispatched before the first response is written, and those responses still\n  queue. Configurable as `maxSendBufferSize`, default 128MB.\n\nBoth limits are configurable on the server and on the client, and either can be disabled by\nsetting it to `0`.\n\n### Behaviour change\n\nBoth limits are enabled by default, following the precedent set by `maxBufferSize`. A peer\nthat stops sending mid-packet for 30 seconds, or that lets more than 128MB of responses\nqueue unread on a single connection, is now disconnected where previously it was not.\n\nThe send cap can also drop a peer that is genuinely reading, if responses are produced\nfaster than the socket drains for long enough. The default is set high for that reason.\nApplications that stream very large responses to deliberately slow consumers should raise\n`maxSendBufferSize` or set it to `0`.\n\n## Workarounds\n\nFor anyone who cannot upgrade immediately:\n\n- **Restrict who can reach the port.** The TCP transport is designed for trusted\n  service-to-service traffic. A network policy, security group, or L4 firewall that limits\n  the port to known peers removes the exposure entirely, and is worth doing regardless of\n  version.\n- **Lower `maxBufferSize`.** This reduces what a single connection can pin on the receive\n  side. It does not bound the total, because the limit is per connection and the number of\n  connections is not capped, and it does nothing for the response-queueing path.\n- **Supply a custom `socketClass`.** An application-provided socket class can implement its\n  own idle timeout and backpressure handling. This is the only pre-patch mitigation that\n  addresses the sending side.\n\nSetting a process memory limit does not mitigate this. It converts the failure from an\nout-of-memory kill of the host into an out-of-memory kill of the process.\n\n## Credit\n\nReported by Salman Aljardan, who provided a detailed write-up and self-contained proofs of\nconcept for each issue, and coordinated disclosure.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@nestjs/microservices"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "11.2.5"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@nestjs/microservices"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "12.0.0"
      }, {
        "fixed" : "12.0.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/nestjs/nest/security/advisories/GHSA-96h4-vgxj-gvm2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nestjs/nest/pull/17746"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nestjs/nest/pull/17749"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nestjs/nest/commit/6ca2dd894a6ff964d318724f363061652e822920"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nestjs/nest/commit/781843ac98d429fe1d541c52c7126850be5989a7"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nestjs/nest/commit/dee4ed4dbc2e18e1e722619927647f5441dfe812"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/nestjs/nest"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nestjs/nest/releases/tag/v11.2.5"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/nestjs/nest/releases/tag/v12.0.3"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-770" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-30T14:44:21Z",
    "nvd_published_at" : null
  }
}