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: remove CORS wildcard, restrict CSP connect-src, use logger (#1960)

LearningCircuite64acce1f02b
diff --git a/src/local_deep_research/security/security_headers.py b/src/local_deep_research/security/security_headers.py
index 3895ea4e31..fed38e402b 100644
--- a/src/local_deep_research/security/security_headers.py
+++ b/src/local_deep_research/security/security_headers.py
@@ -39,7 +39,7 @@ class SecurityHeaders:
app: Flask application instance
Security Configuration:
- SECURITY_CSP_CONNECT_SRC: Restricts WebSocket/fetch connections (default: 'self' ws: wss:)
+ SECURITY_CSP_CONNECT_SRC: Restricts WebSocket/fetch connections (default: 'self')
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
@@ -58,10 +58,13 @@ class SecurityHeaders:
requests without credentials. Use 'require-corp' for stricter isolation.
"""
# Set default security configuration
- # connect-src uses 'self' + ws:/wss: to work from any origin (localhost, LAN, Docker, internet)
+ # connect-src restricted to 'self' — covers same-origin HTTP requests.
+ # Socket.IO uses HTTP long-polling transport with same-origin URLs
+ # (baseUrl = window.location.protocol + '//' + window.location.host),
+ # so explicit ws:/wss: schemes are not needed.
app.config.setdefault(
"SECURITY_CSP_CONNECT_SRC",
- "'self' ws: wss:",
+ "'self'",
)
app.config.setdefault("SECURITY_CORS_ENABLED", True)
app.config.setdefault("SECURITY_CORS_ALLOW_CREDENTIALS", False)
@@ -104,9 +107,11 @@ class SecurityHeaders:
CSP policy string with directives for Socket.IO compatibility
Note:
- - 'unsafe-inline' is required for Socket.IO compatibility
+ - 'unsafe-inline' is required for Socket.IO compatibility; removing it
+ would break real-time WebSocket functionality. If Socket.IO is removed
+ in the future, 'unsafe-inline' should be tightened immediately.
- 'unsafe-eval' removed for better XSS protection (not needed for Socket.IO)
- - connect-src uses 'self' ws: wss: by default (works from any origin)
+ - connect-src defaults to 'self' (same-origin HTTP + WebSocket)
"""
connect_src = self.app.config.get("SECURITY_CSP_CONNECT_SRC", "'self'")
return (
@@ -325,7 +330,7 @@ class SecurityHeaders:
)
# Set credentials if configured and not using wildcard
- # Note: Startup validation ensures credentials is False with wildcard or multi-origin
+ # Note: Startup validation rejects credentials with wildcard origin
if allow_credentials and origin_to_send != "*":
response.headers["Access-Control-Allow-Credentials"] = "true"