Skip to content

[PR] fix(launcher): the claude child stops inheriting a proxy and CA it cannot use (#3446) - #3856

Closed
aolshevskiy wants to merge 2 commits into
ranxianglei:masterfrom
aolshevskiy:2026-10-19_claude-child-proxy-env
Closed

aolshevskiy wants to merge 2 commits into
ranxianglei:masterfrom
aolshevskiy:2026-10-19_claude-child-proxy-env

Conversation

@aolshevskiy

@aolshevskiy aolshevskiy commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

(ai: deepseek/deepseek-flash)

Closes #3446.

Duplicate screening (§7.1) found #3446 (the report) and #3448 (an open fix by the owner). This PR is #3448's head rebased onto master (6deb4547, the #3781 release merge) plus one additive commit. The fork cannot push to #3448's branch, so it lands here; if you prefer, fast-forward #3448's branch to this head and close this one — the trees differ only in src/launcher.ts's claude preset row, the auxProxy health field in src/server/admin.ts, the tests and the docs, so a squash also works. Commits:

  • b6b20018 — [PR] fix: keep /bili/ base-URL legs direct when clients honour proxy envs (Claude Code 2.1.301 self-tunnel 403) #3448 as rebased onto master, author preserved. One conflict resolution: master's #1821 MCP-shell-watch sentence is kept in the README claude paragraph alongside your #3446 note (README.md, README.zh-CN.md); your launcher, test and CONFIGURATION hunks merged as written.
  • c3f63ef0 — the claude lane stops setting HTTPS_PROXY and NODE_EXTRA_CA_CERTS; the proxy this instance resolves for auxiliary egress is published as auxProxy on /__bili/health and handed to a child that has none of its own; CHANGELOG entry.

Why, on top of #3448

#3448 makes the leak harmless for the child; this removes it. After your NO_PROXY merge, HTTPS_PROXY=<our origin> governs nothing the claude child needs: its model traffic is plain http on loopback and reaches us directly via NO_PROXY, with no TLS hop to tunnel and no certificate for NODE_EXTRA_CA_CERTS to vouch for. What the variable still does is ride into every process the child spawns — in-session curl/git/npm issue CONNECT through our MITM and log tunnel destinations the token cache never sees. Both variables are gone from this lane.

The root-cause sentence in #3448 makes the same point from the other side: the design "assumed Claude Code ignores HTTPS_PROXY". Correcting that premise for the client removes the design's purpose, because the lane never wanted a proxy of its own.

Behaviour change (old -> new)

configuration before after
nothing configured child got HTTPS_PROXY=<bili origin> + NODE_EXTRA_CA_CERTS=<bili CA>; grandchildren tunnelled through bili no bili-owned proxy or CA; grandchildren go direct; /bili/ leg direct
user's shell proxy exported same bili-owned values; the user's own proxy never reached the child the shell proxy rides through untouched (the claude lane spawns with raw process.env); the NO_PROXY merge keeps /bili/ direct
only upstreamProxy in the config file, no shell proxy same bili-owned values the child gets that proxy as HTTP_PROXY/HTTPS_PROXY via the handoff; /bili/ still direct
child names a proxy of its own, either case, any scheme untouched untouched, and never probed
attached to a proxy started by an older build (no auxProxy key) n/a nothing handed over — we do not guess our own origin
configured proxy uses an unsupported scheme n/a dropped rather than handed to a child

No model request path changes

The claude lane's model traffic is unchanged: ANTHROPIC_BASE_URL → /bili/<real upstream>, plain http on loopback, direct by construction rather than by NO_PROXY compensating for a proxy we set ourselves. Both-mode reasoning holds for #3448's reason: no model request path changes. The only path that changes is out-of-band tool egress.

Kernel: untouched. Wire / compression modes: untouched (launcher plus one read-only health field).

The wider blast radius, stated plainly

#3448's safety argument is that a loopback-only exclusion cannot alter routing to real upstreams or corporate proxies. This change does alter it, deliberately: curl/git/npm inside a session stop tunnelling through our MITM, which is the leak. Corporate egress survives — the child keeps its own proxy, or receives the one this instance resolves — and what stops is our instance sitting in the path. NODE_EXTRA_CA_CERTS goes for the same reason: nothing on this lane has a TLS hop for it to vouch for.

Tests

  • tests/launcher.test.ts — claude env assertions flipped: no HTTPS_PROXY, no NODE_EXTRA_CA_CERTS, baseEnv preserved, a shell proxy rides through untouched, childNamesProxy covers any scheme in either case. [PR] fix: keep /bili/ base-URL legs direct when clients honour proxy envs (Claude Code 2.1.301 self-tunnel 403) #3448's NO_PROXY tests (merged triple, union + dedupe, already-complete unchanged, raw-https upstream wins, codex untouched, codebuddy parity) unchanged and passing.
  • tests/aux-proxy-handoff.test.ts (new) — handoff applies both variables; a child naming a proxy is left alone and never probed; nothing to hand over leaves the env unchanged and never names bili's own origin.
  • tests/admin-probe.test.ts — health reports auxProxy + auxProxySource for the inherited-shell tier, the config tier, the explicitly-direct case, and drops an unsupported scheme.

Local, on the rebased tree: node --import tsx --test tests/{launcher,admin-probe,aux-proxy,aux-proxy-handoff,fix-1292-windows-claude-settings,launcher-plugin-mode}.test.ts → 360 pass / 0 fail / 1 skipped. npm run check:test-import-graph and npm run check:unused-exports clean. npm run typecheck fails only on the optional jimp dependency absent from this clone (src/image-rescale.ts), pre-existing and unrelated. Full-suite verdict = CI.

CI: the unused-exports red is master-side

unused-exports fails on this PR with one line, and that line is not in this diff:

✗ 1 unused export(s):

  INTERNAL_ONLY src/log-mask.ts: maskUrlForPublish

a4f27307 ("mask private endpoint hosts in the publish-boundary diagnostics blob") exports maskUrlForPublish, and every reference to it sits inside src/log-mask.ts itself — the declaration at line 121, a doc-comment mention at 133, and the single call at 137 inside maskUrlsForPublish. Nothing outside that file imports it, which is the INTERNAL_ONLY shape the gate rejects.

Measured on a clean worktree rather than inferred: upstream/master at 8a00095d fails the gate with nothing else applied, and this branch fails on that same single line both as pushed (based on 6deb4547) and replayed onto 8a00095d. This diff touches no log-mask file. static-gates and test are skipped behind the merge gate rather than failing; whether they pass is untested here.

Fix, per the gate's own message: drop the leading export at src/log-mask.ts:121, leaving maskUrlsForPublish as the public entry. Left out of this PR deliberately — it is unrelated to the claude lane, and it wants its own one-liner against master, which unblocks every open PR at once.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重:不重复,是超集关系。 本 PR = owner 的 #3448(NO_PROXY 合并修复)rebase 到 master + 一个增量 commit(claude lane 彻底移除 HTTPS_PROXY/NODE_EXTRA_CA_CERTS,改由 /__bili/health 的 auxProxy 字段向子进程移交本实例的 aux egress)。声明 Closes #3446;若本 PR 合入,#3448 的内容已被完整包含,#3448 应随之关闭(PR 正文自己也提出了这个处置)。

标签: bug claude-code scope/wiring p1(理由:Claude Code ≥2.1.301 上 bili claude launcher 车道每个请求都撞 403 自隧道,功能不可用;代理/CA 泄漏进子进程是次要面)。

审核进行中:分支已取回并 rebase 到最新 master——唯一冲突是 CHANGELOG 条目顺序,已按「新条目在顶」解决、两侧内容全保留。本地 typecheck / build / 定向测试(launcher、aux-proxy-handoff、admin-probe 等 6 个文件):360 pass / 0 fail / 1 skipped,与作者自报一致。CI 上 unused-exports 红已核实为 master 侧 #3811 引入的孤儿导出(#3871 正在修),与本 PR 无关,不并入本 PR。最终结论按八问体例单独回复。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

PR #3856 审核结论(八问)

1. 是什么问题:Claude Code ≥2.1.301 开始遵守代理环境变量,而 bili claude launcher 一直往子进程环境里盖 HTTPS_PROXY=<bili 自己的 origin> + NODE_EXTRA_CA_CERTS=<bili CA>——于是每个指向 /bili/ base URL 的模型请求都自隧道回 bili 自己,被拒 403 tunnel_destination_denied: self,会话完全不可用(#3446)。次要面:这两个变量泄漏进所有孙进程,会话内 curl/git/npm 全部 CONNECT 穿过 bili 的 MITM,记录下一堆 token 缓存看不到的隧道目标。

2. 什么原因导致的:缺陷的生产者 = launcher 给这条车道的子进程盖了它根本不需要的代理变量。claude 车道走 ANTHROPIC_BASE_URL=/bili/<upstream> plain-http loopback,没有 TLS 跳、没有证书可背书;「CC 的 undici 忽略代理变量」这个假设在 2.1.301 起失效。修在源头:preset 行改 proxy:false, caKeys:[](与 gemini/iflow/antigravity 同类),NO_PROXY loopback 合并作纵深防御(防用户自带 shell/公司代理的车道),auxProxy 移交补上「孙进程可用出口」。

3. 影响范围与严重程度:p1——CC ≥2.1.301 用户经 bili claude 启动时每个请求 403,功能不可用(报告环境:Windows、bili 0.1.197、CC 2.1.301 原生 exe;NO_PROXY=127.0.0.1,localhost,::1 绕行已证实有效)。旧版 CC 不受影响。泄漏面影响所有版本的 claude 车道(多余隧道日志 + 孙进程出口被劫持风险)。

4. 怎么修复的:两层。① #3448 内容(commit 19e292da5,owner 作者保留):凡 base URL 被 wrap 到本实例 origin,就把 localhost/127.0.0.1/::1 并入 NO_PROXY/no_proxy(保用户原值、两种大小写变体、去重)——无论客户端哪个版本、是否自带代理,/bili/ 腿恒直连。② 增量 commit 6332f3c53:claude preset 彻底移除 HTTPS_PROXY/NODE_EXTRA_CA_CERTS;把本实例为 aux 请求解析出的出口代理以 auxProxy/auxProxySource 发布在 /__bili/health(复用 resolveProbeDecision 同款决策,只读附加字段);launcher 仅在子进程未自报任何代理(6 个键任一大小写)时移交 HTTP(S)_PROXY,自报了则完全不探测不改动,旧构建无该字段则不移交、绝不猜自己的 origin。

5. 是否有回归问题:逐条审过触碰路径的既有行为——模型流量路径不变(/bili/ plain-http loopback,plugin/non-plugin 两条 spawn 路径都在测试里钉住);baseEnv 保持完整;其余车道唯一变化是 codebuddy/gemini/iflow/antigravity 在 base URL wrap 到本实例时也获得 NO_PROXY loopback 合并——纯保护性(loopback 从来不是合法 MITM 目标,自/私网隧道本就拒绝),与 jcode/aider/zed/qwen 既有静态 extras 同模式;health 端点形状为附加字段,既有消费者按键解析不受影响;缓存/重试/游标不动;kernel/wire/两种压缩模式不动;native claude 车道(plugin-install.ts)核查无代理环境变量盖章,不涉及。fail-fast 检查:handoff 探测失败降级为「不移交」(即今日状态),有 stderr 一行,非吞错。无意回归:未发现。

6. 是否破坏缓存:不涉及——消息字节不变,前缀缓存稳定性不受影响;无缓存键/重试策略/增量游标变更。

7. 是否改了设计方向:无架构转向。一个明确的方向陈述:claude 车道从「盖代理变量、指望客户端忽略」转为「子进程环境不携带任何 bili 自有代理/CA,出口显式化(自带或实例解析的 aux)」;health 表面新增两个派生只读字段。

8. 是否引入了新的配置:无。没有新 env/config/CLI flag;auxProxy 是派生 health 字段,CONFIGURATION.md 中英已同步文档化。


验证证据

合入判定与待办

@ranxianglei

Copy link
Copy Markdown
Owner

ework ci失败

ranxianglei pushed a commit to aolshevskiy/billion-context that referenced this pull request Oct 20, 2026
…ed-exports gates

The PR head was based on master@39fb841d, which predates two fixes that
already landed on master and were the only failing checks on this PR:
- ranxianglei#3870 regenerated CONFIGURATION.md / .zh-CN.md, dropping 4 stale
  duplicate storage.* rows          -> docs-sync gate
- log-mask.ts dropped the unused `export` on maskUrlForPublish
                                              -> unused-exports gate

Merging origin/master (838e975) brings both fixes in cleanly (zero
conflicts). The PR's own claude-launcher changes (src/launcher.ts, the
auxProxy field in src/server/admin.ts, its tests, and the ranxianglei#3446 doc notes)
are preserved untouched.

Verified locally on the merged tree: `gen-config-docs.mjs generate` then
`git diff --exit-code` is clean; `check-unused-exports.mjs` reports clean.

CI auto-fix lane for PR ranxianglei#3856 (failed head 9dd9375).
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

CI 两条红门(docs-sync、unused-exports)已在 PR 分支上修好并推送;新 head 1dcbbb61a 上这两条已转绿,其余快门全绿,仅剩重量级 test 分片还在跑(与本次改动无关,此前即为绿)。

根因(不是本 PR 的代码问题):PR 头基于旧 master(39fb841d),而这两处 master 后来已各自修掉,PR 分支没跟上:

修法:把当前 master(838e9758)merge 进 PR 分支(零冲突),继承 master 已有的两处修复,而不是手改这两个文件。PR 自身的改动(src/launcher.ts 的 claude preset、src/server/admin.ts 的 auxProxy、两个测试、#3446 文档说明)原样保留,作者提交历史不动。

本地核验(在 merge 后的树上实跑):gen-config-docs.mjs generate 后 git diff --exit-code 干净;check-unused-exports.mjs 报 clean。


结构化结论(八问)

  1. 是什么问题:PR 的 docs-sync、unused-exports 两条 CI 检查红,挡住合并。
  2. 什么原因导致的:PR 基于旧 master,这两处 master 之后已分别修复(CI static gates (unused-exports + docs-sync) red on master since 2026-10-19 - all PR test lanes skipped #3870 文档重生成、log-mask 去多余 export);PR 分支未同步,带旧状态跑 CI 即红。属「分支落后于 master」,非 PR 自身缺陷。
  3. 影响范围与严重程度:仅影响本 PR 能否合并,不影响任何用户或运行时行为;属 CI 门禁问题,非产品缺陷。
  4. 怎么修复的:将最新 master merge 进 PR 分支(零冲突),继承 master 已有修复,避免手工改文件引入偏差。
  5. 是否有回归问题:无。本次只同步 master,不碰 PR 功能代码;PR 原有改动逐文件核对仍在(auxProxy×5、launcher 的 [Bug] bili claude: Claude Code 2.1.301 honours HTTPS_PROXY, so the /bili/ base URL self-tunnels (403 tunnel_destination_denied: self) #3446 引用、两个测试文件均在)。语义漂移 / fail-fast 变吞错 / 阈值时序漂移等高危模式均不涉及。
  6. 是否破坏缓存:不涉及(仅文档 + 一个 export 关键字,无缓存 / 游标 / 去重键变化)。
  7. 是否改了设计方向:不涉及。claude child 的 proxy/CA 设计行为完全未动。
  8. 是否引入了新的配置:不涉及。无新 env / config / 默认值。

收工判定:两条红门已修绿并推送,PR 现为 mergeable(无冲突),待剩余 test 分片跑完即可合并;本次为纯 CI 修复,无任何行为变更。

awork and others added 2 commits October 22, 2026 03:19
- claude preset emits neither `HTTPS_PROXY` nor `NODE_EXTRA_CA_CERTS`: its `/bili/` base URL is plain http on loopback, so nothing was ever tunnelled or trusted, and every child (`curl`, `git`, `npm`) issued CONNECT through bili's MITM instead of going direct.
- `/__bili/health` gains `auxProxy`/`auxProxySource`, the proxy an AUX (blind-tunnel) request resolves to — `/__bili/upstream` answers for the model upstream, where provider and fallback tiers outrank the env tier.
- the launcher hands that proxy to a claude child with no proxy env of its own and leaves a shell-configured child strictly alone; an absent field (pre-handoff build, or explicit direct mode) hands over nothing, never bili's own origin.
- CONFIGURATION told Claude Code users to set both variables, re-creating the leak; undici ignores `HTTPS_PROXY` anyway (same file, later section).
- tests: four claude env assertions flipped to absence, plus handoff unit coverage and the health wire fields.
@ranxianglei

Copy link
Copy Markdown
Owner

(ai: zhipuai-lb/glm-5.3)

已并入合并列车 #4525(master 6d7c587,合并方式 merge commit,提交保留原作者署名)。本 PR 关单收尾;若列车中对应提交出问题,回滚点为 #4525 单提交 revert。

感谢 @aolshevskiy 的贡献——你的提交以原作者署名随列车进入 master(合并方式为 merge commit),仓库贡献者列表可见。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] bili claude: Claude Code 2.1.301 honours HTTPS_PROXY, so the /bili/ base URL self-tunnels (403 tunnel_destination_denied: self)

2 participants