~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: Address additional CodeQL alerts in security fixes
LearningCircuitf259e43b5292
diff --git a/src/local_deep_research/research_library/routes/library_routes.py b/src/local_deep_research/research_library/routes/library_routes.pyindex ad5080f4dc..415ab6df0c 100644--- a/src/local_deep_research/research_library/routes/library_routes.py+++ b/src/local_deep_research/research_library/routes/library_routes.py@@ -542,15 +542,16 @@ def download_text_single(resource_id):success, error = service.download_as_text(resource_id)# Sanitize error message - don't expose internal details- if not success and error:- logger.warning(- f"Download as text failed for resource {resource_id}: {error}"- )+ if not success:+ if error:+ logger.warning(+ f"Download as text failed for resource {resource_id}: {error}"+ )return jsonify({"success": False, "error": "Failed to download resource"})- return jsonify({"success": success, "error": error})+ return jsonify({"success": True, "error": None})except Exception as e:return handle_api_error(f"downloading resource {resource_id} as text", ediff --git a/src/local_deep_research/research_library/routes/rag_routes.py b/src/local_deep_research/research_library/routes/rag_routes.pyindex 5b6e79e676..ecd1981678 100644--- a/src/local_deep_research/research_library/routes/rag_routes.py+++ b/src/local_deep_research/research_library/routes/rag_routes.py@@ -69,48 +69,52 @@ def validate_local_index_path(user_path: str) -> Path:Raises:ValueError: If path is invalid or points to restricted location"""- import os-if not user_path or not isinstance(user_path, str):raise ValueError("Invalid path input")- # Strip whitespace and expand user home directory+ # Strip whitespaceuser_path = user_path.strip()- try:- # Expand ~ and resolve to absolute path- path = Path(user_path).expanduser().resolve()- except (RuntimeError, OSError) as e:- logger.warning(f"Path resolution failed for '{user_path}': {e}")+ # Block obvious traversal patterns before path construction+ if ".." in user_path:+ logger.warning(f"Path contains traversal pattern: {user_path}")raise ValueError("Invalid path format")- # List of restricted system directories (Unix-like systems)- restricted_dirs = [- Path("/etc"),- Path("/sys"),- Path("/proc"),- Path("/dev"),- Path("/root"),- Path("/boot"),- Path("/var/log"),+ # List of restricted path prefixes (as strings before Path construction)+ restricted_prefixes = [+ "/etc/",+ "/sys/",+ "/proc/",+ "/dev/",+ "/root/",+ "/boot/",+ "/var/log/",]- # Check if path is under any restricted directory- for restricted in restricted_dirs:- try:- if path.is_relative_to(restricted):- logger.warning(- f"Blocked attempt to index restricted directory: {path}"- )- raise ValueError("Cannot index system directories")- except (ValueError, AttributeError):- # is_relative_to may raise ValueError or not exist in older Python- # Fallback to string comparison- if str(path).startswith(str(restricted) + os.sep):- logger.warning(- f"Blocked attempt to index restricted directory: {path}"- )- raise ValueError("Cannot index system directories")+ # Expand ~ first (safe operation on string)+ # Then check against restricted prefixes before creating Path object+ normalized_path = user_path+ if user_path.startswith("~"):+ # Get home directory safely+ home = Path.home()+ normalized_path = str(home / user_path[2:].lstrip("/"))++ # Check normalized path string against restricted prefixes+ for prefix in restricted_prefixes:+ if normalized_path.startswith(+ prefix+ ) or normalized_path == prefix.rstrip("/"):+ logger.warning(+ f"Blocked attempt to index restricted directory: {normalized_path}"+ )+ raise ValueError("Cannot index system directories")++ # Now safe to construct Path object after validation+ try:+ path = Path(normalized_path).resolve()+ except (RuntimeError, OSError, ValueError) as e:+ logger.warning(f"Path resolution failed: {e}")+ raise ValueError("Invalid path format")return path