Skip to content

fix: treat IPv4-mapped IPv6 loopback as localhost - #3255

Merged
OrKoN merged 1 commit into
ChromeDevTools:mainfrom
kevin9327:fix-islocalhost-ipv4-mapped
Oct 20, 2026
Merged

OrKoN merged 1 commit into
ChromeDevTools:mainfrom
kevin9327:fix-islocalhost-ipv4-mapped

Conversation

@kevin9327

Copy link
Copy Markdown
Contributor

What

isLocalhost returned false for IPv4-mapped IPv6 loopback addresses such as ws://[::ffff:127.0.0.1]:9222. URL serializes that host as [::ffff:7f00:1], which matched neither the [::1] check nor the dotted IPv4 regex.

isLocalBrowser in ToolHandler.ts uses isLocalhost on the browser's wsEndpoint. So a browser that is reached on a mapped loopback address was treated as remote, and file verification used the remote option instead of local. Telemetry's is_localhost had the same problem.

Fix

The check now also accepts hostnames matching [::ffff:7fXX:XXXX], which is 127.0.0.0/8 in mapped form. Mapped non-loopback addresses ([::ffff:128.0.0.1], [::ffff:192.168.1.1]) still return false.

Tests

I added should return true for IPv4-mapped IPv6 loopback to tests/utils/url.test.ts. It fails before the change and passes after. I ran tests/utils/url.test.ts (36 tests) with tsx against the source rather than doing a full npm run build. Prettier check passes.

AI assistance: I used an AI coding assistant (Grok Bot) to help find and write this fix. I reviewed the change and ran the tests myself.

@OrKoN
OrKoN enabled auto-merge October 20, 2026 14:17
@OrKoN
OrKoN added this pull request to the merge queue Oct 20, 2026
Merged via the queue into ChromeDevTools:main with commit 6cfb34c Oct 20, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants