Skip to main content
Menu
Advisories

Process crash via a large WebSocket message to a WsAdapter gateway

GHSA-M25W-Q28W-J8FPPublished Updated GitHub

Description

FieldValue
Ecosystemnpm
Package@nestjs/platform-ws
Affected versions< 11.2.10 and >= 12.0.0, < 12.5.0
Patched versions11.2.10 and 12.5.0
SeverityHigh
CVSS v3.1AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H (7.5)
CWECWE-770 (Allocation of Resources Without Limits or Throttling), CWE-400 (Uncontrolled Resource Consumption)

Summary

WsAdapter accepted client messages of up to 100 MiB, the ws library's default, and parsed each message whole before any handler or guard ran. A single large message from any client that could open a connection could exhaust the heap and terminate the process.

Impact

Applications that use @nestjs/platform-ws (app.useWebSocketAdapter(new WsAdapter(app))) without a maxPayload in their gateway options are affected. No authentication is needed unless the connection is refused at the upgrade. The default Socket.IO adapter is not affected: engine.io limits messages to 1 MB by default.

Patches

Fixed in 11.2.10 and 12.5.0. WsAdapter now limits client messages to 1 MB by default and closes a connection that sends a larger one with code 1009. A gateway's own maxPayload still takes precedence, and the new maxPayload option of the adapter changes the default.

Workarounds

Set maxPayload in the options of each @WebSocketGateway().

Credit

Reported by Anthropic's OSS Scanner.

Affected versions

References

GitHub · nestjs/nest