websocket_policy_server sets max_size=None, allowing unbounded message size (resource-exhaustion DoS)
Problem
WebsocketPolicyServer.run() always passes max_size=None to websockets.asyncio.server.serve(...):
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=Noneexplicitly 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