Skip to content

AAK-WEBSOCKET-SERVER-001: A WebSocket server for MCP, model or policy traffic leaves its defaults open

Severity
MEDIUM
Category
Transport Security (transport-security)
Scanner
agent_audit_kit/scanners/websocket_server.py
Auto-fixable
No.
SARIF name
WebSocketServerOpenDefaults

What it detects

A Python websockets server for MCP, model or policy traffic has no origins, max_size=None, or a 0.0.0.0 default with no authentication, or sends traceback.format_exc() to the client. In websockets the origin check is opt-in: origins defaults to None, which accepts every Origin, and a WebSocket handshake is not subject to the same-origin policy, so any page open on that machine can connect to ws://127.0.0.1:8000. Binding to loopback does not close that. max_size=None takes a frame of any size from whoever connected, and a traceback hands them the server's internals.

How to fix

Pass origins= with the origins you expect, or require a credential in the handshake through process_request, which a page cannot set on a WebSocket. Leave max_size at its 1 MiB default or set a bound. Send a fixed error string to the client and log the traceback on the server. Default the host to 127.0.0.1, and make listening on every interface an explicit choice.

To confirm the finding is gone, report only this rule:

agent-audit-kit scan . --rules AAK-WEBSOCKET-SERVER-001

Limitations

Reads serve from the Python websockets package, under any import name, and .send(...) of traceback.format_exc, format_exception or format_tb, or of a name assigned from one, in a file with mcp, policy, model, inference, agent or llm as a word of its path, or that imports mcp or fastmcp. So a websockets server anywhere else is not read, and neither is a FastAPI or Starlette WebSocket or unix_serve. Paths with a tests, fixtures, examples, samples or demos directory are skipped. A file that reads origin anywhere, or mentions authorization, basic_auth, api_key, bearer, token or auth as a word, is taken to check it, with nothing to show the check is applied. **options on the call stands the origin arm down, since it may set origins. A host is read as a literal, or as a name matching a parameter with host in its name and a literal default in the same file, so one from an environment variable or a config object is not. A source file over 512 KB is not read.

References

  • OWASP Agentic Top 10: ASI02 (Tool Misuse and Exploitation)
  • Adversa AI MCP Top 25 (AAK-defined ids): ADV-AUTH-01 (Missing Authentication)

All rules. This page is generated from the rule registry when the documentation is built; to change it, change the rule in agent_audit_kit/rules/builtin.py. To give the rule a hand-written write-up, add docs/rules/AAK-WEBSOCKET-SERVER-001.md: the page then shows that text, with the registry reference appended under it.