~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): pin unstructured SSRF (GHSA-4mvj-m6j5-pmf7) as unreachable + tripwire (#6626)
LearningCircuit2044c7c095d2
diff --git a/.grype.yaml b/.grype.yamlindex 8547bba6f6..b21b90f01b 100644--- a/.grype.yaml+++ b/.grype.yaml@@ -566,6 +566,30 @@ ignore:package: { name: nltk }reason: "Medium vuln in nltk 3.9.3. Transitive dep; nltk never imported or used directly. No fix released."+ # ==========================================================================+ # UNSTRUCTURED (GHSA-4mvj-m6j5-pmf7 / CVE-2026-71428 — alerts #8196, #8197)+ # Full-read SSRF in the url= argument of partition()/partition_html()/+ # partition_md() (fetched via requests.get with no host validation).+ # Critical per the advisory. NO LOCKABLE FIX: every fixed release (0.24.0+ # through 0.27.6) requires Python <3.14, while this project pins+ # requires-python >=3.12,<3.15 with a Python 3.14.7 production image.+ # MITIGATED — the URL sinks are unreachable in this codebase:+ # es_utils.index_file calls partition(filename=<PathValidator-vetted local+ # path>); every other touchpoint is langchain-community's file-based+ # Unstructured*Loader family (UnstructuredURLLoader never used). Enforced+ # by tests/security/test_unstructured_url_partition_tripwire.py, which+ # fails the build if a call site ever hands a URL to unstructured while+ # this entry is in force. Mirror entry in .trivyignore.+ # Remove both (and the tripwire) when a fixed unstructured release supports+ # Python 3.14 and the lock is bumped past it.+ # ==========================================================================+ - vulnerability: GHSA-4mvj-m6j5-pmf7+ package: { name: unstructured }+ reason: "Critical URL-partitioning SSRF. No fixed release installs on Python 3.14 (all fixes need <3.14). Sinks unreachable: only partition(filename=<validated local path>) is called; UnstructuredURLLoader unused. Enforced by tests/security/test_unstructured_url_partition_tripwire.py. Remove when a 3.14-compatible fixed release is locked."+ - vulnerability: CVE-2026-71428+ package: { name: unstructured }+ reason: "CVE alias of GHSA-4mvj-m6j5-pmf7 (unstructured URL-partitioning SSRF). See the GHSA entry above."+# --- torch (transitive dep for local embeddings — no fix available) ---- vulnerability: GHSA-rrmf-rvhw-rf47package: { name: torch }diff --git a/.trivyignore b/.trivyignoreindex ab1f4c2e32..1085688a81 100644--- a/.trivyignore+++ b/.trivyignore@@ -264,3 +264,29 @@ CVE-2026-3479 exp:2026-09-01# liblastlog2-2, login, mount, util-linux. Container runs non-root# with dropped capabilities.CVE-2026-27456 exp:2026-10-01++# GHSA-4mvj-m6j5-pmf7 / CVE-2026-71428: unstructured URL-partitioning SSRF+# Severity: CRITICAL per the advisory review; CVSS 3.1 vector+# AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:N (full-read SSRF)+# Review: 2026-09-19+#+# UNFIXABLE ON THIS PYTHON: the url= argument of partition()/+# partition_html()/partition_md() is fetched with no host validation+# (full-read SSRF). Fixed only in unstructured 0.24.0+, and EVERY fixed+# release (0.24.0..0.27.6) declares Requires-Python <3.14 while this project+# pins requires-python >=3.12,<3.15 with a Python 3.14.7 production image —+# no lockable fixed version exists until upstream ships 3.14 support.+#+# MITIGATED — the URL sinks are unreachable: es_utils.index_file calls+# partition(filename=<PathValidator-vetted local path>) and all other usage+# goes through langchain-community's file-based Unstructured*Loader family+# (UnstructuredURLLoader is not used anywhere). Enforced by+# tests/security/test_unstructured_url_partition_tripwire.py, which fails the+# build if any call site ever hands a URL to unstructured while this entry+# is in force.+#+# Tracking: https://github.com/Unstructured-IO/unstructured/security/advisories/GHSA-4mvj-m6j5-pmf7+# Remove when a fixed unstructured release supports Python 3.14 and the lock+# is bumped past it.+CVE-2026-71428 exp:2026-12-19+GHSA-4mvj-m6j5-pmf7 exp:2026-12-19diff --git a/pyproject.toml b/pyproject.tomlindex b35bc1cb60..e6eccb2007 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -71,7 +71,7 @@ dependencies = ["defusedxml~=0.7", # XXE-safe XML parsing"nh3~=0.3", # Backend HTML sanitization"pdfplumber~=0.11",- "unstructured~=0.18",+ "unstructured~=0.18", # GHSA-4mvj-m6j5-pmf7 (CVE-2026-71428) SSRF fixed only in 0.24+, which requires Python <3.14 — no lockable fix until upstream supports 3.14. Suppressed in .trivyignore/.grype.yaml; sink reachability pinned by tests/security/test_unstructured_url_partition_tripwire.py# Runtime parsers for the unstructured office-document loaders. These are# NOT pulled in by bare `unstructured` (only by its `[docx]`/`[odt]`/`[pptx]`/# `[xlsx]` extras), yet the loader registry advertises .doc/.docx/.odt/.ppt/diff --git a/tests/security/test_unstructured_url_partition_tripwire.py b/tests/security/test_unstructured_url_partition_tripwire.pynew file mode 100644index 0000000000..6927013d05--- /dev/null+++ b/tests/security/test_unstructured_url_partition_tripwire.py@@ -0,0 +1,157 @@+# allow: no-sut-import — a static census over the production SOURCE of+# src/local_deep_research (grep-style contract); the SUT it guards is the+# absence of any URL-reaching unstructured call site.+"""Tripwire for the unstructured URL-partitioning SSRF (GHSA-4mvj-m6j5-pmf7).++unstructured 0.18.32 — the newest release that installs on Python 3.14 — is+affected by GHSA-4mvj-m6j5-pmf7 / CVE-2026-71428 (CRITICAL): the ``url=``+argument of ``partition()``, ``partition_html()`` and ``partition_md()`` is+fetched with ``requests.get()`` and no host validation, giving a full-read+SSRF (loopback admin APIs, internal services, cloud metadata endpoints).++Every release carrying the fix (0.24.0+, up to and including 0.27.6) declares+``Requires-Python: <3.14``, and this project's ``requires-python`` is+``>=3.12,<3.15`` with a Python 3.14.7 production image — so no fixed version+can be locked until upstream ships 3.14 support (tracked in the+``.trivyignore`` / ``.grype.yaml`` suppression entries).++This file pins the compensating control instead: the vulnerable sinks are only+reachable when a caller hands unstructured a *URL*. This codebase never does —++* ``es_utils.index_file`` calls ``partition(filename=file_path)`` on a+ PathValidator-vetted local path, and+* every other touchpoint goes through the langchain-community+ ``Unstructured*Loader`` family, which passes ``file_path`` (never ``url``;+ ``UnstructuredURLLoader`` is the URL-taking variant and is not used).++The grep-style contract below fails the build if any of that changes: a new+call site that feeds a URL into unstructured would re-open the SSRF while the+scanner alerts are suppressed.++Remove this tripwire (and the suppression entries) together when the lock can+move to unstructured >= 0.24.0.+"""++from __future__ import annotations++import re+import tomllib+from pathlib import Path++import pytest+from packaging.version import Version++REPO_ROOT = Path(__file__).resolve().parents[2]+SRC = REPO_ROOT / "src" / "local_deep_research"++# Importing an URL-taking unstructured entry point at all counts as a+# violation: the SSRF lives inside partition_html/partition_md regardless of+# which keyword they are called with.+FORBIDDEN_IMPORTS = (+ "unstructured.partition.html",+ "unstructured.partition.md",+ "unstructured.partition.api",+)++# partition() itself is used legitimately (filename=), so the *call* is only+# forbidden when a url= keyword is passed to it — in source form that is+# ``url=`` appearing inside a partition(...) call. A call-scoped regex keeps+# false positives (e.g. ``url=`` kwargs on unrelated functions such as+# requests.get) out.+_PARTITION_URL_KWARG = re.compile(+ r"\bpartition\s*\((?:[^()]|\([^()]*\))*?\burl\s*=", re.DOTALL+)++# The langchain loader that feeds URLs to unstructured.partition.+FORBIDDEN_LOADERS = ("UnstructuredURLLoader",)++# Files that are allowed to mention the forbidden identifiers in prose+# (docstrings/comments explaining this exact suppression).+EXEMPT_FILES = (+ # this test file itself+ Path(__file__).name,+)+++def _violations(text: str, rel: str) -> list[str]:+ offenders = []+ for needle in FORBIDDEN_IMPORTS:+ if needle in text:+ offenders.append(+ f"{rel}: imports {needle!r} (URL-based partition entry point)"+ )+ for needle in FORBIDDEN_LOADERS:+ if needle in text:+ offenders.append(+ f"{rel}: references {needle!r} (feeds URLs to unstructured)"+ )+ if _PARTITION_URL_KWARG.search(text):+ offenders.append(+ f"{rel}: calls partition(... url=...) — full-read SSRF in unstructured "+ "<0.24 (GHSA-4mvj-m6j5-pmf7); pass filename= of a validated local path"+ )+ return offenders+++def test_no_url_reaches_the_unstructured_partitioner() -> None:+ """Grep-style contract: the SSRF sinks must stay unreachable in src/."""+ modules = sorted(SRC.rglob("*.py"))+ assert len(modules) > 100, "source tree not found"++ offenders: list[str] = []+ for path in modules:+ if path.name in EXEMPT_FILES:+ continue+ offenders += _violations(+ path.read_text(encoding="utf-8"), str(path.relative_to(SRC))+ )++ assert offenders == [], (+ "A code path hands a URL to unstructured while the GHSA-4mvj-m6j5-pmf7 "+ "full-read SSRF is only suppressed (no fixed release supports Python "+ "3.14). Partition a PathValidator-vetted local file instead, or "+ "re-evaluate the suppression:\n" + "\n".join(offenders)+ )+++def test_locked_unstructured_still_needs_suppression() -> None:+ """Remove the exceptions when the lock actually contains a fixed release.++ The compatible-release requirement ``~=0.18`` already permits 0.24.0.+ Read every locked variant; this offline check cannot discover new releases+ or establish their Python compatibility.+ """+ lock = tomllib.loads((REPO_ROOT / "pdm.lock").read_text(encoding="utf-8"))+ versions = [+ Version(package["version"])+ for package in lock.get("package", [])+ if package.get("name") == "unstructured"+ ]+ assert versions, (+ "unstructured missing from pdm.lock; remove its suppressions"+ )+ assert all(version < Version("0.24.0") for version in versions), (+ f"pdm.lock contains fixed unstructured {versions}: remove the "+ ".trivyignore/.grype.yaml suppressions and this temporary tripwire"+ )+++ "versions", [("0.24.0",), ("0.27.6",), ("0.18.32", "0.24.0"), ()]+)+def test_removal_guard_rejects_a_fixed_or_removed_lock(+ tmp_path, monkeypatch, versions+):+ # The requirement is unchanged while the resolved dependency changes.+ (tmp_path / "pyproject.toml").write_text(+ '[project]\ndependencies = ["unstructured~=0.18"]\n'+ )+ (tmp_path / "pdm.lock").write_text(+ "".join(+ f'[[package]]\nname = "unstructured"\nversion = "{version}"\n'+ for version in versions+ )+ )+ monkeypatch.setitem(globals(), "REPO_ROOT", tmp_path)+ with pytest.raises(AssertionError, match="remove"):+ test_locked_unstructured_still_needs_suppression()