#1043·openpi

websocket_policy_server sets max_size=None, allowing unbounded message size (resource-exhaustion DoS)

Author: 0206pdhCreated Sep 12, 2026Updated Sep 13, 2026

Problem

WebsocketPolicyServer.run() always passes max_size=None to websockets.asyncio.server.serve(...):

https://github.com/Physical-Intelligence/openpi/blob/215abfb/src/openpi/serving/websocket_policy_server.py#L43

max_size=None disables the websockets library's own message-size protection (default 1 MiB). Any client that can open a websocket connection to the policy server can then send a single arbitrarily large message; websocket.recv() buffers the full message in memory before _handler gets a chance to run, so a large enough message can exhaust the server's memory and crash the process that is driving the robot.

This is a different failure mode from #1039 (network exposure / traceback disclosure): even with --host 127.0.0.1 and no traceback leakage, any client that is allowed to connect at all can still send an unbounded payload.

Proposed fix

Add a bounded (but generous) default max_size, with the value overridable via the WebsocketPolicyServer constructor for callers who intentionally need larger messages:

  • default cap large enough to comfortably fit a real observation (e.g. several 224x224x3 uint8 camera frames + robot state, well under 1 MiB in practice) with a lot of headroom for larger custom observations
  • keep it a constructor parameter (not hardcoded) so a library caller can opt back into max_size=None explicitly if they know they need it

Scope

Only this constructor default. Not proposing authentication, TLS, or rate limiting here.

I'd like to send a PR for this — happy to adjust the default value if you have a different number in mind.

Source: Physical-Intelligence/openpi