Repository navigation
ios: open loopback links on the computer, never the phone - #2018
Merged
Merged
Conversation
WebKit connects to the phone's own 127.0.0.1, [::1] and (on device) localhost directly, whatever the proxy configuration says, so a live preview or chat link to a dev server reached the phone, not the agent's computer. A page or main-frame navigation to the loopback now opens on ipv4/ipv6/name.happy-loopback.invalid; BrowserProxy tunnels that alias as CONNECT to the loopback it stands for and puts the loopback back in each request's Host, Origin and Referer. A content blocker refuses anything else a page loads from the phone's loopback.
Contributor
Author
|
Hosted CI, run 42557795138: uikit and hosted3 passed. Every failure in hosted1 and hosted2 has failed before on runs without this change:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WebKit ignores a page's
ProxyConfigurationfor the phone's own loopback. On an iPhone 12 (iOS 26.1), a live preview or chat link tohttp://127.0.0.1:PORTorhttp://[::1]:PORTconnected straight to the phone, andlocalhostbypassed the proxy too. The page came from the phone, not from the agent's computer. This fix is client-only. The server and agent are unchanged: the tunnel still receives a literal loopback CONNECT target.127.0.0.1,[::1]orlocalhost(normalized) opens onipv4|ipv6|name.happy-loopback.invalidat the same port and scheme (BrowserPolicy.Loopback).BrowserProxytunnels an alias asCONNECT <loopback>:<port>.BrowserRelay.loopbackframes each request and rewritesHost, plusOrigin/Refereron the alias, back to the loopback, so Vite/Next host checks pass. TLS, upgrades and responses pass through byte for byte.BrowserPagehas aWKContentRuleListthat blocks anything else it loads from the phone's loopback. The exact spellings are listed indocs/browser-proxy.md.Tests:
BrowserTests: new alias mapping and request-rewrite tests, 17/17.BrowserStates+Browser: 23/23 on the simulator, including the unchanged numeric-127 testtestALiveArtifactWhoseComputerIsGoneSaysSoAndOpensWhenItIsBackandtestComputerUnreachable….testTheLoopbackOpensOnTheComputerAndNothingReachesThePhones: listeners on the phone's 127.0.0.1/[::1] get 0 hits for 127.0.0.1, [::1] and localhost. No-cors fetches to 9 loopback spellings are blocked.127.example.comstill goes through the proxy. The dev server seesHost: <loopback>:<port>.Reviewed by ufcvos (2 passes, nothing blocking).
Known limits, not fixed here:
name.fetchingipv4.sends the alias Origin.<link rel=preconnect>hasn't been verified.fetch('http://localhost:3000')from another origin) is blocked, not rewritten.