Skip to content

Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.

fix(url_safety): refuse the RFC 6598 shared address space

Tobi | Nordaluxa63e3350dd64
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5c8f2c0..e81ecb0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
+- `url_safety.is_safe_ip` accepted the RFC 6598 shared address space
+ (100.64.0.0/10), which Python's `ipaddress` does not count as private. Alibaba
+ Cloud serves instance metadata at 100.100.100.200, so a crafted URL or DNS
+ answer in that range slipped past the SSRF guard. The range is now refused,
+ and IPv4-mapped IPv6 literals are judged as their embedded IPv4 address.
+ Note: 100.64.0.0/10 is also the Tailscale range, so audits of a staging site
+ reached over Tailscale lose access; see SECURITY.md.
- `commoncrawl_graph.py` no longer writes outside its cache directory. The
`--release` value was interpolated raw into the cache filename, so
`--release ../../../../tmp/x` escaped the cache dir and `_save_cache`'s
diff --git a/scripts/url_safety.py b/scripts/url_safety.py
index 7336beb..91b163a 100644
--- a/scripts/url_safety.py
+++ b/scripts/url_safety.py
@@ -180,20 +180,30 @@ def _reject_authority_confusion(url: str, parsed) -> None:
raise URLSafetyError("URL fragment/userinfo confusion refused")
+# RFC 6598 shared address space (carrier-grade NAT). Not in ``is_private``
+# on any supported Python, yet never publicly routable: Alibaba Cloud serves
+# its instance metadata at 100.100.100.200, and Tailscale/WireGuard meshes
+# hand out 100.64/10 addresses for internal services.
+_SHARED_ADDRESS_SPACE = ipaddress.ip_network("100.64.0.0/10")
+
+
def is_safe_ip(ip_str: str) -> bool:
"""Return True iff ``ip_str`` is a public unicast address.
- Handles IPv4-mapped IPv6 (``::ffff:127.0.0.1`` correctly returns False
- because Python 3.9+'s ``ipaddress`` propagates ``is_loopback`` /
- ``is_private`` through IPv4-mapped form). IPv6 unique-local
- (``fc00::/7``) and link-local (``fe80::/10``) are also rejected.
+ IPv4-mapped IPv6 (``::ffff:127.0.0.1``) is unwrapped and judged as the
+ embedded IPv4 address, so every IPv4 rule below applies to it too.
+ IPv6 unique-local (``fc00::/7``) and link-local (``fe80::/10``) are
+ also rejected.
"""
try:
ip = ipaddress.ip_address(ip_str)
except ValueError:
return False
+ if ip.version == 6 and ip.ipv4_mapped is not None:
+ ip = ip.ipv4_mapped
return not (
ip.is_private
+ or (ip.version == 4 and ip in _SHARED_ADDRESS_SPACE)
or ip.is_loopback
or ip.is_reserved
or ip.is_link_local
diff --git a/tests/test_url_safety.py b/tests/test_url_safety.py
index cf0e87c..e5b7778 100644
--- a/tests/test_url_safety.py
+++ b/tests/test_url_safety.py
@@ -133,6 +133,13 @@ def test_validate_url_blocks_authority_confusion(url: str) -> None:
("172.16.0.1", False),
("127.0.0.1", False),
("169.254.169.254", False), # AWS/GCP/Azure metadata
+ ("100.100.100.200", False), # Alibaba Cloud metadata (RFC 6598 shared space)
+ ("100.64.0.0", False), # RFC 6598 lower bound
+ ("100.127.255.255", False), # RFC 6598 upper bound
+ ("100.128.0.1", True), # first address past the /10 is public
+ ("::ffff:100.100.100.200", False), # IPv4-mapped form of the above
+ ("::ffff:127.0.0.1", False),
+ ("::ffff:8.8.8.8", True),
("0.0.0.0", False),
("::1", False),
("fe80::1", False), # IPv6 link-local
@@ -204,6 +211,8 @@ def test_validate_url_strict_accepts_ip_literal_public() -> None:
"https://10.0.0.1/",
"https://192.168.1.1/",
"https://169.254.169.254/",
+ "http://100.100.100.200/latest/meta-data/",
+ "http://[::ffff:100.100.100.200]/latest/meta-data/",
"https://0.0.0.0/",
],
)