fix(realtime-transcription): bound inbound websocket payloads#102443
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 9, 2026, 6:36 AM ET / 10:36 UTC. Summary PR surface: Source +5, Tests +63. Total +68 across 2 files. Reproducibility: yes. Source inspection shows current main opens the shared realtime transcription 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
Maintainer decision needed
Security Review detailsBest possible solution: Land the shared transport-level cap after the assigned maintainer accepts 16 MiB as the intended all-provider transcription ceiling, or tune the constant and boundary tests to a provider-backed ceiling before merge. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows current main opens the shared realtime transcription Is this the best way to solve the issue? Yes, subject to maintainer acceptance of the cap value. The shared session helper is the narrowest maintainable boundary because all bundled websocket transcription providers route through it; per-provider caps would duplicate policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e595a8c0ac4b. Label changesLabel justifications:
Evidence reviewedPR surface: Source +5, Tests +63. Total +68 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
Review history (4 earlier review cycles)
|
|
Land-ready proof for
Known proof gaps: no live external transcription-provider call. That is intentional: this untrusted contributor head was kept secretless, while real loopback WebSocket boundary tests exercise the changed transport behavior directly and deterministically. |
|
Merged via squash.
|
What Problem This Solves
Fixes an issue where a realtime transcription websocket session would buffer an arbitrarily large inbound frame from the upstream provider before parsing it. The generic session (
src/realtime-transcription/websocket-session.ts) backs every websocket transcription provider (OpenAI, Mistral, xAI, ElevenLabs, Deepgram), so a buggy or hostile upstream could push an unbounded frame straight intoJSON.parsewith no size ceiling.Why This Change Was Made
The session now passes
maxPayloadto thewsclient, matching the existing realtime voice cap.wsrejects an over-limit frame with an error and a 1009 close before it assembles the message, so an oversized frame never reachesonMessage/parseMessage. The 16 MiB cap leaves large headroom over real transcript frames (KB-scale) while replacingws's 100 MiB default.User Impact
Operators running any websocket transcription provider get a bounded failure on a malformed oversized frame instead of unbounded buffering; legitimate transcript traffic is unaffected.
Evidence
pnpm test src/realtime-transcription/websocket-session.test.ts— 12 passed, incl. two new boundary tests (legit large frame delivered, oversized frame dropped before the parser).tsgo:coreandtsgo:core:testclean;oxlinton changed files clean.createRealtimeTranscriptionWebSocketSession) over a realwsconnection, both boundary sides:proof-live.ts
AI-assisted: built with Codex