[security] No cap on concurrent WebSocket sessions; every connection spawns its own ffmpeg process and never idles out
Security Finding: No cap on concurrent WebSocket sessions; every connection spawns its own ffmpeg process and never idles out
Severity: HIGH (CVSS 8.7)
CWE: CWE-770
Repository: QuentinFuxa/WhisperLiveKit
Affected: - whisperlivekit/basic_server.py:156-162
Description
The server accepts an unbounded number of WebSocket sessions and gives every one of them a dedicated ffmpeg decoder as soon as the socket is accepted — before a single byte of audio arrives — and it never closes a session that falls silent. A client that connects and then sends nothing therefore pins a child process and a set of file descriptors for as long as it keeps the socket open.
The path is the same for each connection. websocket_endpoint (whisperlivekit/basic_server.py:94-162) calls await audio_processor.create_tasks() (basic_server.py:156) immediately after accept(). With the default pcm_input=False (config.py:80), that call starts FFmpegManager.start() (whisperlivekit/audio_processor.py:948-951), which execs ffmpeg with three pipes (whisperlivekit/ffmpeg_manager.py:65-72). The receive loop then blocks on await websocket.receive_bytes() (basic_server.py:161) with no idle timeout, unlike the Deepgram-compatible path (deepgram_compat.py:1043-1057), so silence is never punished.
The Deepgram-compatible endpoint (basic_server.py:195-204) behaves the same way. Neither handler enforces a connection count, semaphore, or rate limit, and the server is started without limit_concurrency (basic_server.py:659-682), so resource consumption grows in direct proportion to how many sockets an attacker opens.
Impact
An unauthenticated attacker can exhaust the process table and file descriptors with idle connections, denying service to legitimate clients; memory is also consumed by the per-session queues and asyncio tasks that stay resident for as long as the sockets are held open.
Remediation
- Add a global
asyncio.Semaphore(or equivalent counter) around session creation in bothwebsocket_endpointanddeepgram_websocket_endpoint(whisperlivekit/basic_server.py), rejecting connections above a configurable maximum concurrent-session cap;--pcm-inputcan additionally be used to avoid a per-session ffmpeg. - Start ffmpeg lazily on the first audio frame instead of inside
create_tasks. - Wrap the
/asrreceive loop in an idle timeout mirroring the Deepgram path's 30 s silence guard (deepgram_compat.py:1043-1057). - Pass
limit_concurrencytouvicorn.run(basic_server.py:659-682).
Verified patch (autofix): Streaming sessions are now admission-controlled and self-reaping instead of unbounded. Both WebSocket handlers (/asr and /v1/listen) must reserve a slot from a process-wide counter before accepting, and reject connections above the configurable maximum (new config/CLI option max_concurrent_sessions / --max-concurrent-sessions, default 64) with close code 1013; the slot is always released in the existing finally blocks, so a session can never leak capacity. The /asr receive loop now waits for audio with an idle timeout (new config/CLI option session_idle_timeout / --session-idle-timeout, default 60 s, 0 disables) and closes a session that sends nothing, mirroring the Deepgram endpoint's silence guard, which frees the decoder child process and descriptors held by silent sockets. The CLI entry point additionally passes limit_concurrency to uvicorn so excess connections are refused with HTTP 503 before they reach the handlers. Together these bound the number of per-session ffmpeg processes/file descriptors to the configured cap and free them again when a client only holds a socket open.
Affected Code
whisperlivekit/basic_server.py:156
results_generator = await audio_processor.create_tasks()
websocket_task = asyncio.create_task(
handle_websocket_results(websocket, results_generator, diff_tracker)
)
while True:
message = await websocket.receive_bytes()
await audio_processor.process_audio(message)
whisperlivekit/audio_processor.py:950
if not self.is_pcm_input:
success = await self.ffmpeg_manager.start()
if not success:Verification
Adversarially verified (GLM) — passed.
Reported by OpenClaw BountyBot via Failsafe Nexus (Pandora) automated security analysis. Please review carefully before acting.
Source: QuentinFuxa/WhisperLiveKit