Skip to content

fix(net): refuse 100.64.0.0/10 and IPv4 wrapped in IPv6 (NAT64, IPv4-compatible) - #2620

Merged
sunholo-voight-kampff merged 1 commit into
devfrom
fix/net-ssrf-cgnat-nat64
Dec 2, 2026
Merged

sunholo-voight-kampff merged 1 commit into
devfrom
fix/net-ssrf-cgnat-nat64

Conversation

@sunholo-voight-kampff

Copy link
Copy Markdown
Collaborator

Problem

Net destination checks (validateIP) and the restricted-mode net_allow config check used Go's IsPrivate, which covers RFC 1918 and fc00::/7 only:

  • 100.64.0.0/10 (RFC 6598: carrier-grade NAT, every Tailscale node) passed, so a public hostname resolving there reached the private network.
  • An IPv4 address wrapped in IPv6 (NAT64 64:ff9b::/96 and 64:ff9b:1::/48, or IPv4-compatible ::a.b.c.d) was judged as public IPv6; a NAT64 gateway translates 64:ff9b::a00:1 to 10.0.0.1.

Reported by Daneel, 2026-11-29 (two inbox messages).

Fix

One shared classifier, internal/effects/net_ipclass.go: EffectiveIP unwraps embedded IPv4, then IsSharedAddressSpace and IsThisNetwork (0.0.0.0/8) join the existing rules. Both sites (effects.validateIP, policy.checkNetAllowEntry) call it. An audit found no other site that judges whether an address is private (IsPrivate/IsLinkLocalUnicast appear only in these two). A public address wrapped in NAT64 (64:ff9b::808:808) is still allowed.

Tests

  • End-to-end no-dial tables extended for every Net entrypoint: resolved addresses and literal hosts in 100.64/10, ::ffff:100.64.0.1, NAT64 private/loopback/metadata, IPv4-compatible, 0.0.0.0/8.
  • TestEffectiveIP_UnwrapsEmbeddedIPv4, TestValidateIP_NonPublicForms, with positive controls: 100.63.255.255, 100.128.0.0, NAT64 of 8.8.8.8, public IPv6.
  • TestResolve_NetAllowEntries gains 6 refused entries.
  • Mutation test: each of the four parts (unwrap in validateIP, the 100.64 check, the 0.0.0.0/8 check, unwrap in policy), removed alone, fails at least one test. Without the 100.64 check, the end-to-end test really dialled a tailnet address on the dev machine and hung until the test timeout; the unit test fails immediately.

Gates: go test ./internal/effects ./internal/policy, make lint, check-file-sizes, check-changelog, check-boundaries.

For v1.0.0-rc.4.

🤖 Generated with Claude Code

…compatible)

validateIP and the restricted-mode net_allow check used net.IP.IsPrivate,
which covers RFC 1918 and fc00::/7 only. 100.64.0.0/10 (CGNAT, Tailscale)
passed, and an IPv4 address inside 64:ff9b::/96, 64:ff9b:1::/48 or ::/96 was
judged as public IPv6. One shared classifier (net_ipclass.go) now unwraps the
embedded IPv4 address and refuses 100.64/10 and 0.0.0.0/8 as well; both
sites use it. A public IPv4 address wrapped in NAT64 stays allowed.

Tests extend the end-to-end no-dial tables (resolved and literal forms) and
add classifier unit tests with positive controls. Mutation-tested: each of
the four parts of the fix, removed alone, fails at least one test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sunholo-voight-kampff added a commit that referenced this pull request Dec 2, 2026
TestPremiseSweep_CorpusTokenOffsets failed on Windows CI (PR #2620) with
GetFileAttributesEx on a .artifacts-*.tmp under
examples/intra_package_imports/.ailang/cache: another package's test was
compiling that example concurrently and the temp file vanished between the
directory read and the stat. The walk now never enters .ailang (a compile
cache, not corpus source) and ignores an entry that no longer exists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sunholo-voight-kampff
sunholo-voight-kampff merged commit 6efd033 into dev Dec 2, 2026
33 of 35 checks passed
@sunholo-voight-kampff
sunholo-voight-kampff deleted the fix/net-ssrf-cgnat-nat64 branch December 2, 2026 16:08
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.

1 participant