fix(voice-call): reject oversized realtime WebSocket frames to prevent gateway DoS [AI-assisted]#63890
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 275d99e738
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Greptile SummaryThis PR fixes a real gateway DoS by adding Confidence Score: 5/5Safe to merge — the security fix is correct and well-tested; remaining findings are P2 style suggestions only. The core change (adding maxPayload + error handler) is correct and directly addresses the DoS. The new integration test exercises the real enforcement path end-to-end. All remaining findings are P2: a TypeScript style preference (bridge! vs. nullable) and a minor test teardown gap that does not affect correctness. No files require special attention before merging.
|
Summary
voice-callrealtime WebSocket endpoint (RealtimeCallHandler.handleWebSocketUpgrade) created aWebSocketServerwith nomaxPayloadlimit and noerrorevent handler. Sending an oversized frame caused thewsruntime to throw an uncaughtRangeError, crashing the entire gateway process.maxPayload: 256 KBto the per-connectionWebSocketServerso thewslibrary rejects oversized frames with a 1009 close code before JSON parsing or bridge setup runs. Added aws.on("error", ...)handler to absorb the resulting error event. RefactoredActiveRealtimeVoiceBridgeasPick<RealtimeVoiceBridge, ...>to keep the local type anchored to the SDK definition.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
WebSocketServerwas constructed withoutmaxPayload, so thewslibrary had no frame-size bound. On receipt of an oversized frame it emits anerrorevent; with no handler registered, Node.js treats it as an uncaught exception and terminates the process.Regression Test Plan (if applicable)
extensions/voice-call/src/webhook/realtime-handler.test.tscreateBridge/processEvent/getCallByProviderCallIdare never called.wsmaxPayloadenforcement path end-to-end without requiring a live Twilio session.User-visible / Behavior Changes
Realtime stream clients that send frames larger than 256 KB will now receive a WebSocket 1009 (Message Too Big) close frame instead of crashing the gateway. Normal Twilio Media Stream control frames are well under this limit.
Diagram (if applicable)
Security Impact (required)
Repro + Verification
Environment
Steps
/voice/webhookTwiML endpointExpected
Actual (before fix)
RangeError: Max payload size exceededEvidence
RealtimeCallHandler websocket hardening > rejects oversized pre-start frames before bridge setupadded and passing.Human Verification (required)
startevent (pre-bridge);hasBridgeflag correctly prevents access to uninitialized bridge on close.Review Conversations
Compatibility / Migration
Risks and Mitigations
MAX_REALTIME_MESSAGE_BYTESis a named constant easy to adjust with a test update.