Skip to content

[PR] fix: validate diagnostic loopback host exemptions - #7397

Merged
ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-20_mask-loopback-like-hostnames
Nov 20, 2026
Merged

ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-20_mask-loopback-like-hostnames

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

⚠️ MODEL-FACING TEXT CHANGE

The failure-response host field and visible error now mask 127-prefixed DNS names; a portless IPv6 loopback stays intact. Failure status, kind, code and retry behavior remain unchanged. The regression checks the exact visible text acp-proxy failure: dns ENOTFOUND <private-host>:8443, so clients retain the failure class and port without receiving a private hostname.

Fixes #7396

Problem

The loopback display exemption accepts ip.startsWith("127."), which also matches private DNS names such as 127.customer.internal. This leaks those names through diagnostic URLs, actual host-event files, and structured upstream-failure responses despite host masking being enabled.

Changes

  • Require a real IPv4 loopback literal. Preserve Node's numeric aliases (127.1, 127.0.1, 127.0x1, and octal spellings) only after a numeric-only candidate canonicalizes to a valid 127/8 address.
  • Split bracketed display targets after the closing bracket. new URL("http://[::1]").host has no port and must not be split at an IPv6 address colon.
  • Keep exact localhost/IPv6 loopback/0.0.0.0 visibility, clean loopback URL spelling, credential removal, public-host policy and the existing opt-out.

This changes diagnostic host visibility, not connection admission, name resolution or routing. No config field, environment variable, dependency or kernel change.

Validation

The unchanged tested base has 6 failing behavior regressions and 2 passing controls. The fixed branch passes 52/52 focused tests:

node --import ./tests/preload-test-env.mjs \
  --import ./tests/preload-storage-baseline.mjs --import tsx \
  --test --test-concurrency=2 \
  tests/loopback-diagnostic-hosts.test.ts tests/log-mask.test.ts \
  tests/issue4254-upstream-failure-egress.test.ts \
  tests/web-storage-diagnostics-redaction.test.ts
npm run typecheck
npm run build
npm run check:unused-exports
npm run check:test-import-graph
git diff --check

The new regressions exercise the real host-event file writer and the 502 response builder, alongside direct URL/display controls. Existing tests include real proxy logs, connection failures, CONNECT and WebSocket error paths. Full regression remains the remote CI lanes on the pushed PR head.

Tested base: 1e357bf2d6632bfbd2a74ffb70ecee1af1ec7cc3; Node.js 24.22.3, Linux x86_64.

Duplicate boundary

All-author/all-state searches and the latest 100 actual open PRs found no equivalent repair. #3653/#4257 introduced the exemption, #6098 fixed credentials in genuine loopback URLs, and #7393 fixes repeated embedded-URL scans. Those behaviors are preserved.

⚠️ MODEL-FACING TEXT CHANGE
Failure-response host fields now mask 127-prefixed DNS names and keep a
portless IPv6 loopback intact. Status, failure kind, code and retry policy
are unchanged; the exact visible 502 error is covered by a regression.

Require actual IPv4 loopback addresses instead of accepting any 127.
prefix. Retain Node's numeric IPv4 aliases after syntax validation and
canonicalization. Split bracketed display targets after their closing
bracket so an address colon is never mistaken for a port separator.

The unchanged base fails six behavior regressions with two controls passing.
The fix passes 52 focused tests, typecheck, build and both static gates.
@ranxianglei ranxianglei changed the title fix: validate diagnostic loopback host exemptions [PR] fix: validate diagnostic loopback host exemptions Nov 20, 2026
@ranxianglei
ranxianglei merged commit 0a995d5 into ranxianglei:master Nov 20, 2026
84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Diagnostic loopback exemptions expose 127-prefixed private DNS names

2 participants