Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pkgs/lab-ops-hub/container/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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")
Expand Down
1 change: 1 addition & 0 deletions pkgs/lab-ops-hub/src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 4 additions & 0 deletions pkgs/lab-ops-hub/test/lib.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions pkgs/lab-ops-hub/test/test_container_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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)

Expand Down
Loading