Reject IPv4-mapped/compatible IPv6 forms of local hosts as unsafe proxies#1697
Open
jax-0n-git wants to merge 1 commit into
Open
Reject IPv4-mapped/compatible IPv6 forms of local hosts as unsafe proxies#1697jax-0n-git wants to merge 1 commit into
jax-0n-git wants to merge 1 commit into
Conversation
…xies `isLocalOnlyHost` rejected loopback / link-local / this-network proxy endpoints in their IPv4 (`127.0.0.1`, `169.254.x`) and plain-IPv6 (`::1`, `fe80::/10`) spellings, but the IPv6 branch only matched those literal shapes. The same machine-local endpoints written as IPv4-mapped (`::ffff:127.0.0.1`, `::ffff:169.254.1.1`) or IPv4-compatible (`::127.0.0.1`) IPv6 addresses slipped through the check and were accepted as "safe" remote proxy hosts. Decode the embedded IPv4 address from the mapped (`::ffff:a.b.c.d`) and compatible (`::a.b.c.d`) forms and apply the same IPv4 local-host rules to it, via a shared `isLocalOnlyIPv4` helper. Adds a test target for OsaurusNetworking with coverage for the mapped/compatible local hosts, the existing plain spellings (regression), and genuinely-remote hosts (including a public IPv4-mapped address, which must still be accepted). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
isLocalOnlyHostrejects loopback / link-local / this-network proxy endpoints in their IPv4 (127.0.0.1,169.254.x) and plain-IPv6 (::1,fe80::/10) spellings, but the IPv6 branch only matched those literal shapes. The same machine-local endpoints written as IPv4-mapped (::ffff:127.0.0.1,::ffff:169.254.1.1) or IPv4-compatible (::127.0.0.1) IPv6 addresses slipped through and were accepted as "safe" remote proxy hosts.This decodes the embedded IPv4 address from the mapped (
::ffff:a.b.c.d) and compatible (::a.b.c.d) forms and applies the same IPv4 local-host rules to it, via a sharedisLocalOnlyIPv4helper. The change only ever rejects more hosts (the fail-safe direction for a security guard); genuinely-remote addresses — including a public IPv4-mapped address like::ffff:8.8.8.8— stay accepted. The IPv4-compatible branch also rejects the reserved low::0.xrange as non-routable, which is the safe direction.Coupling: open #1693 also edits
GlobalProxyConfiguration.swiftand adds the sameOsaurusNetworkingTeststarget. Whichever lands second needs a trivial rebase to de-dupe thePackage.swifttest-target block; the test files have distinct names and don't conflict.Changes
Test Plan
swift testinPackages/OsaurusNetworking(all green) +swift-format lint --strictclean. New test target covers the mapped/compatible local hosts (rejected after fix), the existing plain spellings (regression), and genuinely-remote hosts including a public IPv4-mapped address (still accepted). No MLX/GUI dependency.