Skip to content

fix(network): classify NAT64/6to4 by embedded IPv4 and block reserved ranges - #2574

Merged
chaliy merged 3 commits into
mainfrom
claude/project-thread-eafupr
Oct 7, 2026
Merged

chaliy merged 3 commits into
mainfrom
claude/project-thread-eafupr

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

The SSRF guard (is_private_ip, used before the request and in the connect-time resolver) now:

  • classifies NAT64 (64:ff9b::/96) and 6to4 (2002::/16) addresses by the IPv4 address they carry;
  • blocks the remaining non-global ranges: 0.0.0.0/8, 192.0.0.0/24, 198.18.0.0/15, 224.0.0.0/4, 240.0.0.0/4 (incl. broadcast), and v6 100::/64, Teredo 2001::/32, local-use NAT64 64:ff9b:1::/48, site-local fec0::/10, multicast ff00::/8.

Documentation ranges (192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24, 2001:db8::/32) stay allowed, since they are unroutable and tests use them as public stand-ins.

Why

An allowlisted hostname with attacker-controlled DNS could return 64:ff9b::a9fe:a9fe or 2002:7f00:1::. On a NAT64 network, or through a 6to4 relay, those reach cloud metadata or loopback while passing the v4 checks. Spotted while comparing against shipfastlabs/bashbox, which already handles these forms. New threat entry TM-NET-029.

Before / After

Before: the 4 new unit tests fail (test_is_private_ip_nat64_embeds_v4, _6to4_embeds_v4, _reserved_v4_ranges, _reserved_v6_ranges).
After: cargo test -p bashkit --lib --features http_client network:: gives 58 passed, 0 failed.

Risk

  • Low
  • Hosts that resolve only to multicast, benchmark (198.18/15) or Teredo addresses can no longer be reached. None of these are legitimate HTTP targets.

Checklist

  • Tests added or updated
  • Backward compatibility considered

… ranges

is_private_ip let 64:ff9b::/96 and 2002::/16 addresses through even when
they embed loopback, RFC1918 or link-local v4, and missed 0.0.0.0/8,
192.0.0.0/24, 198.18.0.0/15, multicast, 240.0.0.0/4, Teredo, site-local
and v6 multicast. An allowlisted host with attacker DNS could reach
internal services via these forms. Adds TM-NET-029.
@chaliy chaliy self-assigned this Oct 7, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit f7bd566 Commit Preview URL

Branch Preview URL
Oct 07 2026, 06:20 PM

@chaliy
chaliy merged commit d3a82cf into main Oct 7, 2026
46 checks passed
@chaliy
chaliy deleted the claude/project-thread-eafupr branch October 7, 2026 18:39
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