Process crash via Socket.IO error replies that echo a message's binary data
Description
| Field | Value |
|---|---|
| Ecosystem | npm |
| Package | @nestjs/websockets, @nestjs/platform-socket.io |
| Affected versions | >= 11.0.0, < 11.2.10 and >= 12.0.0, < 12.5.0 |
| Patched versions | 11.2.10 and 12.5.0 |
| Severity | High |
| CVSS v3.1 | AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H (7.5) |
| CWE | CWE-405 (Asymmetric Resource Consumption (Amplification)), CWE-400 (Uncontrolled Resource Consumption) |
Summary
By default, the WebSocket exception filter includes the data of the message that failed in its error reply. With the Socket.IO adapter, a crafted message with binary data could make that reply far larger than the message itself, and sending it could exhaust memory or terminate the process.
Impact
Applications using the default Socket.IO adapter and the default WebSocket exception filter (or one that extends BaseWsExceptionFilter and keeps includeCause) are affected when any message handler can fail for a client, for example because a guard refuses it or a pipe rejects the payload. No authentication is needed.
Patches
Fixed in 11.2.10 and 12.5.0. The default filter leaves binary data out of the cause of its error replies, and IoAdapter disconnects a client whose message refers to the same binary value more than once. Upgrade both @nestjs/websockets and @nestjs/platform-socket.io.
Workarounds
Use an exception filter that does not include the cause, for example one that extends BaseWsExceptionFilter with includeCause: false.
Credit
Reported by Anthropic's OSS Scanner.