Packages / @nestjs/microservices / Security

HighVulnerabilityGHSA-m8vh-jmq9-5rjgCVE-2026-102281Published 29 Sep 2026

Nest: Remote process termination via a deeply nested microservice message pattern

Affected releases · @nestjs/microservices

  • 12.x12.0.0 – 12.0.1Fixed in 12.0.2
  • 11.x11.0.0 – 11.2.3Fixed in 11.2.4
  • 10.x10.0.0 – 10.4.22No fix on this line yet
  • 9.x and older2.0.0 – 9.4.3No fix, no longer updated

On 12.x, the newest line:

npm install @nestjs/microservices@12.0.2
12.x
  1. Affected

    12.0.0 – 12.0.1

    2 releases

  2. Fixed

    12.0.2 – 12.2.0

    8 releases, latest

11.x
  1. Affected

    11.0.0 – 11.2.3

    56 releases

  2. Fixed

    11.2.4 – 11.2.7

    4 releases

10.x
  1. Affected

    10.0.0 – 10.4.22

    55 releases

9.x
  1. Affected

    9.0.0 – 9.4.3

    37 releases

8.x
  1. Affected

    8.0.0 – 8.4.7

    32 releases

7.x
  1. Affected

    7.0.0 – 7.6.18

    51 releases

6.x
  1. Affected

    6.0.0 – 6.11.11

    67 releases

5.x
  1. Affected

    5.0.0 – 5.7.4

    30 releases

4.x
  1. Affected

    4.0.0 – 4.6.6

    37 releases

3.x
  1. Affected

    3.0.0 – 3.1.0

    4 releases

2.x
  1. Affected

    2.0.0 – 2.1.0

    9 releases

392 stable releases of @nestjs/microservices, oldest to newest, one row per major.

Is your project affected?

Paste your package.json, or type the range you declare for @nestjs/microservices. It is read in your browser and sent nowhere.

What happens

FieldValue
Ecosystemnpm
Package@nestjs/microservices
Affected versions>= 12.0.0, < 12.0.2 and < 11.2.4
Patched versions12.0.2 and 11.2.4 (upgrade to 12.0.3 / 11.2.5)

Summary

A single message whose pattern is a deeply nested object terminates a NestJS microservice that uses the TCP or RabbitMQ transport. The server serialized the client-supplied pattern with JSON.stringify to derive the handler lookup key; on deeply nested input this throws RangeError: Maximum call stack size exceeded. The exception escaped the asynchronous message handler as an unhandled promise rejection, which terminates the Node.js process under the default --unhandled-rejections=throw.

Impact

Denial of service, one message per crash, repeatable. The attacker needs to be able to reach the transport: connect to the TCP transport's port, or publish to the queue or exchange the service consumes from. The TCP transport performs no authentication by default, so on a reachable port this requires nothing else.

Only the TCP and RabbitMQ transports are affected. The other transports take the pattern as a string from the broker topic or channel and never serialize a client-supplied object to build it.

Details

In ServerTCP#handleMessage and ServerRMQ#handleMessage the pattern was stringified without a guard:

const pattern = isString(packet.pattern)
  ? packet.pattern
  : JSON.stringify(packet.pattern);

JSON.parse accepts nesting depths that JSON.stringify cannot re-serialize, because JSON.stringify recurses natively, so an attacker can craft a payload that parses successfully on arrival and then throws when the pattern is converted back to a string. Neither transport attached a rejection handler to the promise returned by handleMessage, so the RangeError propagated out as an unhandled rejection.

Proof of concept

Against a NestJS microservice on the TCP transport (default port 3001). The nested JSON is built as text rather than with JSON.stringify, which is what makes the payload serializable by the attacker but not by the victim:

const { connect } = require('node:net');

const DEPTH = 100_000;
const pattern = '{"nested":'.repeat(DEPTH) + '{}' + '}'.repeat(DEPTH);
const payload = `{"pattern":${pattern},"data":null,"id":"1"}`;

const socket = connect(3001, '127.0.0.1', () => {
  // Nest's TCP framing is <byteLength>#<json>
  socket.write(`${Buffer.byteLength(payload)}#${payload}`);
});

The service exits with RangeError: Maximum call stack size exceeded. The equivalent payload published to the consumed queue crashes a RabbitMQ-transport service.

Patches

Fixed in 12.0.2 and 11.2.4.

  • Incoming patterns are converted through a guarded Server#getPatternAsString, which falls back to a sentinel value that matches no handler. Such a message now receives the ordinary "no message handler" response (TCP) or is negatively acknowledged (RabbitMQ) instead of crashing the process.

  • Rejections escaping handleMessage in both transports are routed to handleError rather than left unhandled.

Workarounds

If you cannot upgrade, restrict network access to the transport so that only trusted peers can reach it. Running the process with --unhandled-rejections=warn prevents the crash but leaves the message unprocessed and is not a substitute for the fix.

Credit

Reported by ZeroVuln Labs.