# CVE-2026-40879: Nest Affected by DoS via Recursive handleData in JsonSocket (TCP Transport)

Source: https://junglewise.ai/threats/cve-2026-40879-nest-affected-by-dos-via-recursive-handledata-in-jsonsocket-tcp  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-04-21. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

CVE-2026-40879 · Severity: high · CVSS 7.5 · Published 2026-04-21

NestJS Microservices is a library used to build scalable, distributed applications with message-based communication. An attacker can send specially crafted TCP messages containing many small JSON objects in a single frame, causing the JSON parser to recursively process each message and exhaust the application's call stack, resulting in a denial of service crash.

Technologies: [NestJS Nest](https://junglewise.ai/threats/technologies/nest). Vendors: [NestJS](https://junglewise.ai/threats/vendors/nestjs), [npm](https://junglewise.ai/threats/vendors/npm).

## Quick answers

**Is CVE-2026-40879 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-40879 being exploited in the wild.

**How severe is CVE-2026-40879?** High severity, with a CVSS score of 7.5, published 21 April 2026.

**Which products and versions are affected?** NestJS Microservices <= 11.1.18; @nestjs/microservices (npm) <= 11.1.18, SEMVER:introduced=0,fixed=11.1.19.

**Is there a fix for CVE-2026-40879?** Yes. @nestjs/microservices (npm): upgrade to 11.1.19 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-40879 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-40879?** Check whether you run NestJS Microservices, NestJS Nest or @nestjs/microservices (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- @nestjs/microservices (npm): upgrade to 11.1.19 or later

  ```sh
  npm install @nestjs/microservices@11.1.19
  ```


## Technical details

The vulnerability is a stack overflow (CWE-674, CWE-770) in the JsonSocket TCP transport handler. The handleData() method recurses once per JSON message in the buffer, and each recursion shrinks the buffer without ever reaching the configured maxBufferSize limit. An attacker can send approximately 47 KB of valid JSON messages in a single TCP frame to trigger a RangeError and crash the application. The attack requires network access to the microservice but no authentication or user interaction. The issue is fixed in @nestjs/microservices version 11.1.19.

## Affected products

- NestJS Microservices <= 11.1.18

## Identifiers

- CVE-2026-40879
- GHSA-hpwf-8g29-85qm

## Timeline

- 2026-04-14: disclosed: GitHub Security Advisory published
- 2026-04-14: patched: Fixed in @nestjs/microservices@11.1.19

## References

- [https://github.com/nestjs/nest/security/advisories/GHSA-hpwf-8g29-85qm](https://github.com/nestjs/nest/security/advisories/GHSA-hpwf-8g29-85qm)

## Related threats

- [NestJS denial of service via deeply nested microservice message pattern](https://junglewise.ai/threats/cve-2026-102281-nest-is-a-framework-for-building-scalable-node-js-server-side)
- [NestJS authentication bypass in @nestjs/platform-fastify via trailing slash](https://junglewise.ai/threats/cve-2026-54281-nestjs-authentication-bypass-in-nestjs-platform-fastify-via)
- [@nestjs/core Improperly Neutralizes Special Elements in Output Used by a Downstream Component ('Injection')](https://junglewise.ai/threats/cve-2026-35515-nestjs-core-improperly-neutralizes-special-elements-in-output)
- [NestJS auth bypass in @nestjs/platform-fastify](https://junglewise.ai/threats/cve-2026-2293-nestjs-auth-bypass-in-nestjs-platform-fastify)
- [NestJS Fastify URL encoding middleware bypass](https://junglewise.ai/threats/cve-2025-69211-nestjs-fastify-url-encoding-middleware-bypass)
