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 vulnerabilities and remove redundant static route

LearningCircuitee688b498cbf
diff --git a/src/local_deep_research/web/app_factory.py b/src/local_deep_research/web/app_factory.py
index 04307ab671..36496a95ad 100644
--- a/src/local_deep_research/web/app_factory.py
+++ b/src/local_deep_research/web/app_factory.py
@@ -464,20 +464,38 @@ def register_blueprints(app):
# Add static route at the app level for compatibility
@app.route("/static/<path:path>")
def app_serve_static(path):
+ from ..security.path_validator import PathValidator
+
static_dir = Path(app.config.get("STATIC_DIR", "static"))
# First try to serve from dist directory (for built assets)
- dist_path = static_dir / "dist"
- file_path = dist_path / path
+ dist_dir = static_dir / "dist"
+ try:
+ # Use PathValidator to safely validate the path
+ validated_path = PathValidator.validate_safe_path(
+ path,
+ dist_dir,
+ allow_absolute=False,
+ required_extensions=None, # Allow any file type for static assets
+ )
- if file_path.exists():
- return send_from_directory(str(dist_path), path)
+ if validated_path and validated_path.exists():
+ return send_from_directory(str(dist_dir), path)
+ except (ValueError, Exception):
+ # Path validation failed, try regular static folder
+ pass
# Fall back to regular static folder
- regular_path = static_dir / path
+ try:
+ validated_path = PathValidator.validate_safe_path(
+ path, static_dir, allow_absolute=False, required_extensions=None
+ )
- if regular_path.exists():
- return send_from_directory(str(static_dir), path)
+ if validated_path and validated_path.exists():
+ return send_from_directory(str(static_dir), path)
+ except (ValueError, Exception):
+ # Path validation failed
+ pass
return make_response(jsonify({"error": "Not found"}), 404)
diff --git a/src/local_deep_research/web/routes/research_routes.py b/src/local_deep_research/web/routes/research_routes.py
index 41e9776fe9..16f9bf71fb 100644
--- a/src/local_deep_research/web/routes/research_routes.py
+++ b/src/local_deep_research/web/routes/research_routes.py
@@ -6,13 +6,11 @@ from pathlib import Path
from flask import (
Blueprint,
- abort,
g,
jsonify,
redirect,
request,
send_file,
- send_from_directory,
session,
url_for,
)
@@ -41,33 +39,6 @@ from .globals import active_research, termination_flags
research_bp = Blueprint("research", __name__)
-# Add the missing static file serving route
-@research_bp.route("/static/<path:path>")
-def serve_static(path):
- """Serve static files"""
- from flask import current_app
-
- # Get static dir from app config or fallback to default
- static_dir = Path(
- current_app.config.get(
- "STATIC_DIR", Path(__file__).parent.parent / "static"
- )
- )
-
- # First try to serve from dist directory (for built assets)
- dist_path = static_dir / "dist" / path
- if dist_path.exists():
- return send_from_directory(str(static_dir / "dist"), path)
-
- # Fall back to regular static folder
- regular_path = static_dir / path
- if regular_path.exists():
- return send_from_directory(str(static_dir), path)
-
- # File not found
- abort(404)
-
-
# Add static route at the root level
@research_bp.route("/redirect-static/<path:path>")
def redirect_static(path):