Repository navigation
Conversation
…other special-use literals as non-public; the grant stays narrow #1560 Signed-off-by: Nik Cubrilovic <[email protected]>
|
Reviewed the diff for the new classifier in I found no correctness or security problems. The grant/policy split matches the description.
|
This was referenced Nov 2, 2026
Contributor
Author
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.
Closes #1560.
Decision: a wider function for the policy callers, the shared narrow function stays a grant
isNonPublicHostname(backed byisPrivateOrReservedHost) answers "is this a private-network host" and is used two ways. Callers that GRANT from it (allowPrivateNetwork: isNonPublicHostname(baseHost)inaudit-engine/adapter.ts, the seed redirect'sisNonPublicUrl(url), the TLS probe) would WIDEN a grant if the function widened: a start URLhttp://[64:ff9b::a00:1]/would then count as "on the private network" and be allowed private-network egress, and the hosted engine would inherit that from its site host. So the shared function is not widened. The callers that DECIDE POLICY ask a different question (can a public visitor or a hosted service reach this?) and now read a wider one:isNonPublicHostnameForPolicy(packages/utils/src/non-public-host.ts) =isNonPublicHostnameplusisSpecialUseIpLiteral(newpackages/utils/src/special-use-ip.ts).nonPublicHostLabelandisNonPublicUrlread it, so every caller of the label gets it: cloud handoff and render charge (audit/cloud.ts), publish and register gating (cli/commands/audit.ts,report.ts), the MCP billing note (mcp/billed-audit.ts), the rules runner'sskipOnPrivateTargetgate, and a smart audit's not-applicable list (audit/smart-audits.ts,privateTargetRuleIdsnow exported for the test).parseUserUrl(url.ts) reads it: a special-use literal has no public certificate, so it defaults tohttp://.privateNetworkHostLabelandisPrivateNetworkUrl(the old behaviour) are whatseed-redirect.tsreads. The egress guards (public-egress.ts:vetEgressTarget,refusedWithoutLookup) are untouched and keep their own address logic; the adapter'sallowPrivateNetworklines and the TLS probe are untouched.What counts as special-use (
isSpecialUseIpLiteral, syntactic, no lookup, whatever IPv4 is embedded): IPv6 NAT6464:ff9b::/96and64:ff9b:1::/48, 6to42002::/16, Teredo and the other IETF assignments2001::/23, documentation2001:db8::/32and3fff::/20, discard100::/64, site-localfec0::/10, multicastff00::/8, the deprecated IPv4-compatible::/96, an IPv4-mapped or -translated address whose IPv4 is special-use, and an ISATAP identifier (::5efe:a.b.c.d) embedding one (plus the loopback, link-local and ULA ranges the narrow function already had); IPv40/8,10/8,100.64/10,127/8,169.254/16,172.16/12,192.168/16,192.0.0.0/24,192.0.2.0/24,192.88.99.0/24,198.18.0.0/15,198.51.100.0/24,203.0.113.0/24and224.0.0.0/4upward. A public IPv4 or IPv6 literal (8.8.8.8,2606:4700::1111,::ffff:8.8.8.8,2001:4860:4860::8888) stays public. This PR does not use #1547'sisNonPublicHostnameStrict; it is its own helper, under a different name, so the two can land in either order and be reconciled (they should end up as one function).Tests and fixtures changed
packages/utils/tests/non-public-host.test.tslistedhttps://203.0.113.10/as "a public literal IP"; it is documentation (TEST-NET-3), so it moved to the special-use list and the public literal there is now93.184.216.34. No other test used a documentation address as a classifier input (integrity.test.ts,hotlinked-932,mixed-contentuse them as page content hosts;seed-base-collapseandtls-certificateonly mention them).packages/utils/tests/special-use-ip.test.ts(86): 32 special IPv6 literals, 9 public ones, 20 special and 19 public IPv4, spellings (expanded, upper case, dotted tail, zone id), malformed input, and that the narrow classifier is unchanged while the policy one is wider.non-public-host.test.ts(labels for 18 special-use URLs, the narrow label does not name them, 96 tests);parse-user-url-local-scheme-812.test.ts(default scheme http for special-use literals, https for public ones);rules/tests/private-target-skip.test.ts(page and site rule gating for NAT64, 6to4, Teredo, site-local, documentation; a public literal still runs them; 9 fail on main);apps/cli/tests/audit/cloud-prefetch-non-public-base.test.ts(both cloud seams sethostUnreachableByCloud; a public literal does not; 10 fail on main);apps/cli/tests/lib/non-public-host.test.ts(12 forms: the label, publish and register decisions, a smart audit's skipped rules; a public literal publishes).crawler/tests/start-redirect-resolver.test.ts: a NAT64, 6to4 or documentation start URL is not allowed private-network egress (the guard refuses it with no request) and a LAN start URL still is. It passes on main by design.Not done
The hosted API classifier (
classifyHostedEgressHost, private repo) mirrors this list entry for entry and should get the same wider verdict; that is a private PR. The AC's "docs state why they do not" part is the docs section below for the grant. Docs (docs/guides/local-audits-cli.mdx) and CHANGELOG updated. Skill change: none.