~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): strip settings_snapshot in DatabaseReportStorage.get_report_with_metadata (defence-in-depth) (#4863)
LearningCircuit11dde70b8283
diff --git a/src/local_deep_research/storage/database.py b/src/local_deep_research/storage/database.pyindex 4f6a93a784..90b70f7798 100644--- a/src/local_deep_research/storage/database.py+++ b/src/local_deep_research/storage/database.py@@ -6,6 +6,7 @@ from sqlalchemy.orm import Sessionfrom .base import ReportStoragefrom ..database.models import ResearchHistory+from ..security import strip_settings_snapshotclass DatabaseReportStorage(ReportStorage):@@ -111,7 +112,12 @@ class DatabaseReportStorage(ReportStorage):return {"content": research.report_content,- "metadata": research.research_meta or {},+ # Strip settings_snapshot (API keys/tokens) before exposing+ # research_meta — this method's contract is to hand back+ # metadata, so a future route wiring it to a response must not+ # leak the snapshot (CWE-200). Defence-in-depth at the source,+ # mirroring the report/details routes. Other fields preserved.+ "metadata": strip_settings_snapshot(research.research_meta),"query": research.query,"mode": research.mode,"created_at": research.created_at,diff --git a/tests/storage/test_database_storage.py b/tests/storage/test_database_storage.pyindex 01ec81c4af..e18fc3dcb1 100644--- a/tests/storage/test_database_storage.py+++ b/tests/storage/test_database_storage.py@@ -189,6 +189,26 @@ class TestGetReportWithMetadata:assert result is None+ def test_strips_settings_snapshot_from_metadata(+ self, mock_session, mock_research_history+ ):+ """settings_snapshot (API keys/tokens) must be stripped from the+ returned metadata — defence-in-depth at the source so a future route+ wiring this method to a response cannot leak it (CWE-200). Other+ metadata fields are preserved."""+ mock_research_history.research_meta = {+ "iterations": 2,+ "settings_snapshot": {"llm.openai.api_key": "sk-SECRET-KEY"},+ }+ mock_session.query.return_value.filter_by.return_value.first.return_value = mock_research_history++ storage = DatabaseReportStorage(mock_session)+ result = storage.get_report_with_metadata("test-uuid")++ assert "settings_snapshot" not in result["metadata"]+ assert "sk-SECRET-KEY" not in str(result["metadata"])+ assert result["metadata"]["iterations"] == 2+class TestDeleteReport:"""Tests for delete_report method."""