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: address 3 critical security issues from AI code review

LearningCircuit68daaa20d09c
diff --git a/src/local_deep_research/security/security_headers.py b/src/local_deep_research/security/security_headers.py
index 92cb20180a..f4c6dbb10c 100644
--- a/src/local_deep_research/security/security_headers.py
+++ b/src/local_deep_research/security/security_headers.py
@@ -42,7 +42,8 @@ class SecurityHeaders:
SECURITY_CORS_ENABLED: Enable CORS for API routes (default: True)
SECURITY_CORS_ALLOW_CREDENTIALS: Allow credentials in CORS (default: False)
SECURITY_CORS_ALLOWED_ORIGINS: Allowed CORS origins, comma-separated for multiple
- (default: "*"). Multi-origin uses origin reflection.
+ (default: "" - requires explicit configuration).
+ Multi-origin uses origin reflection.
SECURITY_COEP_POLICY: Cross-Origin-Embedder-Policy applied globally to ALL routes
(default: "credentialless"). Options: require-corp, credentialless, unsafe-none
@@ -61,7 +62,9 @@ class SecurityHeaders:
)
app.config.setdefault("SECURITY_CORS_ENABLED", True)
app.config.setdefault("SECURITY_CORS_ALLOW_CREDENTIALS", False)
- app.config.setdefault("SECURITY_CORS_ALLOWED_ORIGINS", "*")
+ # Default to empty (fail closed) - require explicit configuration for CORS
+ # Using "*" creates a security footgun - users must explicitly allow origins
+ app.config.setdefault("SECURITY_CORS_ALLOWED_ORIGINS", "")
app.config.setdefault("SECURITY_COEP_POLICY", "credentialless")
self.app = app
@@ -196,7 +199,7 @@ class SecurityHeaders:
return
allowed_origins = self.app.config.get(
- "SECURITY_CORS_ALLOWED_ORIGINS", "*"
+ "SECURITY_CORS_ALLOWED_ORIGINS", ""
)
allow_credentials = self.app.config.get(
"SECURITY_CORS_ALLOW_CREDENTIALS", False
@@ -233,7 +236,7 @@ class SecurityHeaders:
- Single origin or reflected origins allow credentials if configured
"""
configured_origins = self.app.config.get(
- "SECURITY_CORS_ALLOWED_ORIGINS", "*"
+ "SECURITY_CORS_ALLOWED_ORIGINS", ""
)
allow_credentials = self.app.config.get(
"SECURITY_CORS_ALLOW_CREDENTIALS", False
diff --git a/src/local_deep_research/utils/safe_requests.py b/src/local_deep_research/utils/safe_requests.py
index 73c581b7e5..2a25d50244 100644
--- a/src/local_deep_research/utils/safe_requests.py
+++ b/src/local_deep_research/utils/safe_requests.py
@@ -50,10 +50,11 @@ def safe_get(
if "timeout" not in kwargs:
kwargs["timeout"] = timeout
- # Allow redirects by default (initial URL is validated, but redirect targets are not)
- # Note: For maximum security, consider setting allow_redirects=False explicitly
+ # Disable redirects by default to prevent SSRF bypass via redirect chains
+ # Redirects could point to internal services, bypassing initial URL validation
+ # Callers can explicitly enable redirects if needed and trust the redirect target
if "allow_redirects" not in kwargs:
- kwargs["allow_redirects"] = True
+ kwargs["allow_redirects"] = False
try:
response = requests.get(url, params=params, **kwargs)
@@ -115,10 +116,11 @@ def safe_post(
if "timeout" not in kwargs:
kwargs["timeout"] = timeout
- # Allow redirects by default (initial URL is validated, but redirect targets are not)
- # Note: For maximum security, consider setting allow_redirects=False explicitly
+ # Disable redirects by default to prevent SSRF bypass via redirect chains
+ # Redirects could point to internal services, bypassing initial URL validation
+ # Callers can explicitly enable redirects if needed and trust the redirect target
if "allow_redirects" not in kwargs:
- kwargs["allow_redirects"] = True
+ kwargs["allow_redirects"] = False
try:
response = requests.post(url, data=data, json=json, **kwargs)
diff --git a/src/local_deep_research/web/app_factory.py b/src/local_deep_research/web/app_factory.py
index 647ace5114..2fe5af4dbc 100644
--- a/src/local_deep_research/web/app_factory.py
+++ b/src/local_deep_research/web/app_factory.py
@@ -107,6 +107,8 @@ def create_app():
app.config["PREFERRED_URL_SCHEME"] = "https"
# Initialize CSRF protection
+ # Explicitly enable CSRF protection (don't rely on implicit Flask-WTF behavior)
+ app.config["WTF_CSRF_ENABLED"] = True
CSRFProtect(app)
# Exempt Socket.IO from CSRF protection
# Note: Flask-SocketIO handles CSRF internally, so we don't need to exempt specific views