~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: normalize absolute module paths in security whitelist (#2823)
LearningCircuit1a6fd9216e2a
diff --git a/src/local_deep_research/security/module_whitelist.py b/src/local_deep_research/security/module_whitelist.pyindex 4e3340bd10..a65792c3b7 100644--- a/src/local_deep_research/security/module_whitelist.py+++ b/src/local_deep_research/security/module_whitelist.py@@ -199,6 +199,14 @@ def get_safe_module_class(>>> cls = get_safe_module_class(".engines.search_engine_brave", "BraveSearchEngine")>>> engine = cls(api_key="...")"""+ # Normalize legacy absolute paths to relative form.+ # Some code paths (settings snapshots, older DB entries) may pass absolute+ # paths like "local_deep_research.web_search_engines.engines.search_engine_X"+ # instead of the required relative form ".engines.search_engine_X".+ _ABSOLUTE_PREFIX = "local_deep_research.web_search_engines"+ if module_path and module_path.startswith(_ABSOLUTE_PREFIX):+ module_path = module_path[len(_ABSOLUTE_PREFIX) :]+# Validate both module path and class name against whitelistsif not validate_module_import(module_path, class_name):logger.error(diff --git a/tests/security/test_module_whitelist.py b/tests/security/test_module_whitelist.pyindex 7375989018..8a968c89c5 100644--- a/tests/security/test_module_whitelist.py+++ b/tests/security/test_module_whitelist.py@@ -191,8 +191,18 @@ class TestGetSafeModuleClass:assert "not in the security whitelist" in str(exc_info.value)- def test_raises_security_error_for_absolute_import(self):- """Should raise SecurityError for absolute import paths."""+ def test_normalizes_legacy_absolute_import(self):+ """Should normalize absolute paths from our own package to relative form."""+ # Absolute path for a whitelisted engine should be auto-normalized+ cls = get_safe_module_class(+ "local_deep_research.web_search_engines.search_engine_base",+ "BaseSearchEngine",+ )+ assert cls is not None+ assert cls.__name__ == "BaseSearchEngine"++ def test_raises_security_error_for_foreign_absolute_import(self):+ """Should raise SecurityError for absolute import paths outside our package."""with pytest.raises(SecurityError):get_safe_module_class("local_deep_research.security.module_whitelist",@@ -276,6 +286,35 @@ class TestGetSafeModuleClass:package="custom.package",)+ def test_normalizes_collection_engine_absolute_path(self):+ """Regression test for user-reported collection search blocked error."""+ with patch(+ "local_deep_research.security.module_whitelist.importlib.import_module"+ ) as mock_import:+ mock_module = MagicMock()+ mock_module.CollectionSearchEngine = type(+ "CollectionSearchEngine", (), {}+ )+ mock_import.return_value = mock_module++ cls = get_safe_module_class(+ "local_deep_research.web_search_engines.engines.search_engine_collection",+ "CollectionSearchEngine",+ )+ assert cls.__name__ == "CollectionSearchEngine"+ mock_import.assert_called_once_with(+ ".engines.search_engine_collection",+ package="local_deep_research.web_search_engines",+ )++ def test_rejects_exact_prefix_normalizing_to_empty(self):+ """Exact prefix without module suffix normalizes to empty string → rejected."""+ with pytest.raises(SecurityError):+ get_safe_module_class(+ "local_deep_research.web_search_engines",+ "BaseSearchEngine",+ )+class TestSecurityScenarios:"""Test specific security attack scenarios."""@@ -419,12 +458,13 @@ class TestDocumentation:- Logging of blocked attempts for security auditingSECURITY MODEL:- | Input Type | Action | Reason |- |-------------------|----------|-------------------------------------|- | Relative + listed | ALLOWED | Trusted search engine module |- | Absolute path | BLOCKED | Could access dangerous modules |- | Unlisted module | BLOCKED | Not in trusted whitelist |- | Unlisted class | BLOCKED | Could be dangerous class |- | Empty/None | BLOCKED | Invalid input |+ | Input Type | Action | Reason |+ |-------------------------|------------|-------------------------------------|+ | Relative + listed | ALLOWED | Trusted search engine module |+ | Absolute (own package) | NORMALIZED | Converted to relative, then checked |+ | Absolute (foreign) | BLOCKED | Could access dangerous modules |+ | Unlisted module | BLOCKED | Not in trusted whitelist |+ | Unlisted class | BLOCKED | Could be dangerous class |+ | Empty/None | BLOCKED | Invalid input |"""assert True # Documentation test