Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(security): block the IPv4-Translated prefix so ::ffff:0:127.0.0.1 is private (#6460)

Lukas Buckb49724e0ef27
diff --git a/changelog.d/6460.security.md b/changelog.d/6460.security.md
new file mode 100644
index 0000000000..f4cfd6a211
--- /dev/null
+++ b/changelog.d/6460.security.md
@@ -0,0 +1,8 @@
+SSRF and private-IP gating now blocks the IPv4-Translated prefix
+`::ffff:0:0:0/96` (RFC 2765 / SIIT). An address such as
+`::ffff:0:127.0.0.1` or `::ffff:0:169.254.169.254` carries its IPv4 in the low
+32 bits but is not the IPv4-Mapped form, so `ipaddress` does not unwrap it and
+it previously fell through every IPv4 check and classified as public (#6408).
+The mapped prefix `::ffff:0:0/96` is one group lower and keeps being judged on
+the address it carries. The notification URL validator shares the same range
+list and is covered too.
diff --git a/src/local_deep_research/security/ip_ranges.py b/src/local_deep_research/security/ip_ranges.py
index d9a44114b2..1728d25409 100644
--- a/src/local_deep_research/security/ip_ranges.py
+++ b/src/local_deep_research/security/ip_ranges.py
@@ -45,6 +45,14 @@ PRIVATE_IP_RANGES = [
# 6to4/NAT64 wraps. Has zero legitimate live use; blocking it is the
# same defense-in-depth move as the transition prefixes above.
ipaddress.ip_network("::/96"),
+ # IPv4-Translated (RFC 2765 / SIIT). Same shape as the IPv4-Compatible
+ # prefix above — the IPv4 sits in the low 32 bits — and the same threat:
+ # `::ffff:0:169.254.169.254` reaches IMDS on a host with SIIT routes.
+ # NOT covered by the validator's `ipv4_mapped` unwrap, which only
+ # recognises the MAPPED form `::ffff:0:0/96` (`::ffff:127.0.0.1`);
+ # `ipaddress` returns None for `ipv4_mapped` on the translated form, so
+ # it fell through every IPv4 check and classified as public (#6408).
+ ipaddress.ip_network("::ffff:0:0:0/96"),
]
# NAT64 prefixes — operators on IPv6-only hosts using DNS64+NAT64 reach
diff --git a/tests/security/test_notification_validator.py b/tests/security/test_notification_validator.py
index 5401a7d0aa..dead8a01a2 100644
--- a/tests/security/test_notification_validator.py
+++ b/tests/security/test_notification_validator.py
@@ -1340,6 +1340,53 @@ class TestClassConstants:
assert "192.168.0.0/16" in range_strings
+class TestIPv4TranslatedPrefixInNotificationValidator:
+ """Mirror of ssrf_validator's IPv4-Translated checks for the
+ notification path. Both surfaces share ``PRIVATE_IP_RANGES`` through
+ ``is_ip_blocked``, so the second ingress is pinned the way the
+ NAT64 family above is."""
+
+ def test_ipv4_translated_imds_blocked(self):
+ """``::ffff:0:169.254.169.254`` — RFC 2765 / SIIT, IMDS in the low
+ 32 bits. Not the IPv4-MAPPED prefix, so ``ipv4_mapped`` does not
+ unwrap it (#6408)."""
+ assert (
+ NotificationURLValidator._is_private_ip("::ffff:0:169.254.169.254")
+ is True
+ )
+
+ def test_ipv4_translated_loopback_blocked(self):
+ """``::ffff:0:127.0.0.1`` — the address from the report."""
+ assert (
+ NotificationURLValidator._is_private_ip("::ffff:0:127.0.0.1")
+ is True
+ )
+
+ def test_ipv4_translated_hex_form_blocked(self):
+ """The same two addresses with the low 32 bits in hex."""
+ assert (
+ NotificationURLValidator._is_private_ip("::ffff:0:a9fe:a9fe")
+ is True
+ )
+ assert (
+ NotificationURLValidator._is_private_ip("::ffff:0:7f00:1") is True
+ )
+
+ def test_the_mapped_family_is_still_judged_on_its_payload(self):
+ """Control: the new entry blocks the TRANSLATED prefix only.
+
+ ``::ffff:8.8.8.8`` is IPv4-MAPPED, one group lower, and is still
+ unwrapped and judged on the address it carries — so this class
+ cannot pass by refusing every embedded-IPv4 literal.
+ """
+ assert (
+ NotificationURLValidator._is_private_ip("::ffff:8.8.8.8") is False
+ )
+ assert (
+ NotificationURLValidator._is_private_ip("::ffff:127.0.0.1") is True
+ )
+
+
class TestNat64EnvOptOutInNotificationValidator:
"""Mirror of ssrf_validator's TestNat64EnvOptOut for the notification
path. The notification validator must honor the same operator
diff --git a/tests/security/test_ssrf_validator.py b/tests/security/test_ssrf_validator.py
index 00878d2eff..e2094d1333 100644
--- a/tests/security/test_ssrf_validator.py
+++ b/tests/security/test_ssrf_validator.py
@@ -1346,6 +1346,61 @@ class TestIPv6TransitionPrefixesBlocked:
assert validate_url("http://[::192.168.1.1]/") is False
+ def test_ipv4_translated_imds_blocked(self):
+ """[::ffff:0:169.254.169.254] — RFC 2765 / SIIT IPv4-Translated.
+
+ Not the same prefix as IPv4-Mapped, and not covered by the
+ validator's unwrap: `ipaddress` returns None for `ipv4_mapped` on
+ this form, so it fell through every IPv4 check and classified as
+ public (#6408). The embedded address is in the low 32 bits exactly
+ as in the IPv4-Compatible case above.
+ """
+ from local_deep_research.security.ssrf_validator import (
+ validate_url,
+ )
+
+ assert validate_url("http://[::ffff:0:169.254.169.254]/") is False
+
+ def test_ipv4_translated_loopback_blocked(self):
+ """[::ffff:0:127.0.0.1] — the address from the report."""
+ from local_deep_research.security.ssrf_validator import (
+ validate_url,
+ )
+
+ assert validate_url("http://[::ffff:0:127.0.0.1]/") is False
+
+ def test_ipv4_translated_hex_form_blocked(self):
+ """The same two addresses written with the low 32 bits in hex.
+
+ `a9fe:a9fe` is 169.254.169.254 and `7f00:1` is 127.0.0.1, so these
+ are the hex spellings of the two cases above. The dotted-quad tail
+ is a convenience of the textual form, not a separate address, and a
+ prefix check has to see both spellings the same way.
+ """
+ from local_deep_research.security.ssrf_validator import (
+ validate_url,
+ )
+
+ assert validate_url("http://[::ffff:0:a9fe:a9fe]/") is False
+ assert validate_url("http://[::ffff:0:7f00:1]/") is False
+
+ def test_the_translated_prefix_is_not_the_mapped_prefix(self):
+ """The distinction the report's title gets wrong, pinned.
+
+ `::ffff:0:0/96` is IPv4-MAPPED and already handled by the
+ validator's `ipv4_mapped` unwrap. The translated form lives one
+ group higher, in `::ffff:0:0:0/96`, and adding the mapped prefix
+ instead would have left the reported address public.
+ """
+ import ipaddress
+
+ reported = ipaddress.ip_address("::ffff:0:127.0.0.1")
+
+ assert reported not in ipaddress.ip_network("::ffff:0:0/96")
+ assert reported in ipaddress.ip_network("::ffff:0:0:0/96")
+ assert ipaddress.ip_address("::ffff:127.0.0.1").ipv4_mapped is not None
+ assert reported.ipv4_mapped is None
+
class TestIPv6TransitionPrefixesAllowFlagMatrix:
"""Lock in the design decision: ``allow_private_ips=True`` does NOT