Details
Then in _validated_addresses:
judged = _unwrap_embedded_ipv4(ip)
if not (judged.is_global or any(ip in net for net in allow)):
return []
Verified: this blocks the NAT64/IPv4-compat/6to4 internal forms while genuine public IPs and public NAT64-wrapped IPs still pass.
Resolution
Addressed by #3426 (pending merge), targeted for release in lightrag-hku 1.5.5. _validated_addresses() now decides global-routability by starting from the stdlib's `is_global` on the literal and only ever tightening it — the guard is never more permissive than ipaddress itself:
- Fixed-position transition wrappers are decoded and the embedded IPv4 must also be global (IPv4-mapped
::ffff:0:0/96, IPv4-compatible::/96, and the NAT64 well-known prefix64:ff9b::/96— RFC 6052 §2.2, contiguous low-32 embedding). So64:ff9b::7f00:1(→ loopback) is blocked while64:ff9b::808:808(→ public 8.8.8.8) still passes. - Blocks whose embedded-IPv4 position must not be trusted are default-denied as whole blocks, independent of the interpreter: the RFC 8215 local-use prefix
64:ff9b:1::/48(technology-agnostic, embedded-IPv4 position not guaranteed per RFC 8215 §5 — a fixed-offset decode is itself bypassable, e.g.64:ff9b:1:7f00:0:100:808:808encodes127.0.0.1but its low 32 bits read as public8.8.8.8) and 6to42002::/16(IANA global-reachability N/A; current CPython classifies the whole block non-global — RFC 7526 deprecated only the 6to4 anycast relay path, not the 2002::/16 prefix itself). Decoding 6to4 by its embedded IPv4 would have re-permitted2002::/16addresses the stdlib already blocks, so it is denied outright instead.
Genuine global IPv6 and a NAT64 wrapper of a *public* IPv4 still pass; regression tests cover every wrapped form of loopback / RFC1918 / metadata, the RFC 6052 /48 suffix bypass, and 6to4 of a public IPv4. Boundary: a NAT64 deployment using a *custom*, globally-routable Network-Specific Prefix (RFC 6052 permits any /32../96), or a genuine local NAT64 / legacy 6to4 in the force-denied blocks, is not auto-permitted — such operators should pin the download egress or set NATIVE_MD_IMAGE_ALLOWED_NON_PUBLIC_CIDRS deliberately.
Credit
tonghuaroot ([email protected]).