~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(security): block Oracle Classic metadata endpoint (#7011)
LearningCircuit4e8204ef908e
diff --git a/SECURITY.md b/SECURITY.mdindex 90eb08aec5..7dc63f35b7 100644--- a/SECURITY.md+++ b/SECURITY.md@@ -188,6 +188,7 @@ Both `ssrf_validator.validate_url` and `NotificationURLValidator.validate_servic| `169.254.0.23` | Tencent Cloud || `100.100.100.200` | AlibabaCloud || `fd00:ec2::254` | AWS IMDS over IPv6 |+| `192.0.0.192` | Oracle Compute Classic / Cloud at Customer |`fd00:ec2::254` is AWS's native IPv6 instance-metadata endpoint. It is a ULA (`fc00::/7`), **not** an IPv4-mapped or NAT64-wrapped form of `169.254.169.254`, so it is not covered by the IPv4 entries or the NAT64 embedded-IPv4 check above and must be listed explicitly — otherwise it stays reachable under `allow_private_ips=True`, which permits the whole `fc00::/7` range. Entries are matched by canonical string form (`is_ip_blocked` parses the candidate with `ipaddress.ip_address` first), so uppercase / zero-padded / expanded variants all normalise to the listed form before the membership test.diff --git a/changelog.d/+oracle-classic-imds.security.md b/changelog.d/+oracle-classic-imds.security.mdnew file mode 100644index 0000000000..36cf47a801--- /dev/null+++ b/changelog.d/+oracle-classic-imds.security.md@@ -0,0 +1,2 @@+Always block Oracle Compute Classic's `192.0.0.192` instance-metadata+endpoint, including when an outbound policy permits private addresses.diff --git a/src/local_deep_research/security/egress/fetch.py b/src/local_deep_research/security/egress/fetch.pyindex 57275fdd1d..5d1057e5fa 100644--- a/src/local_deep_research/security/egress/fetch.py+++ b/src/local_deep_research/security/egress/fetch.py@@ -26,10 +26,10 @@ def policy_aware_validate_url(url: str, egress_context=None) -> bool:regardless of scope (handled inside ``is_ip_blocked``).``block_link_local=True`` is DEFENSE IN DEPTH, not a fix for a known- exploit. ``ALWAYS_BLOCKED_METADATA_IPS`` covers six literal metadata+ exploit. ``ALWAYS_BLOCKED_METADATA_IPS`` covers known literal metadataaddresses; the rest of 169.254.0.0/16 (and fe80::/10) is not adeliberate service range, but it does host provider-specific metadata- endpoints outside those six -- Scaleway's 169.254.42.42, for one. A+ endpoints outside that list -- Scaleway's 169.254.42.42, for one. APRIVATE_ONLY run is meant to reach a lab box on 192.168.x or127.0.0.1, never an auto-configuration address, so excluding therange costs nothing real and removes a class of target.diff --git a/src/local_deep_research/security/ssrf_validator.py b/src/local_deep_research/security/ssrf_validator.pyindex 5ed7ffaefd..f0939b288b 100644--- a/src/local_deep_research/security/ssrf_validator.py+++ b/src/local_deep_research/security/ssrf_validator.py@@ -37,6 +37,10 @@ ALWAYS_BLOCKED_METADATA_IPS = frozenset("169.254.170.23", # AWS ECS task metadata v4"169.254.0.23", # Tencent Cloud"100.100.100.200", # AlibabaCloud+ # Oracle Compute Classic and Cloud at Customer expose instance+ # metadata here. This address falls outside the explicit private+ # and link-local ranges, so policy flags must never allow it.+ "192.0.0.192", # Oracle Compute Classic IMDS# AWS native IPv6 IMDS endpoint. Documented by AWS as the IPv6# instance-metadata address ([fd00:ec2::254]). It is a ULA# (fc00::/7), NOT an IPv4-mapped / NAT64-wrapped form of@@ -192,7 +196,7 @@ def is_ip_blocked(send path (see ``security.dns_pinning`` /``notification_validator``): the lenient plugin/raw-webhookpartition allows private LAN targets, but link-local is where- cloud-provider metadata lives beyond the six always-blocked+ cloud-provider metadata lives beyond the always-blocked metadataliterals (e.g. Scaleway's ``169.254.42.42``) and is never alegitimate self-hosted notifier, so it stays blocked there. Has noeffect unless ``allow_private_ips=True`` — without the opt-indiff --git a/tests/notifications/test_notification_webhook_dns_pin.py b/tests/notifications/test_notification_webhook_dns_pin.pyindex 53796396b3..8d88c7aea3 100644--- a/tests/notifications/test_notification_webhook_dns_pin.py+++ b/tests/notifications/test_notification_webhook_dns_pin.py@@ -1308,7 +1308,7 @@ def test_ipv6_imds_rebind_refused_through_send():# ==========================================================================def test_link_local_refused_by_notification_block_window():"""An UNPINNED lookup that resolves into the link-local range (Scaleway's- metadata ``169.254.42.42`` is the canonical example — NOT one of the six+ metadata ``169.254.42.42`` is the canonical example — NOT one of thealways-blocked literals) is refused by the notification block-privatewindow when ``block_link_local=True``, even though allow_private_ips=Truepermits RFC1918. Teeth: drop ``block_link_local`` and this lookup@@ -1433,7 +1433,7 @@ def test_rfc1918_json_webhook_still_delivers_end_to_end():## These tests use a HOSTNAME that validates PUBLIC (the validator's own# resolution, call #1 of the scripted resolver) but rebinds to a link-local-# address that is NOT one of the six always-blocked metadata literals (call+# address that is NOT one of the always-blocked metadata literals (call# #2, at the guarded send call site itself) — Scaleway's ``169.254.42.42``# / a bare IPv6 ``fe80::`` address, both ordinary link-local space that# ``allow_private_ips=True`` would otherwise ADMIT. So a refusal here candiff --git a/tests/security/test_egress_fetch_link_local.py b/tests/security/test_egress_fetch_link_local.pyindex 41f0bc864a..b23470a3d0 100644--- a/tests/security/test_egress_fetch_link_local.py+++ b/tests/security/test_egress_fetch_link_local.py@@ -5,7 +5,7 @@ with an attacker-chosen address requires the operator to have listed thehost in ``local_hostnames`` (or the attacker to control DNS for a host theoperator already listed), so it is a hardening gap rather than an open door.-What it does close: ``ALWAYS_BLOCKED_METADATA_IPS`` holds six literal+What it does close: ``ALWAYS_BLOCKED_METADATA_IPS`` holds known literalmetadata addresses, and the remainder of 169.254.0.0/16 still carriesprovider-specific metadata endpoints -- Scaleway's 169.254.42.42 amongthem. Before this, the two egress gates disagreed: ``policy.py``@@ -57,7 +57,7 @@ def _ctx(scope=EgressScope.PRIVATE_ONLY):@pytest.mark.parametrize("ip,why",[- ("169.254.42.42", "Scaleway metadata, outside the six literals"),+ ("169.254.42.42", "Scaleway metadata, outside the listed literals"),("169.254.169.254", "the canonical metadata literal"),("169.254.1.1", "generic IPv4 link-local"),],diff --git a/tests/security/test_llm_endpoint_link_local_hardening.py b/tests/security/test_llm_endpoint_link_local_hardening.pyindex 763641b585..8cec6fcf9b 100644--- a/tests/security/test_llm_endpoint_link_local_hardening.py+++ b/tests/security/test_llm_endpoint_link_local_hardening.py@@ -96,5 +96,5 @@ def test_self_hosted_still_classifies_as_local(host):"host", ["169.254.169.254", "metadata.google.internal"])def test_named_metadata_addresses_remain_blocked(host):- """The pre-existing six-literal denylist must survive the range change."""+ """The pre-existing literal denylist must survive the range change."""assert _classify_host(host, _private_only_ctx()) is Falsediff --git a/tests/security/test_metadata_ip_set_tripwire.py b/tests/security/test_metadata_ip_set_tripwire.pyindex d5ca785296..cabc3b4fbd 100644--- a/tests/security/test_metadata_ip_set_tripwire.py+++ b/tests/security/test_metadata_ip_set_tripwire.py@@ -3,11 +3,9 @@``ALWAYS_BLOCKED_METADATA_IPS`` is the SSRF chain's absolute floor:every entry is a cloud instance-metadata endpoint, and the reviewcontract says any **removal** is Critical while additions are fine.-Behavioral coverage today reaches four of the six members (via one-route-level suite); the other two — ``169.254.170.23`` (AWS ECS v4)-and ``169.254.0.23`` (Tencent) — have no test anywhere, and no test-pins the set property itself. A consolidation refactor that drops an-entry therefore lands green.+Behavioral coverage also needs a set-membership pin: a consolidation+refactor that drops a less frequently exercised provider endpoint must+fail even when another metadata test still passes.The IPv6 member deserves its own pin: ``fd00:ec2::254`` is a ULA,not an IPv4-mapped or NAT64-wrapped form of the IPv4 entries, so no@@ -33,6 +31,7 @@ DOCUMENTED_METADATA_IPS = frozenset("169.254.170.23", # AWS ECS task metadata v4"169.254.0.23", # Tencent Cloud"100.100.100.200", # AlibabaCloud+ "192.0.0.192", # Oracle Compute Classic IMDS"fd00:ec2::254", # AWS IMDS over IPv6})diff --git a/tests/security/test_notification_validator.py b/tests/security/test_notification_validator.pyindex c03b7e07f5..52b2faaa35 100644--- a/tests/security/test_notification_validator.py+++ b/tests/security/test_notification_validator.py@@ -785,7 +785,7 @@ class TestLinkLocalBlockedForPluginSchemes:The lenient plugin/raw-webhook partition runs with``allow_private_ips=True`` so self-hosted LAN notifiers work. Butcloud-provider metadata lives across the WHOLE link-local range- (169.254.0.0/16, fe80::/10), not just the six always-blocked literals+ (169.254.0.0/16, fe80::/10), not just the always-blocked literals(e.g. Scaleway's 169.254.42.42). ``validate_service_url`` must rejectany link-local plugin-scheme target while still allowing RFC1918 /loopback / non-link-local ULA.diff --git a/tests/security/test_ssrf_validator.py b/tests/security/test_ssrf_validator.pyindex 646487b2f8..7c1775cf57 100644--- a/tests/security/test_ssrf_validator.py+++ b/tests/security/test_ssrf_validator.py@@ -14,7 +14,8 @@ Security model:- IPv6 ULA: fc00::/7- IPv6 Link-local: fe80::/10- Cloud metadata endpoints (AWS IMDS / ECS, Azure, OCI, DigitalOcean,- AlibabaCloud, Tencent — see ALWAYS_BLOCKED_METADATA_IPS) are ALWAYS blocked+ AlibabaCloud, Tencent, Oracle Classic — see ALWAYS_BLOCKED_METADATA_IPS)+ are ALWAYS blockedThe allow_private_ips parameter is designed for trusted self-hosted services likeSearXNG or Ollama that may be running in containerized environments (Docker, Podman)@@ -937,6 +938,25 @@ class TestAllowFlagMatrix:class TestAlwaysBlockedMetadataIPs:"""Cloud-metadata IPs blocked under every flag combination."""+ @pytest.mark.parametrize(+ "flags",+ [+ {},+ {"allow_localhost": True},+ {"allow_private_ips": True},+ {"allow_localhost": True, "allow_private_ips": True},+ ],+ )+ def test_oracle_classic_imds_blocked_under_all_flags(self, flags):+ """Oracle Compute Classic serves instance metadata at 192.0.0.192."""+ from local_deep_research.security.ssrf_validator import (+ is_ip_blocked,+ validate_url,+ )++ assert is_ip_blocked("192.0.0.192", **flags)+ assert not validate_url("http://192.0.0.192/latest/meta-data/", **flags)+def test_aws_ipv6_imds_blocked_under_all_flags(self):"""AWS's native IPv6 IMDS endpoint (fd00:ec2::254) is a ULA(fc00::/7), NOT an IPv4-mapped / NAT64-wrapped form ofdiff --git a/tests/security/test_ssrf_validator_high_value.py b/tests/security/test_ssrf_validator_high_value.pyindex 09a3a637d0..5ad4ac462f 100644--- a/tests/security/test_ssrf_validator_high_value.py+++ b/tests/security/test_ssrf_validator_high_value.py@@ -339,6 +339,7 @@ class TestConstants:"169.254.170.23","169.254.0.23","100.100.100.200",+ "192.0.0.192","fd00:ec2::254",})diff --git a/tests/utilities/test_utilities_layer_contracts.py b/tests/utilities/test_utilities_layer_contracts.pyindex 94aef1c7b7..5f81035057 100644--- a/tests/utilities/test_utilities_layer_contracts.py+++ b/tests/utilities/test_utilities_layer_contracts.py@@ -505,42 +505,25 @@ class TestUrlUtilsUnvalidatedInput:@pytest.mark.parametrize("metadata_endpoint",[- # Oracle Cloud legacy instance metadata endpoint. The- # always-blocked set names OCI but lists only- # 169.254.169.254; 192.0.0.192 is in IETF-assigned- # 192.0.0.0/24, which is neither a literal nor part of the- # link-local range, so it matches no blocked range.- "http://192.0.0.192/opc/v1/instance/",+ # Oracle Compute Classic metadata is neither RFC1918 nor+ # link-local, so it needs an explicit always-blocked entry.+ "http://192.0.0.192/2007-08-29/meta-data/",],)- def test_metadata_endpoints_outside_the_literal_list_are_allowed(+ def test_oracle_classic_metadata_endpoint_is_blocked(self, metadata_endpoint):- """SECURITY-SENSITIVE: the always-blocked set is a literal list.-- ``is_safe_custom_llm_endpoint`` calls ``validate_url(...,- allow_private_ips=True, block_link_local=True)``, so the whole of- 169.254.0.0/16 (and fe80::/10) is blocked regardless of the six- enumerated literals -- see- ``test_link_local_range_is_blocked_even_off_the_literal_list``- below. 192.0.0.0/24 is a separate, non-link-local range and is- not covered by that carve-out. An authenticated user can- therefore still point the OpenAI-compatible LLM base_url at it- and read the responses back through completions output.- """- assert is_safe_custom_llm_endpoint(metadata_endpoint) is True, (- "if this now returns False the blocklist was widened -- update "- "this test, it is pinning a gap, not a desired behaviour"- )+ """The custom LLM endpoint cannot reach Oracle Classic IMDS."""+ assert is_safe_custom_llm_endpoint(metadata_endpoint) is False@pytest.mark.parametrize("link_local_endpoint",[# Scaleway instance metadata -- link-local, not one of the- # six always-blocked literals.+ # always-blocked metadata literals."http://169.254.42.42/conf",# AWS VPC resolver / EC2 legacy helper range -- same /16, not- # one of the six always-blocked literals.+ # one of the always-blocked metadata literals."http://169.254.169.253/",],)@@ -552,7 +535,7 @@ class TestUrlUtilsUnvalidatedInput:``is_safe_custom_llm_endpoint`` now passes ``block_link_local=True``to ``validate_url`` (see the ``harden(ssrf): block link-local byrange on the custom LLM endpoint path`` commit), so the entire- link-local range is blocked, not just the six enumerated+ link-local range is blocked, not just the enumeratedcloud-metadata literals. This used to be pinned here as anallowed gap; it is a blocked range now, so this asserts thetightened behaviour instead.diff --git a/tests/web_search_engines/engines/test_search_engine_searxng.py b/tests/web_search_engines/engines/test_search_engine_searxng.pyindex 329d303c80..844f19b80b 100644--- a/tests/web_search_engines/engines/test_search_engine_searxng.py+++ b/tests/web_search_engines/engines/test_search_engine_searxng.py@@ -3679,7 +3679,7 @@ class TestFullSearchPrivateIpGate:def test_gated_instance_still_blocks_link_local_url(self, monkeypatch):"""Even with both approvals, the rest of 169.254.0.0/16 (provider- metadata outside the six literals, e.g. Scaleway's 169.254.42.42)+ metadata outside the always-blocked literals, e.g. Scaleway's 169.254.42.42)stays blocked via ``block_link_local=True``."""engine = self._make_engine(monkeypatch, instance_gate=True, result_fetch=True