Overview
src/collaboration/collaboration.gateway.ts accepts WebSocket messages from clients with no size validation. A malicious client can send megabyte-scale operation payloads, exhausting server-side memory during JSON parsing or OT transformation.
Specifications
Features:
- Reject WebSocket messages exceeding a configurable size limit (default 64KB for collaboration operations).
Tasks:
- In each
@SubscribeMessage handler, measure JSON.stringify(payload).length and throw WsException if over the limit.
- Read the limit from
ConfigService (WS_MAX_PAYLOAD_BYTES).
- Alternatively, configure
maxHttpBufferSize on the Socket.IO server in main.ts.
- Add unit tests that emit oversized payloads and verify rejection.
Impacted Files:
src/collaboration/collaboration.gateway.ts
src/main.ts
Acceptance Criteria
- Messages exceeding the limit result in a
WsException with code PAYLOAD_TOO_LARGE.
- Legitimate messages under the limit are processed normally.
- Limit is configurable without code changes.
Overview
src/collaboration/collaboration.gateway.tsaccepts WebSocket messages from clients with no size validation. A malicious client can send megabyte-scale operation payloads, exhausting server-side memory during JSON parsing or OT transformation.Specifications
Features:
Tasks:
@SubscribeMessagehandler, measureJSON.stringify(payload).lengthand throwWsExceptionif over the limit.ConfigService(WS_MAX_PAYLOAD_BYTES).maxHttpBufferSizeon the Socket.IO server inmain.ts.Impacted Files:
src/collaboration/collaboration.gateway.tssrc/main.tsAcceptance Criteria
WsExceptionwith codePAYLOAD_TOO_LARGE.