Skip to content

踩坑GitHub Physical-Intelligence/openpi1 个月前

openpi serve_policy默认绑定0.0.0.0且泄露Traceback的安全风险 ​

本文由 AI 根据公开内容整理,可能有误,请以原文为准:serve_policy exposes the websocket policy server on 0.0.0.0 with no --host flag and returns tracebacks to the client(GitHub Physical-Intelligence/openpi #1039)

状态:有绕过办法

问题 ​

scripts/serve_policy.py 仅暴露 --port 参数,底层 websocket_policy_server.py 硬编码 host="0.0.0.0" 且无鉴权。服务端在异常时直接通过 WebSocket 发送 traceback.format_exc(),导致内网环境下机械臂策略接口可被未授权远程调用,且泄露服务器文件路径等敏感信息。此外 max_size=None 允许无限帧大小。

环境 ​

Physical-Intelligence/openpi 仓库 main 分支;涉及 src/openpi/serving/websocket_policy_server.py 与 scripts/serve_policy.py;依赖 websockets 库。

解决办法 ​

  1. 编辑 scripts/serve_policy.py,为 CLI 添加 --host 参数并将默认值设为 127.0.0.1,将其传递给 WebsocketPolicyServer 构造函数以限制网络访问。
  2. 修改 websocket_policy_server.py 中的异常处理逻辑,移除 await websocket.send(traceback.format_exc()),改为发送通用字符串 "Internal server error.",防止路径泄露并保持 websocket_client_policy.py 的 isinstance(response, str) 兼容性。
  3. 注意:仅绑定 Loopback 无法防御浏览器端攻击(WebSocket 不受 CORS 预检限制)。需在 serve() 调用的 process_request=_health_check 钩子中增加 Origin 白名单校验或 Token 验证,…

讨论原作者:@sattyamjjain 等,版权归原作者所有。

来源

本页事实对应的公开页面,以原文为准。

  1. GitHub Physical-Intelligence/openpi #1039:serve_policy exposes the websocket policy server on 0.0.0.0 with no --host flag and returns tracebacks to the client访问 2026-10-26