Repository navigation
Replies: 12 comments
|
源码侧全部核实(本地 0.1.2-alpha.1 = cd5ef81;alpha.2 仅版本号变动,web-fetch-http 源码与你的引用一致)。你的四条根因论断逐条都能对上,且这组文件里有一个你可能没注意到的现成注入点,让修复比想象中更顺。 核实结果(packages/web/web-fetch-http/):
增量发现(对修复评估重要):解析器注入点其实已经存在—— 三条建议的评估:
另:不建议把 198.18.0.0/15 直接当公网段放行(第三种隐式变体)——那等于对所有 DNS 答案开放该段,信任面是隐式的且无配置痕迹,不如显式配置可审计。 结论:方向 1 先行(外科手术式、守卫语义不变、有现成注入点),方向 2 作为配置面补充并注意收窄豁免范围,方向 3 立即补。PR 通道重开后这是可落地的候选;若先出插件形态(在 web-fetch-http 外注册包装 provider)也能验证思路,但配置口最终应在 in-tree。 |
|
感谢逐条核实,特别是 1. resolver 建议直接支持 DoH 形态(而非仅 UDP 指定服务器)。 真实受害部署里,OpenClash/Clash TUN 普遍劫持 UDP53: 2. allowDomains 收窄方案同意。 rebinding 反例成立——"仅豁免 198.18.0.0/15 等保留段、RFC1918/loopback/link-local 照拒"是正确形态。 |
|
Re-anchored against alpha.2 (
The fix direction satisfies #5202 and #4893 at once. Verified current alpha.2: On the DoH point (eddiedon) — agree on the threat model, one precision: The UDP53-hijack concern is real: under OpenClash/Clash TUN the transparent proxy intercepts plain UDP53, so One precision: "undici 有现成实现" is slightly optimistic — undici's Agent accepts a custom On allowDomains narrowing — agreed, and it's the constraint that keeps the triangle closed: exempt only the fake-ip range (198.18.0.0/15) and any user-declared CIDRs; keep RFC1918 / loopback / link-local rejected so #3051's security intent is preserved. That is also exactly what #4893 is asking for — a configurable allowlist that the SSRF guard still filters through. The test pattern is already there too ( |
|
补一个 macOS + Surge(增强模式) 的数据点,确认这不是 OpenClash / 路由器部署特有的问题,并且与你在 #5202 的结论逐条一致: 环境
表现 $ scutil --dns | grep -A1 "if_index : 31"
nameserver[0] : 198.18.0.2 # Surge 的虚拟 DNS
$ dig +short www.themoviedb.org @198.18.0.2
198.18.2.78
$ curl -sS -o /dev/null -w '%{http_code} %{remote_ip}\n' https://www.themoviedb.org/
200 198.18.2.78 # TUN 正常接管而 两点 macOS 特有的补充
0.1.5-rc.1 复核(与 argszero 在 alpha.2 上的结论一致)
也就是说从 alpha.2 到 rc.1,注入点一直存在、也一直没接到配置面上。另外这个组合在 v4.1 那条模型可用、web_fetch 不可用的用户体感上也很明显:模型会老老实实报告"抓取被安全策略拦截",而不是回退到别的抓取通道,对不熟悉 fake-IP 的用户基本无从排查。 (原帖 #5202 提到的方向我完全同意:resolver 注入是最外科的做法;若要加 allowlist,收窄成"只豁免 fake-IP 段、RFC1918 / loopback / link-local 照拒"才可以同时满足 #3051 的安全意图。) |
|
补一个 macOS + Clash Verge Rev 的数据点,以及三点前面没被提到的增量。 环境:macOS / Node v24.3.0;Clash Verge Rev,TUN 模式( 1.
|
ipaddr.js |
ipaddr.parse('198.18.0.77').range() |
isPublicIpAddress() 结果 |
|---|---|---|
1.9.1 |
unicast |
true(放行) |
2.5.0 |
reserved |
false(拒绝) |
web-fetch-http 钉的是 ^2.5.0,所以现状是拒绝。但这意味着拦截结果会随依赖升级而变,并非稳定契约。建议在 fetch-http.spec.ts 里用一个写死的 198.18.x.x 断言把该分类显式钉住:否则未来某次依赖变动会静默改变安全行为——而且两个方向都危险(漏放也是)。
2. ~/.dsh/.env 是既有的、只作用于 harness 自身的逃生路径
上面提到"唯一的既有逃生口是把整个 harness 出站指向代理端口——代价过大"。补充一点限定:它不需要导出到 shell。~/.dsh/.env(Harness-home 层)是唯一允许设置 HTTP_PROXY / HTTPS_PROXY / NO_PROXY / ALL_PROXY 的 .env 层(app-boot/src/index.ts:126);项目目录的 .env 写这些名字会被直接拒绝启动(app-boot/tests/app-boot.spec.ts:143)。影响面因此限于 harness,不动 shell 与其他进程。
本机实测(fake-ip 全程开启,未改动任何解析器):
~/.dsh/.env:
HTTPS_PROXY=http://127.0.0.1:7897
https://damodev.csdn.net/ -> HTTP 200
https://www.google.com/ -> HTTP 302
走的正是 provider.ts:134 的 proxyRouteFor(url) → requestVia:跳过本机解析与 pinning,真实解析交给代理。两点注意:
- 它不替代定制 resolver 那个修复方向,只是当下可用的 workaround;
dsh-http-proxy只接受http:/https:形态的代理 URL(policy.ts:57),写socks5://会被跳过并只留一条诊断。
3. 一个可用于回归验证的对照基线
同一会话、同一时刻:web_search 正常——web-search-deepseek/src/provider.ts:225 用原生 fetch,全程不检查解析结果,它的 api.deepseek.com 同样解析到 198.18.3.5 却工作正常。Claude Code、Codex、curl、浏览器在同环境下也均正常。也就是说这是 web-fetch-http 独有的失败模式,修复后可以拿这个对照确认"只有它变了、别的没受影响"。
|
给「今天就能用」的逃生路径补一个机制级证据(今天在 #5797 已核实,与 Agzer0 实测的 ~/.dsh/.env 路径是同一机制):
|
|
我根据本讨论的 resolver 注入思路实现了一个可运行插件:
|
|
Workaround, not a fix. Correction to the
The minimal single variable is Effective on next launch; loopback is auto-bypassed. Literal loopback/metadata IPs stay blocked — only the #6019 caveat remains. |
|
对于 Clash 用户可以应用如下设置 dns:
...
fake-ip-range: 28.0.0.1/8
fake-ip-range6: 3ffe::/16
... |
|
Another data point — plus a state-aware variant for machines that toggle the proxy. Windows 11, client 猫猫云 (mihomo core, I re-verified the OP's root-cause chain on this install: system resolver -> The env-proxy path works — but a static
Only if all three pass does it inject Two details that matched other comments here:
Security is unchanged: only the hostname path is proxied; IP literals are still rejected, exactly as Measured with fake-ip still active and TUN untouched: This is a workaround, not a fix. I fully support the OP's preferred direction: wire the existing 中文一句话版:同一环境下复现了这个 bug。静态写死代理在「代理时开时关」的机器上会让 DSH 整个断网(模型 API 也 ECONNREFUSED),所以改成启动时三步探测再决定注入代理还是直连; |
|
补充几点,不重复 @argszero 已经核实过的调用链、注入点和方案取舍。 Windows 上另一种失败点:解析成功了,卡在分类我这台机器:Win11,DSH 桌面版,Clash Verge(mihomo TUN + fake-ip 1/16),没设任何 proxy 环境变量。 DNS 没失败,拿到 fake-ip 之后被 6019 和 5202 其实是同一处代码的两个方向
所以「有代理就跳过校验」(#10672 里 argszero 指出的 rc.2 实际行为)修好了 5202,同时把 6019 坐实。想一次盖住两边,只有方案①:把已存在的 我在 5202 里想看到的验收标准是「默认直连路径下 fake-ip 可用,同时代理路径的 SSRF 不弱于现状」,不然容易被读成「放宽就好」。 一个外部先例openclaw/openclaw#52162 撞过同一类冲突(Clash fake-ip + SSRF 守卫)。最后进 main 的写法是: // packages/memory-host-sdk/src/host/remote-http.ts
const MEMORY_REMOTE_TRUSTED_ENV_PROXY_MODE = "trusted_env_proxy";
...
...(shouldUseEnvProxy(params.url) ? { mode: MEMORY_REMOTE_TRUSTED_ENV_PROXY_MODE } : {}),有 proxy env 就切模式,跳掉本地预解析。思路跟 DSH 现在的 顺带:给别人支招前先查一下#10672 的结论是 profile 目录下有一份重复的 有副本就说明得先清理 profile 的独立安装。我这边查了没有, 环境:DSH 桌面版 profile |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Description
Title:
web-fetch-httpSSRF guard rejects every fetch under transparent-proxy fake-ip DNS (198.18.0.0/15) — no resolver/allowlist escape hatchSummary
Since v0.1.2, the new default public fetch backend (
@deepseek-ai/dsh-web-fetch-http) rejects all fetches to foreign domains when DSH runs on a network whose DNS answers with fake-ip addresses (198.18.0.0/15) — the standard DNS mode of transparent proxies (OpenClash / Clash / mihomo TUN), which is an extremely common home/office deployment in China. The domain resolves via the system resolver to a reserved-range IP, the SSRF guard correctly classifies it as non-public, and the whole answer set is rejected (WEB_BLOCKED_URL). There is no configuration to point the provider at a different resolver or to allowlist specific domains, so the shippedweb_fetchtool degrades to "domestic direct domains only".Environment
0.1.2-alpha.2(Windows 11, host-side — unrelated to the file sandbox)Resolve-DnsName example.com→198.18.21.38,github.com→198.18.0.7(fake-ip range), while CN-direct domains (e.g.www.baidu.com→180.101.51.73) resolve to real public IPsReproduction
Any tool bypassing the guard (e.g. Node
fetchinside the DSH sandbox) reaches the same URLs fine — the network path is healthy; only the guard's view of DNS is "poisoned" by fake-ip.Root cause (from
0.1.2-alpha.2sources)@deepseek-ai/dsh-web-fetch-http(src/network.ts, builtlib/index.js~L54-78):lookup(hostname, { all: true, order: "verbatim" })fromnode:dns/promises(getaddrinfo) → returns the fake-ip.isPublicIpAddress()= ipaddr.jsrange() === "unicast"; 198.18.0.0/15 (RFC 2544 benchmarking, used by Clash-family fake-ip) classifies as reserved → rejected.allowPrivate. README documents the caps (timeouts/bytes/chars) as the only knobs.Impact
web_fetchis effectively limited to domains that resolve to real public IPs (typically CN-direct domains). Foreign domains — the primary fetch targets (GitHub, docs, APIs) — always fail withWEB_BLOCKED_URL.Suggested directions (any one would fix this without weakening the SSRF guarantee)
resolver: <ip>or a DoH URL onweb-fetch-http. Resolution then returns real public IPs, the existing whole-set validation and connection pinning stay byte-for-byte identical — only the resolver is swappable. This is the most surgical fix and matches how other HTTP clients expose DNS overrides.allowDomains: ["github.com", "*.githubusercontent.com"]— an operator-asserted trust list that skips the non-public rejection for matching hostnames (still pinning to whatever the resolver returned). Clear, scoped, and loud in config.Workarounds in the wild (for other users hitting this)
fake-ip-filter/ dnsmasq whitelist) so they resolve to real IPs;fetch/MCP-based fetching tools instead of the shippedweb_fetch.Happy to test a build or provide more traces.
中文版
标题建议:
web-fetch-http的 SSRF 防护在透明代理 fake-ip DNS(198.18.0.0/15)环境下拒绝一切外域抓取,且无 resolver/allowlist 配置口一句话:0.1.2 默认启用的公网 WebFetch,在路由器 OpenClash/Clash fake-ip 模式(国内最常见的透明代理 DNS 部署)下,外域全部报
WEB_BLOCKED_URL——域名经系统解析拿到 198.18 假 IP,SSRF 校验按保留段拒绝整组结果。国内直连域名(真实 IP)不受影响。根因:
dsh-web-fetch-http用系统解析器(getaddrinfo)+ ipaddr.jsrange() === "unicast"判定 + 任一地址非公网即整组拒绝。这是正确的防 DNS rebinding 设计,但 fake-ip 部署下解析结果永远不可能通过校验,而配置面上没有任何换 resolver / 域名白名单的口子。建议(任一即可,均不削弱 SSRF 保证):
allowDomains信任清单:按域名豁免非公网拒绝,运营者显式断言;临时绕行:代理侧 fake-ip-filter 放行所需域名 / 本机 hosts 固定真实 IP / 用 node fetch 或 MCP 类抓取工具。
All reactions