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.

feat: Enhance security logging and add Windows path protection

LearningCircuit0dd716b501f7
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 22ced5fb2e..cb27463937 100644
--- a/src/local_deep_research/research_library/routes/rag_routes.py
+++ b/src/local_deep_research/research_library/routes/rag_routes.py
@@ -20,6 +20,7 @@ from flask import (
from loguru import logger
import glob
import json
+import sys
import uuid
from pathlib import Path
from typing import Optional
@@ -104,8 +105,9 @@ def validate_local_index_path(user_path: str) -> Path:
user_path, home, allow_absolute=False
)
- # Block restricted system directories
+ # Block restricted system directories (Unix and Windows)
restricted_dirs = [
+ # Unix system directories
Path("/etc"),
Path("/sys"),
Path("/proc"),
@@ -115,20 +117,40 @@ def validate_local_index_path(user_path: str) -> Path:
Path("/var/log"),
]
+ # Add Windows system directories if on Windows
+ if sys.platform == "win32":
+ # Common Windows system directories (all possible drive letters)
+ for drive in ["C:", "D:", "E:"]:
+ restricted_dirs.extend(
+ [
+ Path(f"{drive}\\Windows"),
+ Path(f"{drive}\\System32"),
+ Path(f"{drive}\\Program Files"),
+ Path(f"{drive}\\Program Files (x86)"),
+ ]
+ )
+
for restricted in restricted_dirs:
+ # Check if path is under restricted directory
+ is_restricted = False
+
try:
- if validated_path.is_relative_to(restricted):
- logger.warning(
- f"Blocked attempt to index restricted directory: {validated_path}"
- )
- raise ValueError("Cannot index system directories")
+ # Try modern Python's is_relative_to() method
+ is_restricted = validated_path.is_relative_to(restricted)
except (ValueError, AttributeError):
- # Fallback for older Python versions
- if str(validated_path).startswith(str(restricted) + "/"):
- logger.warning(
- f"Blocked attempt to index restricted directory: {validated_path}"
- )
- raise ValueError("Cannot index system directories")
+ # Fallback for older Python versions or path comparison issues
+ # Check both Unix-style and Windows-style path separators
+ path_str = str(validated_path)
+ restricted_str = str(restricted)
+ is_restricted = path_str.startswith(
+ restricted_str + "/"
+ ) or path_str.startswith(restricted_str + "\\")
+
+ if is_restricted:
+ logger.error(
+ f"Security: Blocked attempt to index restricted directory: {validated_path}"
+ )
+ raise ValueError("Cannot index system directories")
return validated_path