fix(mattermost): reject oversized websocket events#99366
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 3, 2026, 2:42 AM ET / 06:42 UTC. Summary PR surface: Source +6, Tests +75. Total +81 across 2 files. Reproducibility: yes. A loopback WebSocket server can exercise Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the fixed transport cap if maintainers accept the 4 MiB supported event envelope; otherwise choose a larger fixed cap and keep the same focused loopback test shape. Do we have a high-confidence way to reproduce the issue? Yes. A loopback WebSocket server can exercise Is this the best way to solve the issue? Yes, with maintainer acceptance of the compatibility envelope. The default Mattermost WebSocket factory is the narrow owner boundary for this resource guard; parser-only validation would still buffer the frame first, and a config option would add unnecessary operator surface unless a higher supported limit is required. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against da67520b8d5f. Label changesLabel justifications:
Evidence reviewedPR surface: Source +6, Tests +75. Total +81 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
d3fc995 to
a834f58
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
a834f58 to
a555c28
Compare
Co-authored-by: sunlit-deng <[email protected]>
|
Merged via squash.
|
* fix(mattermost): bound monitor websocket payloads * fix(mattermost): preserve websocket payload headroom Co-authored-by: sunlit-deng <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
* fix(mattermost): bound monitor websocket payloads * fix(mattermost): preserve websocket payload headroom Co-authored-by: sunlit-deng <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
Summary
Bounds inbound Mattermost monitor WebSocket messages at 16 MiB before application parsing, instead of inheriting the pinned
wsclient's 100 MiB default.What Problem This Solves
A buggy or hostile self-hosted Mattermost server could make the monitor buffer a very large WebSocket message before JSON/schema validation had a chance to reject it. The production connection factory supplied no
maxPayload, sows8.21.0 allowed up to 100 MiB per message.Why This Change Was Made
The default Mattermost WebSocket factory is the narrow transport owner that can reject a complete fragmented or compressed message before it reaches capture and JSON parsing. A fixed 16 MiB ceiling:
The loopback regression uses the real production factory. It dispatches a normal post and a 1+ MiB valid post envelope, then sends a 16 MiB + 1 byte frame and verifies the
wsreceiver reportsMax payload size exceeded.User Impact
Normal Mattermost posts, cards, reactions, and integration events continue to work. An inbound WebSocket message above 16 MiB closes and reconnects the monitor instead of being buffered up to 100 MiB.
Evidence
ws8.21.0 defaults clientmaxPayloadto 100 MiB and rejects excess length in the receiver before message emission.PostPropsMaxRunesis 800,000, andpostedevents serialize the post into the event data as a JSON string.cbx_78e494d6dac7, exact head8839d638f956256cbdbb2ab0ccb620fa2b45c0f3:run_a5a491b2ad1b: all 11 focused Mattermost monitor WebSocket tests passed, including production-factory normal/large-valid/oversized behavior.run_dd52e6322300:pnpm check:changedpassed, including project type checks, lint/format guards, and runtime import-cycle checks.Co-authored-by: sunlit-deng [email protected]