Skip to content

[PR] fix(proxy): honor equivalent IPv6 bypass addresses - #6708

Merged
ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-14_ipv6-bypass-literals
Nov 14, 2026
Merged

ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-14_ipv6-bypass-literals

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Closes #6707.

Problem

matchesNoProxy() compares a URL-normalized IPv6 hostname against the original bypass token. Equivalent spellings therefore disagree: http://[::1] does not match NO_PROXY=0:0:0:0:0:0:0:1, and ::ffff:127.0.0.1 does not match the URL-normalized ::ffff:7f00:1. In auto proxy mode this sends a deliberately excluded upstream through the environment proxy. Exact IPv6 entries in Windows ProxyOverride have the same mismatch.

Change

Canonicalize valid IPv6 literal tokens with the same URL parser used for the target, after the existing port check. This covers expanded groups, leading zeros, alternative zero-compression positions and IPv4-embedded notation. The IPv6 addressing specification, section 2.2 defines these equivalent representations.

Only IPv6 literal comparison changes. Existing DNS suffixes, IPv4 matching, wildcard modes, explicit proxy precedence and malformed-token fallback are covered by controls. IPv4 addresses are not equated with IPv4-mapped IPv6 addresses. No setting, dependency or protocol shape is added; the shared proxy resolver applies in both plugin and proxy modes.

Verification

  • Base: 9495c764d36909eec263f404d4802d68b608f23f. The ten new tests produce 8 failures and 2 passing controls on the unchanged source.
  • A real IPv6 loopback upstream and a rejecting environment proxy reproduce the product failure through startServer(): the baseline sends CONNECT and returns 502. With this fix the same HTTP request reaches the IPv6 upstream directly, returns 200 with the expected JSON, preserves its request body and sends no CONNECT.
  • New regression matrix plus existing upstream proxy routing and skipped-proxy diagnostics: 35 tests passed, 0 failed, 0 skipped on Node 24.22.1/Linux. Windows bypass behavior is exercised with injected system proxy configuration; no registry state is changed.
  • Full project TypeScript checking, production build and git diff --check passed. Hosted cross-platform CI remains the full-suite verdict.

History check

Checked the complete cached Afloat16 PR file/patch index and all-state searches for NO_PROXY/IPv6 and matchesNoProxy. Read the relevant actual patches: #73 introduced the existing literal-string comparison; #2505 and #6211 change Windows wildcard handling; #6092 changes socket host/CONNECT authority spelling. #6577, #6583 and #6595 modify connection lifecycle, TLS trust or buffered tunnel data. None canonicalizes bypass address tokens.

@ranxianglei
ranxianglei merged commit d64086b into ranxianglei:master Nov 14, 2026
48 checks passed
@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b)

Post-merge review — this PR was merged to master at 12:50Z (via batch6-wave6, merge commit d64086b73c, now on origin/master), so this is a verification review of the merged state.

Duplicate screening: no duplicate. Independent all-state search for NO_PROXY/IPv6 and matchesNoProxy finds only #6707 (the source issue) and this PR. The Windows wildcard family (#2502/#2505) is a different mechanism (wildcard grammar, not address canonicalization); #609/#613 is updater egress — a different subsystem. Consistent with the PR's own history check.

Live state verified:

  • CI on PR head d7e316ac: 48 check runs — 36 success, 12 skipped, 0 failures.
  • The PR is a single linear commit on the claimed base 9495c764; the bypass hunk is unchanged on master (other batch6 PRs touched the same file's TLS-trust/CONNECT-buffering regions — separate threads, no conflict with this hunk; the test file is identical on master).

Independent verification (re-ran locally, did not take the PR's word for it):

  • Base 9495c764 + the 10 new tests: 8 fail / 2 pass — exactly as claimed; the two passing are the precedence and behavior-retention controls. The e2e test reproduces the product failure (CONNECT to the rejecting proxy → 502).
  • Merged head: 10/10 pass, including the real-server e2e (auto proxy mode, real IPv6 loopback upstream, real rejecting proxy, 0 CONNECT, 200, request body preserved).
  • Existing regression net on the merged head: upstream-proxy-routing + windows-bypass-leading-globs + skipped-proxy-hint = 41/41 pass.

Code review:

  • The fix sits at the decision point (the comparison inside matchesNoProxy), not a payload mask — root cause.
  • Both sides now go through the same URL parser (the target host is already URL-normalized; the token is canonicalized via the same targetUrl helper), so equivalence is structurally guaranteed — no hand-rolled IPv6 parser, no new dependency, no config surface.
  • Gates are tight: host.includes(":") (zero added cost for IPv4/DNS targets) + net.isIP(token) === 6 (only valid IPv6 literals are canonicalized).
  • The port check runs before canonicalization; the port boundary is preserved and tested.
  • Wildcard and suffix paths are byte-identical for all inputs (a canonicalized token never contains * and never starts with *./.).
  • Zone-index tokens degrade gracefully: net.isIP accepts [internal-ip6]%eth0 but URL parsing rejects it → the token is left unchanged → legacy literal comparison (no match, same as before, no crash) — covered by the ::1%lo test.
  • IPv4 is never equated with IPv4-mapped IPv6 (documented + tested) — a conservative, defensible boundary.
  • Pure widening: the target host is already canonical, so previously-matching pairs cannot break (canonicalization is idempotent); only equivalent spellings newly match.
  • Egress routing only (resolveProxyDecision), mode-agnostic — no wire/message-shape change, so both compression modes are unaffected; no new config/env/dependency.
  • Tests have teeth: both directions asserted (5 equivalence + 6 negative boundaries + precedence + controls), a true e2e through startServer() with listen(0) ports and full teardown in finally, no registry state touched.
  • Diff: 2 files, +119/−0, single commit, no unrelated changes.
  • Non-blocking nits: the variable literal (a URL object) would read better as canonical; the e2e test requires IPv6 loopback on the host (present on all CI runners; rare on IPv6-less local boxes). No action needed.

Behavior change (disclosed): NO_PROXY / Windows ProxyOverride entries written in an equivalent-but-non-canonical IPv6 spelling (expanded groups, leading zeros, alternate zero-compression, IPv4-embedded notation) now match — previously only the exact canonical spelling matched. Old → new, the intended fix; no other behavior change.

标签: bug + scope/wiring + p3(缺陷,出网代理边界,边缘场景可绕行)


结构化八问

  1. 是什么问题: NO_PROXY / Windows ProxyOverride 里的 IPv6 绕过条目,若写成非规范但等价的写法(展开组、前导零、不同零压缩位置、IPv4 内嵌写法),与 URL 规范化后的目标地址比对不上,auto 代理模式会把本应绕过的上游送进环境代理(代理拒绝时 502)。
  2. 什么原因导致的: matchesNoProxy() 用「URL 规范化后的目标 host」对比「原始 bypass token」,两侧规范化口径不一致——一边已 canonical、另一边没有,等价写法因此失配。
  3. 影响范围与严重程度: 仅「IPv6 上游 + 非规范 IPv6 绕过写法」组合触发;规范写法不受影响。p3 边缘场景,有绕行(写规范写法)。
  4. 怎么修复的: 在既有端口检查之后,把有效 IPv6 字面量 token 用与目标相同的 URL 解析器(targetUrl)规范化后再比较——两侧同一解析器,等价性由构造保证;不手写 IPv6 解析、不加配置、不加依赖。
  5. 是否有回归问题: 无。逐项核查: 独立 */<local>/端口检查/通配/后缀匹配均不受影响(规范化后的 token 不含 *、不以 *./. 开头);非 IPv6 目标新代码永不执行(host.includes(":") 门);原先能匹配的配对不会失配(host 已是规范形,规范化幂等);zone-index token 优雅退化(URL 解析失败→保留原 token,行为与之前一致,不崩溃);IPv4 不与 IPv4-mapped IPv6 等价(有意设计,有测试)。既有 41 个代理路由/绕过/诊断测试全绿。
  6. 是否破坏缓存: 不涉及——改动在出网路由决策层,与 prompt 缓存/重试/增量游标无关。
  7. 是否改了设计方向: 不涉及——架构/边界/数据流不变,只统一了单函数内的比较口径。
  8. 是否引入了新的配置: 不涉及——无新 env/config/默认值。

判定: 审核通过,合入合理(已合入 master),无需后续动作。

@ranxianglei ranxianglei added bug Something isn't working p3 scope/wiring labels Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working p3 scope/wiring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Equivalent IPv6 NO_PROXY literals incorrectly route requests through a proxy

2 participants