Skip to content

~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.

fix(security): resolve open code-scanning alerts (pypdf DoS, exception exposure, migration SQL, Actions injection, devskim FP) (#4601)

LearningCircuitc65d59a65fd4
diff --git a/.github/workflows/ai-code-reviewer.yml b/.github/workflows/ai-code-reviewer.yml
index 9c9680762b..b427db4416 100644
--- a/.github/workflows/ai-code-reviewer.yml
+++ b/.github/workflows/ai-code-reviewer.yml
@@ -76,6 +76,7 @@ jobs:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
FAIL_ON_REQUESTED_CHANGES: ${{ vars.FAIL_ON_REQUESTED_CHANGES || 'false' }}
DEBUG_MODE: ${{ vars.DEBUG_MODE || 'false' }}
+ EVENT_ACTION: ${{ github.event.action }}
run: |
# Run the AI reviewer and save response to file
echo "Running AI code review..."
@@ -133,7 +134,7 @@ jobs:
fi
# Don't post raw response as it may contain sensitive data
- echo "AI response could not be processed. Please check the workflow logs for debugging information (enable DEBUG_MODE to see details)." | gh pr comment ${{ github.event.pull_request.number }} --repo ${{ github.repository }} -F -
+ echo "AI response could not be processed. Please check the workflow logs for debugging information (enable DEBUG_MODE to see details)." | gh pr comment "$PR_NUMBER" --repo "$REPO_FULL_NAME" -F -
exit 1
fi
@@ -178,7 +179,7 @@ jobs:
else
echo "Label already exists: $label"
fi
- if gh issue edit ${{ github.event.pull_request.number }} --add-label "$label" 2>/dev/null; then
+ if gh issue edit "$PR_NUMBER" --add-label "$label" 2>/dev/null; then
echo "Successfully added label: $label"
else
echo "Failed to add label: $label"
@@ -194,7 +195,7 @@ jobs:
# Remove the ai_code_review label so re-adding it re-triggers a review.
# Only relevant when this run was triggered by that label; on
# opened/synchronize/ready_for_review there is no such label to remove.
- if [ "${{ github.event.action }}" = "labeled" ]; then
+ if [ "$EVENT_ACTION" = "labeled" ]; then
echo "Removing ai_code_review label to allow easy re-triggering"
if gh issue edit "$PR_NUMBER" --remove-label "ai_code_review" 2>/dev/null; then
echo "Successfully removed ai_code_review label"
diff --git a/pdm.lock b/pdm.lock
index 05df131bf5..70fa595b6e 100644
--- a/pdm.lock
+++ b/pdm.lock
@@ -5,7 +5,7 @@
groups = ["default", "dev", "mcp"]
strategy = ["inherit_metadata"]
lock_version = "4.5.0"
-content_hash = "sha256:c0d5e239050af875df6376cc117dcc6141e517be65cfe96989d2cc5f73589b93"
+content_hash = "sha256:a2a1de9527b2d652e07f51871b1895aeb4e92b10370939bcf5e9a492d0cabd92"
[[metadata.targets]]
requires_python = ">=3.12,<3.15"
@@ -4786,7 +4786,7 @@ files = [
[[package]]
name = "pypdf"
-version = "6.10.2"
+version = "6.13.2"
requires_python = ">=3.9"
summary = "A pure-python PDF library capable of splitting, merging, cropping, and transforming PDF files"
groups = ["default"]
@@ -4794,8 +4794,8 @@ dependencies = [
"typing-extensions>=4.0; python_version < \"3.11\"",
]
files = [
- {file = "pypdf-6.10.2-py3-none-any.whl", hash = "sha256:aa53be9826655b51c96741e5d7983ca224d898ac0a77896e64636810517624aa"},
- {file = "pypdf-6.10.2.tar.gz", hash = "sha256:7d09ce108eff6bf67465d461b6ef352dcb8d84f7a91befc02f904455c6eea11d"},
+ {file = "pypdf-6.13.2-py3-none-any.whl", hash = "sha256:6eeb9e57693f29d41bd01255d02660cbbb41fd7fc818a982677389a35e4f2083"},
+ {file = "pypdf-6.13.2.tar.gz", hash = "sha256:5a96a17dbdfbf9c2ab24c0a13fa0aba182be22ba6f283098712c16fc242f509f"},
]
[[package]]
diff --git a/pyproject.toml b/pyproject.toml
index 6fef88ccf8..3670afb962 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -46,7 +46,7 @@ dependencies = [
"sqlalchemy-utc~=0.14",
"wikipedia~=1.4",
"arxiv~=2.4",
- "pypdf~=6.10.1", # CVE-2026-33123, CVE-2026-31826, GHSA-9m86-7pmv-2852, CVE-2026-27888, CVE-2026-27024, CVE-2026-0777, CVE-2025-55197, GHSA-3crg-w4f6-42mx fixes
+ "pypdf~=6.12", # CVE-2026-33123, CVE-2026-31826, GHSA-9m86-7pmv-2852, CVE-2026-27888, CVE-2026-27024, CVE-2026-0777, CVE-2025-55197, GHSA-3crg-w4f6-42mx, GHSA-248m-82v9-q6g6, GHSA-cj93-chg6-vgv8 fixes
"sentence-transformers~=5.2",
"faiss-cpu~=1.13.0", # 1.14.x wheels SIGILL on CPUs without AVX2 (#4480); unpin criteria tracked in #4499
"pydantic~=2.12",
diff --git a/src/local_deep_research/database/migrations/versions/0013_remove_meta_search_engines.py b/src/local_deep_research/database/migrations/versions/0013_remove_meta_search_engines.py
index 052e3da46f..530b2cba99 100644
--- a/src/local_deep_research/database/migrations/versions/0013_remove_meta_search_engines.py
+++ b/src/local_deep_research/database/migrations/versions/0013_remove_meta_search_engines.py
@@ -171,7 +171,7 @@ def _rewrite_queued_research_snapshots(conn) -> None:
def _rewrite_benchmark_search_configs(conn, table: str) -> None:
rows = conn.execute(
- sa.text(f"SELECT id, search_config FROM {table}") # noqa: S608 — table is a hardcoded literal
+ sa.text(f"SELECT id, search_config FROM {table}") # noqa: S608 # bearer:disable python_lang_sql_injection — table is always a hardcoded literal ("benchmark_runs"/"benchmark_configs")
).fetchall()
rewritten = 0
@@ -185,7 +185,7 @@ def _rewrite_benchmark_search_configs(conn, table: str) -> None:
config["search_tool"] = REPLACEMENT_ENGINE
conn.execute(
sa.text(
- f"UPDATE {table} SET search_config = :config " # noqa: S608 — table is a hardcoded literal
+ f"UPDATE {table} SET search_config = :config " # noqa: S608 # bearer:disable python_lang_sql_injection — table is always a hardcoded literal ("benchmark_runs"/"benchmark_configs")
"WHERE id = :id"
),
{"config": json.dumps(config), "id": row_id},
diff --git a/src/local_deep_research/research_library/routes/rag_routes.py b/src/local_deep_research/research_library/routes/rag_routes.py
index 2ec1757f8d..f339ea7b5d 100644
--- a/src/local_deep_research/research_library/routes/rag_routes.py
+++ b/src/local_deep_research/research_library/routes/rag_routes.py
@@ -196,11 +196,16 @@ def _format_test_embedding_error(exc: Exception, model: str) -> str:
type_module = type(exc).__module__ or ""
if _module_matches(type_module, _INTERNAL_MODULE_PREFIX):
+ # Internal LDR exceptions can carry filesystem paths / SQL fragments
+ # that sanitize_error_message() does not pattern-match, so we do not
+ # echo their detail to the browser — the full trace is in the server
+ # logs (logger.exception at the call site) which the user is asked to
+ # attach.
return (
f"Embedding test failed for model '{model}' due to an "
f"internal LDR error ({type_name}). This is a bug in LDR, "
"not your configuration. Please report it on GitHub with "
- f"the server logs. Detail: {detail}"
+ "the server logs."
)
if any(
@@ -2276,7 +2281,12 @@ def index_collection(collection_id):
)
except Exception as e:
results["failed"] += 1
- error_msg = str(e) or "Failed to index document"
+ # Scrub creds/keys before surfacing to the browser
+ # (SSE yield below); full trace stays in server logs.
+ error_msg = (
+ sanitize_error_message(str(e))
+ or "Failed to index document"
+ )
results["errors"].append(
{
"filename": filename,
@@ -2596,7 +2606,9 @@ def _background_index_worker(
db_password,
task_id,
status="failed",
- error_message=str(e),
+ # Scrub creds/keys: this is later returned to the client by the
+ # index-status endpoint; full trace stays in server logs above.
+ error_message=sanitize_error_message(str(e)),
)
diff --git a/tests/chat/test_chat_research_triggering.py b/tests/chat/test_chat_research_triggering.py
index 6ab81f5560..0f9f283703 100644
--- a/tests/chat/test_chat_research_triggering.py
+++ b/tests/chat/test_chat_research_triggering.py
@@ -121,7 +121,7 @@ class TestResearchTriggering:
def test_send_message_unencrypted_db_allows_research_without_password(
self, authenticated_client
):
- """Non-encrypted DB must NOT be blocked by the password guard.
+ """A plaintext (no-SQLCipher) DB must NOT be blocked by the password guard.
resolve_user_password returns (None, session_expired=False) for an
unencrypted install, so the chat research path must proceed.