Repository navigation
network: normalize allowlist paths and block unspecified/CGNAT ranges - #853
Merged
ewhauser merged 2 commits intoOct 19, 2026
Merged
Conversation
Apply RFC 3986 remove_dot_segments before allowlist matching and send the normalized URL, denying paths that still decode to dot segments (%2e%2e, ..%2f, ..%5c, ..\, ..;). Redirect targets get the same check. Extend DenyPrivateRanges to unspecified addresses (0.0.0.0/8, ::), shared/CGNAT 100.64.0.0/10, multicast, other IANA non-public ranges, and NAT64/6to4 addresses embedding a non-public IPv4 destination, for both the preflight and dial-time checks.
ewhauser
enabled auto-merge (squash)
October 19, 2026 03:42
ewhauser
deleted the
network/fix-allowlist-dot-segments-private-ranges
branch
October 19, 2026 06:21
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.
Fixes two sandbox network-policy bypasses in
network/network.go.1. Allowlist path-prefix bypass via dot segments
urlAllowed/allowListPathMatchescomparedEscapedPath()as a raw prefix, and the original unnormalized URL was sent. WithAllowedURLPrefixes=["https://api.example.com/v1/"],https://api.example.com/v1/../admin(or%2e%2evariants) passed the check and went out unnormalized, so the server resolved it to/admin.Now:
remove_dot_segmentsruns on the escaped path before matching, and the normalized*url.URLthat was checked is the one assigned to the outgoinghttp.Request(/v1/a/../bis checked and sent as/v1/b;Response.URLreports the normalized URL)../..segment after a server percent-decodes (%2e%2e,.%2e), splits on encoded or backslash separators (..%2f,..%5c,..\), or strips;path params (..;, the Tomcat-style trick) are denied rather than normalized.Location: /v1/%2e%2e/adminnow returnsRedirectNotAllowedError.2.
isPrivateIPgapsIt missed unspecified addresses (
0.0.0.0,::), which connect to localhost on Linux and macOS, plus CGNAT100.64.0.0/10and other non-public ranges. It now usesnet/netipand covers:0.0.0.0/8100.64.0.0/10,192.0.0.0/24, TEST-NETs,198.18.0.0/15,240.0.0.0/4::/96,::ffff:0:0:0/96,64:ff9b:1::/48,100::/64,2001:db8::/32,fec0::/1064:ff9b::/96and 6to42002::/16when the embedded IPv4 address is non-publicIPv4-mapped addresses are classified by their IPv4 form. Both the preflight
checkPrivateHost(lexical and DNS-resolved) and the dial-timedialContextchecks use it. Literal-IP detection in the preflight now usesnetip.ParseAddr, which also handles zoned IPv6 literals.Behavior note: with
DenyPrivateRanges, hosts that resolve into198.18.0.0/15are now blocked. This includes the "fake-IP" DNS mode used by some local proxies (Clash, Surge).SPEC
Updated the network policy section in
SPEC.md(§12) to describe path normalization and ambiguous-segment denial, and to list the full set of blocked ranges.Testing
New regression tests in
network/network_test.gouse theWithDoer/WithResolverfakes plus a recording doer that checks what is actually sent:isPrivateIPtable0.0.0.0,::and100.64.0.1are blocked lexically, after DNS, and at dial timeAll of these failed before the fix and pass after it.
go test ./network/... ./internal/builtins/... ./internal/runtime/...passes (with the pinned diff/ripgrep oracles).FuzzHTTPClientPolicypasses.make lintreports 0 issues.