From 94bb66d83ff39c78500bdf0237c0c792472c5987 Mon Sep 17 00:00:00 2001 From: Muse Sweep Date: Wed, 21 Oct 2026 20:06:31 -0500 Subject: [PATCH] lab-ops-hub: refuse the RFC 9637 documentation range 3fff::/20 in both crawl validators (#519) --- pkgs/lab-ops-hub/container/app.py | 12 ++++++++++-- pkgs/lab-ops-hub/src/lib.ts | 1 + pkgs/lab-ops-hub/test/lib.test.ts | 4 ++++ pkgs/lab-ops-hub/test/test_container_validate.py | 4 ++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pkgs/lab-ops-hub/container/app.py b/pkgs/lab-ops-hub/container/app.py index bc581411dc..096dc9c270 100644 --- a/pkgs/lab-ops-hub/container/app.py +++ b/pkgs/lab-ops-hub/container/app.py @@ -148,14 +148,19 @@ def validate_crawl_url(raw): # ipaddress reports multicast (224.0.0.0/4) and 192.88.99.0/24 as # is_global; neither is a public unicast crawl target (#476). raise ValueError(f"refusing to crawl non-public address {host}") - elif isinstance(ip, ipaddress.IPv6Address) and ip not in _GLOBAL_UNICAST_V6: + elif isinstance(ip, ipaddress.IPv6Address) and ( + ip not in _GLOBAL_UNICAST_V6 or ip in _IPV6_DOCUMENTATION + ): # ipaddress.is_global is True for any IPv6 address outside its # narrow private list — multicast (ff00::/8), site-local # (fec0::/10), SRv6 SIDs (5f00::/16) and the reserved space # outside global unicast all pass it (#474). Global unicast # lives in 2000::/3; require that first, as the Worker's # validateCrawlUrl does, then let is_global judge within it - # (it knows the 2001::/23 special-purpose block). + # (it knows the 2001::/23 special-purpose block). The RFC 9637 + # documentation range 3fff::/20 sits inside 2000::/3 and + # is_global's verdict on it depends on the interpreter's bundled + # special-purpose registry, so refuse it explicitly (#519). raise ValueError(f"refusing to crawl non-public address {host}") elif not ip.is_global: raise ValueError(f"refusing to crawl non-public address {host}") @@ -165,6 +170,9 @@ def validate_crawl_url(raw): _GLOBAL_UNICAST_V6 = ipaddress.IPv6Network("2000::/3") +_IPV6_DOCUMENTATION = ipaddress.IPv6Network("3fff::/20") + + _NAT64_WELL_KNOWN = ipaddress.IPv6Network("64:ff9b::/96") _IPV4_6TO4_RELAY_ANYCAST = ipaddress.IPv4Network("192.88.99.0/24") diff --git a/pkgs/lab-ops-hub/src/lib.ts b/pkgs/lab-ops-hub/src/lib.ts index e93c447aa2..520f127e71 100644 --- a/pkgs/lab-ops-hub/src/lib.ts +++ b/pkgs/lab-ops-hub/src/lib.ts @@ -99,6 +99,7 @@ function ipv6IsGlobal(host: string): boolean { if (g[0] >= 0xfc00 && g[0] <= 0xfdff) return false; // unique-local fc00::/7 if (g[0] >= 0xff00) return false; // multicast ff00::/8 if (g[0] === 0x2001 && g[1] === 0x0db8) return false; // documentation 2001:db8::/32 + if (g[0] === 0x3fff && (g[1] & 0xf000) === 0) return false; // documentation 3fff::/20 (RFC 9637) (#519) // The 2001::/23 IANA special-purpose block is non-global except six // entries (#474, mirroring the Python validator's ipaddress verdicts): // 2001:1::1 and 2001:1::2 (PCP anycast), 2001:3::/32 (AMT), diff --git a/pkgs/lab-ops-hub/test/lib.test.ts b/pkgs/lab-ops-hub/test/lib.test.ts index be3cf8ecc5..1c58ab0d47 100644 --- a/pkgs/lab-ops-hub/test/lib.test.ts +++ b/pkgs/lab-ops-hub/test/lib.test.ts @@ -117,6 +117,8 @@ test("validateCrawlUrl agrees with the container validator on special IPv6 range "https://[2001:40::1]/", // 2001::/23 special-purpose "https://[2001:50::1]/", // 2001::/23 special-purpose "https://[2001:1::3]/", // 2001:1::/48 is global only at ::1 and ::2 + "https://[3fff::1]/", // documentation 3fff::/20 (RFC 9637) (#519) + "https://[3fff:0fff:ffff:ffff:ffff:ffff:ffff:ffff]/", // last address in 3fff::/20 (#519) ]; for (const u of blocked) { assert.equal(validateCrawlUrl(u).ok, false, u); @@ -129,6 +131,8 @@ test("validateCrawlUrl agrees with the container validator on special IPv6 range "https://[2001:20::1]/", // ORCHIDv2 2001:20::/28 "https://[2001:30::1]/", // ORCHIDv2 2001:30::/28 "https://[2001:4860:4860::8888]/", // ordinary global unicast + "https://[3fff:1000::1]/", // first address past 3fff::/20 (#519) + "https://[3ffe::1]/", // global unicast below 3fff::/20 (#519) ]; for (const u of allowed) { assert.equal(validateCrawlUrl(u).ok, true, u); diff --git a/pkgs/lab-ops-hub/test/test_container_validate.py b/pkgs/lab-ops-hub/test/test_container_validate.py index 8088f4ad21..e98ff0eae0 100644 --- a/pkgs/lab-ops-hub/test/test_container_validate.py +++ b/pkgs/lab-ops-hub/test/test_container_validate.py @@ -163,6 +163,8 @@ def test_agrees_with_worker_validator_on_special_ipv6_ranges(self): "https://[2001:40::1]/", # 2001::/23 special-purpose "https://[2001:50::1]/", # 2001::/23 special-purpose "https://[2001:1::3]/", # 2001:1::/48 global only at ::1/::2 + "https://[3fff::1]/", # documentation 3fff::/20 (RFC 9637) (#519) + "https://[3fff:0fff:ffff:ffff:ffff:ffff:ffff:ffff]/", # last address in 3fff::/20 (#519) ): self.assertRefused(url) for url in ( @@ -173,6 +175,8 @@ def test_agrees_with_worker_validator_on_special_ipv6_ranges(self): "https://[2001:20::1]/", # ORCHIDv2 2001:20::/28 "https://[2001:30::1]/", # ORCHIDv2 2001:30::/28 "https://[2001:4860:4860::8888]/", # ordinary global unicast + "https://[3fff:1000::1]/", # first address past 3fff::/20 (#519) + "https://[3ffe::1]/", # global unicast below 3fff::/20 (#519) ): self.assertAccepted(url)