支持 --host 0.0.0.0 绑定局域网部署,并让特权 /api 方法跟随 trustedHosts #397
Jasonsun77
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
支持
--host 0.0.0.0绑定局域网部署,并让特权/api方法跟随trustedHosts,否则局域网管理页(配置/凭据)无法使用。验收与细节
背景
dsh Web 目前明确拒绝
--host 0.0.0.0(packages/bundle/web-app/src/startup.ts69-70 行):但同时存在两个问题,让这个"安全拒绝"既挡不住真正想暴露的人,又卡死了合法部署:
问题 1:CLI 检查可被
cordis.patch.yml完全绕过通过 home 级 patch 配置(
~/.dsh/cordis.patch.yml)给id: webserver设host: 0.0.0.0,CLI 的--host校验根本不生效——检查形同虚设。正经用户想绑局域网被 CLI 拦,得靠改配置文件绕;而真想暴露 RCE 的人照样能绕过。问题 2:即使绑了 0.0.0.0 + 配了
--trusted-host,特权方法仍钉死 loopback绑 0.0.0.0 后,
webRuntime.trustedHosts会正确采样局域网 IP 并传给 connection 插件的trustedHosts(非特权接口局域网访问正常)。但PRIVILEGED_METHODS(settings.*、credentials.*、llm.discoverModels、agentPreset.read/copy/openDocument/remove、host.pickDirectory/openPath)在packages/client/connection/src/index.ts的apply()里用硬编码空信任列表isTrustedApiRequest(request, [])钉死 loopback(146-149 行),导致:settings.describe/credentials.describe→ 403,配置页(Agent 预设、权限模块)无法加载trustedHosts才能用(升级会被覆盖,这就是我来提 issue 的原因)预期结果
支持显式
--host 0.0.0.0(或新增显式绑定开关),允许局域网/内网服务器部署特权方法的信任判定跟随配置的
trustedHosts(loopback OR 用户显式声明的--trusted-host),而不是硬编码空列表绑定 0.0.0.0 时给出明确的安全警告(RCE 风险),建议/要求显式
--trusted-host白名单,避免"裸绑 0.0.0.0"出现在公网验收条件:
dsh --profile web --host 0.0.0.0 --trusted-host <lan-ip>能正常启动并打印 LAN URLsettings.describe/credentials.describe返回 200(而非 403)--trusted-host时绑定 0.0.0.0 给出明确安全警告(或拒绝),不允许无白名单裸绑用户或模型可见变化:
cordis.patch.yml或改源码绕过 CLI 限制测试证据(环境:v0.1.0-rc.5 / commit 47f9438,Ubuntu,静态 IP 192.168.0.107):
dsh --profile web --host 0.0.0.0→error: --host 0.0.0.0 is intentionally not supported yet for safety...~/.dsh/cordis.patch.yml设webserver.host: 0.0.0.0):POST http://192.168.0.107:3080/api/agentPreset.list→ 200(非特权方法正常,trustedHosts 链路 OK)POST http://192.168.0.107:3080/api/settings.describe→ 403forbiddenPOST http://192.168.0.107:3080/api/credentials.describe→ 403POST http://127.0.0.1:3080/api/settings.describe→ 200packages/client/connection的 src + lib,把特权方法拦截的空列表改为trustedHosts(可让局域网全通,但升级会被覆盖,且等于改了安全边界——正是希望上游正规解决的原因)All reactions