~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
bound bulk library deletion ids (#7008)
LearningCircuitd5a2fb9bf442
diff --git a/changelog.d/6590.security.md b/changelog.d/6590.security.mdnew file mode 100644index 0000000000..a38ef0070e--- /dev/null+++ b/changelog.d/6590.security.md@@ -0,0 +1 @@+Bulk library deletion and preview routes now bound the `document_ids` list to 1,000 items and each ID to 2,048 characters before running per-document work.diff --git a/src/local_deep_research/web/routers/library_delete.py b/src/local_deep_research/web/routers/library_delete.pyindex 78772b7624..54ba646410 100644--- a/src/local_deep_research/web/routers/library_delete.py+++ b/src/local_deep_research/web/routers/library_delete.py@@ -32,6 +32,8 @@ from ...research_library.deletion.services.bulk_deletion import ()from typing import Annotated+from .library import _MAX_STRING_LIST_ITEMS, _MAX_STRING_LIST_ITEM_LENGTH+router = APIRouter(prefix="/library/api", tags=["delete"])# NOTE: Routes use username (not .get()) intentionally.# Depends(require_auth) guarantees the key exists; direct access fails@@ -92,11 +94,7 @@ def _validate_document_ids_from_data(data):# the per-document delete lock's dict key, both surfacing as 500s from# services this router does not own. Rejecting non-string elements here# keeps every hostile element type out of that code entirely.- if (- not isinstance(document_ids, list)- or not document_ids- or not all(isinstance(doc_id, str) for doc_id in document_ids)- ):+ if not isinstance(document_ids, list) or not document_ids:return None, JSONResponse({"success": False,@@ -105,6 +103,44 @@ def _validate_document_ids_from_data(data):status_code=400,)+ # Use the same manual-selection limits as the sibling library routes.+ # Check count before scanning elements: the 16 MB JSON body tier can+ # otherwise trigger hundreds of thousands of per-document operations.+ if len(document_ids) > _MAX_STRING_LIST_ITEMS:+ return None, JSONResponse(+ {+ "success": False,+ "error": (+ "document_ids must contain at most"+ f" {_MAX_STRING_LIST_ITEMS} items"+ ),+ },+ status_code=400,+ )++ if not all(isinstance(doc_id, str) for doc_id in document_ids):+ return None, JSONResponse(+ {+ "success": False,+ "error": "document_ids must be a non-empty list",+ },+ status_code=400,+ )++ if any(+ len(doc_id) > _MAX_STRING_LIST_ITEM_LENGTH for doc_id in document_ids+ ):+ return None, JSONResponse(+ {+ "success": False,+ "error": (+ "document_ids items must be at most"+ f" {_MAX_STRING_LIST_ITEM_LENGTH} characters"+ ),+ },+ status_code=400,+ )+return document_ids, Nonediff --git a/tests/web/routers/test_library_delete_hostile_input.py b/tests/web/routers/test_library_delete_hostile_input.pyindex e42ff5b4da..620d27a0aa 100644--- a/tests/web/routers/test_library_delete_hostile_input.py+++ b/tests/web/routers/test_library_delete_hostile_input.py@@ -264,6 +264,22 @@ def test_document_ids_edge_cases_return_400(_assert_clean_400(resp, method, path, repr(payload))[email protected]("method,path", ALL_ROUTES)+ "document_ids",+ [+ pytest.param(["id"] * 1001, id="too-many-ids"),+ pytest.param(["x" * 2049], id="overlong-id"),+ ],+)+def test_document_ids_bounds_reject_before_deletion(+ hostile_client, method, path, document_ids+):+ client, _, _ = hostile_client+ resp = client.request(method, path, json={"document_ids": document_ids})+ _assert_clean_400(resp, method, path, "oversized document_ids")++# ---------------------------------------------------------------------------# Well-formed request must still work exactly as before: nonexistent-but-# valid string IDs 200 with a per-item "not found", and a real document ID