fix(discord): bound gateway websocket payloads#99998
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 4, 2026, 11:33 AM ET / 15:33 UTC. Summary PR surface: Source +2, Tests +54. Total +56 across 5 files. Reproducibility: yes. with source-level reproduction rather than a local run: current main constructs both Discord gateway socket paths without Review metrics: 1 noteworthy metric.
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: Keep the bounded Discord gateway receive hardening if maintainers accept the 16 MiB cap; otherwise adjust the cap or require live large-guild proof before merge. Do we have a high-confidence way to reproduce the issue? Yes, with source-level reproduction rather than a local run: current main constructs both Discord gateway socket paths without Is this the best way to solve the issue? Mostly yes: the Discord plugin socket construction path is the right owner boundary, and the second commit resolves the earlier unsafe 1 MiB cap by raising it to 16 MiB. The remaining question is whether maintainers accept that exact fail-closed threshold for upgrades. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ba7b5db74c91. Label changesLabel justifications:
Evidence reviewedPR surface: Source +2, Tests +54. Total +56 across 5 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
Review history (3 earlier review cycles)
|
5d38f05 to
d18d252
Compare
d18d252 to
18a8b91
Compare
|
Merged via squash.
|
* fix(discord): bound gateway websocket payloads * fix(discord): raise gateway payload cap for large events * refactor(discord): centralize gateway websocket policy --------- Co-authored-by: Peter Steinberger <[email protected]>
* fix(discord): bound gateway websocket payloads * fix(discord): raise gateway payload cap for large events * refactor(discord): centralize gateway websocket policy --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes an issue where Discord gateway connections could accept oversized inbound WebSocket frames before gateway payload validation ran.
Why This Change Was Made
Gateway WebSocket clients now set a 16 MiB
maxPayloadcap. The same cap is applied to the monitor/proxy wrapper path so normal Discord startup uses the bounded transport too, while still allowing large gateway events such as member chunks that can exceed 1 MiB.User Impact
Discord gateway users get normal gateway behavior for large guild traffic, with oversized frames still rejected by the WebSocket client before they can grow toward the upstream 100 MiB default.
Evidence
node scripts/run-vitest.mjs extensions/discord/src/internal/gateway-websocket-options.test.ts extensions/discord/src/monitor/provider.proxy.test.ts --reporter=verbosefailed because gateway socket constructors did not includemaxPayload.node scripts/run-vitest.mjs extensions/discord/src/internal/gateway.test.ts extensions/discord/src/monitor/gateway-plugin.test.ts extensions/discord/src/monitor/provider.proxy.test.ts extensions/discord/src/internal/gateway-websocket-options.test.ts --reporter=verbose: passed 4 files, 66 tests.node_modules/.bin/oxfmt --check extensions/discord/src/internal/gateway.ts extensions/discord/src/internal/gateway-websocket-options.test.ts extensions/discord/src/monitor/gateway-plugin.ts extensions/discord/src/monitor/gateway-plugin.test.ts extensions/discord/src/monitor/provider.proxy.test.ts && git diff --check: passed.GatewayPluginandwsserver:AI-assisted: built with Codex