Sep 30, 2026·6 min read·38 visits
A single, deeply nested pattern object can crash a NestJS microservice utilizing TCP or RabbitMQ transport due to uncaught RangeError exceptions.
An unauthenticated remote attacker can crash NestJS microservices utilizing TCP or RabbitMQ transport layers. The vulnerability exists due to recursive serialization of deeply nested message patterns using JSON.stringify, leading to a RangeError and process termination.
The vulnerability CVE-2026-102281 is a denial of service flaw located within the NestJS framework, specifically affecting the @nestjs/microservices package. NestJS microservices use transport layers to communicate across distributed environments. When configured to use either Transmission Control Protocol (TCP) or RabbitMQ (RMQ) transports, the microservice server listens to incoming messages, deserializes them, and performs routing based on the message pattern.
This architecture exposes an attack surface where an unauthenticated remote sender can submit a maliciously crafted message with a structured pattern. The transport layer attempts to serialize this pattern to determine the appropriate handler. This serialization process is vulnerable to uncontrolled recursion, resulting in a thread-terminating error.
The flaw represents a combination of CWE-674 (Uncontrolled Recursion) and CWE-248 (Uncaught Exception). A single payload is sufficient to crash the entire application process, rendering the microservice completely unavailable to legitimate clients until it is manually or automatically restarted.
The root cause lies in how incoming message patterns are handled in the ServerTCP#handleMessage and ServerRMQ#handleMessage methods of the @nestjs/microservices package. When a client-controlled message pattern is received, the NestJS server tries to generate a lookup key to find the corresponding handler. If the pattern is not a flat string, the server automatically passes it to the native JSON.stringify utility without error encapsulation.
While the preceding JSON parsing phase typically handles nested structures efficiently, the native JSON.stringify engine in V8 utilizes recursive descent to traverse and serialize objects. If an object is nested to an extreme depth, generally exceeding 10,000 levels, the recursion exhausts the stack limit of the JavaScript engine. V8 raises a RangeError: Maximum call stack size exceeded exception to halt execution.
Because the message parsing operates in an asynchronous promise context, this synchronous RangeError is converted into an asynchronous rejection. The server lacked a proper rejection handler (.catch()) on the promise chain linked to the underlying socket event listener. Modern Node.js runtimes (version 15 and higher) default to exiting the process upon encountering an unhandled promise rejection, which causes the application daemon to terminate.
An analysis of the vulnerable source code shows how the input stringification was executed without exception wrapping. In the TCP and RMQ transport handlers, raw message payloads were deserialized and processed. The pattern extraction was implemented as follows:
// Vulnerable implementation in ServerTCP
const packet = await this.deserializer.deserialize(rawMessage);
const pattern = !isString(packet.pattern)
? JSON.stringify(packet.pattern) // Throws RangeError if nested too deeply
: packet.pattern;The patch addresses the serialization defect by routing the stringification through a new guarded helper function named getPatternAsString. This helper safely wraps the serialization logic in a try-catch block, intercepting any RangeError exceptions and returning a fallback string representation if serialization fails:
// Patched implementation in Server
protected getPatternAsString(pattern: unknown): string {
if (isString(pattern)) {
return pattern;
}
try {
return JSON.stringify(pattern);
} catch {
return '[UNSERIALIZABLE_PATTERN]'; // Fallback prevents call stack crash
}
}Additionally, the patch wraps the asynchronous event listeners in .catch() blocks to prevent unhandled promise rejections from propagating to the global runtime. In ServerTCP, the message listener was modified to gracefully handle failures via the server's internal error handler:
// Patched message binding in ServerTCP
readSocket.on('message', (msg: ReadPacket & PacketId) =>
this.handleMessage(readSocket, msg).catch(err => this.handleError(err))
);Exploitation of CVE-2026-102281 is highly reliable and requires no elevated privileges or prior authentication. To exploit a microservice using the TCP transport, the attacker must have network reachability to the exposed TCP port. For microservices utilizing RabbitMQ, the attacker must have authorization to publish messages to the specific exchange or queue from which the microservice consumes.
The attack begins with generating a JSON object containing a heavily nested structure. An attacker can write a simple generation script to construct an object with a depth of 100,000 nested properties, represented as {"nested": {"nested": ... {}}}. This structure is wrapped in the standard NestJS envelope, using the target pattern property to carry the nested object.
Upon transmitting this frame to the target service, the microservice successfully parses the inbound stream because the parser accommodates highly nested frames. However, as soon as the framework invokes the routing lookup and attempts to stringify the pattern, the call stack is exhausted. The thread throws a RangeError, which leads to an unhandled promise rejection, immediately killing the Node.js process.
The impact of this vulnerability is a complete loss of service availability (CVSS score: 7.5). Because a single, unauthenticated network message can terminate the backend application, any public-facing or internally exposed vulnerable service can be disabled on demand by an attacker.
No confidentiality or integrity impacts are associated with this flaw. The vulnerability does not permit remote code execution, file system manipulation, or unauthorized data retrieval. The entire payload is discarded as the engine crashes, meaning no malicious commands are executed.
However, the operational impact in enterprise systems is high. If the microservice is not configured with an automatic process supervisor such as PM2, systemd, or Kubernetes replication controllers, the service will remain offline until manual intervention occurs. If a process supervisor is active, an attacker can continuously send the payload to create a crash loop, exhausting system resources and causing persistent denial of service.
The primary remediation strategy is to upgrade @nestjs/microservices to a secure version. For systems running on the 11.x release line, the dependency must be updated to version 11.2.4 or higher. For systems on the 12.x release line, the package must be updated to 12.0.2 or higher.
In environments where upgrading is not immediately possible, several secondary defensive configurations are recommended. Access control lists must be configured to block access to the microservice's TCP port from untrusted networks. RabbitMQ publishing privileges must be restricted so that external, untrusted clients cannot post to queues consumed by the microservice.
As a temporary infrastructure workaround, the Node.js process can be started with the --unhandled-rejections=warn command-line flag. This configuration changes the runtime response to unhandled promise rejections, printing a warning to the console instead of terminating the process. This flag prevents the crash but may introduce memory leaks or unexpected state conditions if other unrelated rejections occur.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H| Product | Affected Versions | Fixed Version |
|---|---|---|
NestJS Microservices NestJS | < 11.2.4 | 11.2.4 |
NestJS Microservices NestJS | >= 12.0.0, < 12.0.2 | 12.0.2 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-674, CWE-248 |
| Attack Vector | Network (AV:N) |
| CVSS Score | 7.5 (High) |
| EPSS Score | 0.00376 (29.01% percentile) |
| Impact | Availability (Denial of Service) |
| Exploit Status | Proof of Concept available |
| KEV Status | Not listed |
The software direct or indirect recursion without effective limits on recursion depth, causing stack allocation space exhaustion.
CVE-2026-114150 is a network-accessible information disclosure vulnerability affecting Microsoft ASP.NET Core in .NET 11.0 preview releases and Microsoft Visual Studio 2026 prior to version 18.12.0. The flaw stems from the use of uninitialized resources (CWE-908) within response buffering components, specifically ResponseBufferingStream used by middleware such as HTTP Logging and Output Caching. Because rented memory segments from ArrayPool<byte> or MemoryPool<byte> are not cleared upon return or strictly bounded to the exact written byte count during subsequent reads, residual response payloads from earlier HTTP requests remain in the buffer tail. Downstream consumers or log sinks reading these buffers expose confidential cross-session data, including authentication tokens and personally identifiable information.
An incorrect authorization vulnerability (CWE-863) exists in the ASP.NET Core SignalR HTTP Connection Dispatcher (`Microsoft.AspNetCore.Http.Connections`). The connection negotiation process failed to bind the authenticated caller identity to the generated connection state, and subsequent transport or message dispatch handlers failed to verify caller consistency. Consequently, an authenticated low-privilege attacker who obtains a valid connection identifier or token can inject messages into or hijack another user's SignalR session, achieving an elevation of privilege across security boundaries.
CVE-2026-109478 is a network-accessible Denial of Service (DoS) vulnerability in ASP.NET Core caused by inefficient algorithmic complexity (CWE-407) when parsing comma-separated HTTP request headers. Prior to the patch, the internal helper method ParsingHelpers.GetHeaderSplit repeatedly called StringValues.Concat inside a loop iterating over each comma-separated token. Because StringValues allocates a new array of size k + 1 and copies all existing elements upon each concatenation, processing N tokens incurs O(N^2) time and space complexity. An unauthenticated remote attacker can send HTTP requests with headers containing thousands of short, comma-separated values to exhaust CPU cycles and induce severe Garbage Collection (GC) pauses, rendering the web application unresponsive.
CVE-2026-114147 is a high-severity Denial of Service (DoS) vulnerability affecting ASP.NET Core and specifically the Microsoft.AspNetCore.SignalR.StackExchangeRedis scale-out provider across .NET 8.0, 9.0, 10.0, and 11.0 preview releases. The vulnerability originates from a string comparison mismatch between internal per-connection group collections and the centralized Redis channel subscription registry, compounded by a race condition during connection teardown. Remote unauthenticated attackers can exploit this flaw to leave orphaned connection contexts and active Redis pub/sub listeners pinned in memory, leading to unbounded memory exhaustion and application process termination.
CVE-2026-114156 is an improper resolution of path equivalence vulnerability (CWE-41) in Microsoft ASP.NET Core affecting .NET 11.0 preview releases and Microsoft Visual Studio 2026. The vulnerability stems from a discrepancy between how path prefix validation helpers (such as PathString.StartsWithSegments) and downstream routing mechanisms handle alternate path separators and percent-encoded characters. An unauthenticated remote attacker can exploit this mismatch over the network to bypass path-based authorization middleware and access restricted endpoints.
CVE-2026-114157 is a high-severity local privilege escalation and security feature bypass vulnerability affecting ASP.NET Core on Microsoft Windows. The flaw resides in the Kestrel web server's Named Pipes transport layer (Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes) and stems from a race condition (CWE-362) during broken pipe error recovery. When an active connection throws an IOException during handshake acceptance, the connection listener previously disposed of the broken NamedPipeServerStream instance before acquiring a replacement stream from its internal pool. This sequence created a momentary window where zero server instances of the named pipe existed in the Windows Named Pipe File System (NPFS). A local, low-privileged attacker can exploit this timing window to create a named pipe with the identical name and a permissive Discretionary Access Control List (DACL), hijacking subsequent inter-process communications and escalating privileges across security boundaries.