~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(security): close WebSocket CORS default and stop ACAO leak for non-whitelisted origins (#3091)
LearningCircuitb84915a67489
diff --git a/src/local_deep_research/security/security_headers.py b/src/local_deep_research/security/security_headers.pyindex fed38e402b..f7a70802ac 100644--- a/src/local_deep_research/security/security_headers.py+++ b/src/local_deep_research/security/security_headers.py@@ -309,19 +309,34 @@ class SecurityHeaders:if request_origin in allowed_origins_set:origin_to_send = request_originelse:- # Request origin not in whitelist - log but still set configured origin- # (Browsers will enforce CORS, this just logs for monitoring)+ # Request origin not in whitelist — do NOT emit ACAO header+ # so the browser blocks the request outright.logger.warning(f"CORS request from non-whitelisted origin: {request_origin}. "f"Allowed origins: {configured_origins}")- # Use first configured origin for backward compatibility- origin_to_send = list(allowed_origins_set)[0]+ return response# Single origin configured - always use it (browser enforces CORS)else:origin_to_send = configured_originsresponse.headers["Access-Control-Allow-Origin"] = origin_to_send++ # When the ACAO value is dynamic (not a fixed wildcard), caches must+ # key on the Origin request header to avoid serving one origin's ACAO+ # to a different origin.+ if origin_to_send != "*":+ existing_vary = response.headers.get("Vary", "")+ if not any(+ v.strip().lower() == "origin"+ for v in existing_vary.split(",")+ if v.strip()+ ):+ if existing_vary:+ response.headers["Vary"] = f"{existing_vary}, Origin"+ else:+ response.headers["Vary"] = "Origin"+response.headers["Access-Control-Allow-Methods"] = ("GET, POST, PUT, DELETE, OPTIONS")diff --git a/src/local_deep_research/web/services/socket_service.py b/src/local_deep_research/web/services/socket_service.pyindex 6618a445d7..74dc5fc092 100644--- a/src/local_deep_research/web/services/socket_service.py+++ b/src/local_deep_research/web/services/socket_service.py@@ -61,8 +61,8 @@ class SocketIOService:else:socketio_cors = Noneelse:- # No env var set — preserve existing permissive default- socketio_cors = "*"+ # No env var set — fail closed to same-origin only, matching HTTP CORS default+ socketio_cors = Noneif socketio_cors is None:logger.info(diff --git a/tests/security/test_security_headers_gaps.py b/tests/security/test_security_headers_gaps.pyindex 4675a87695..ba81757213 100644--- a/tests/security/test_security_headers_gaps.py+++ b/tests/security/test_security_headers_gaps.py@@ -196,8 +196,7 @@ class TestCorsHeaders:resp = client.get("/api/test", headers={"Origin": "https://evil.com"})- origin = resp.headers["Access-Control-Allow-Origin"]- assert origin in ("https://a.com", "https://b.com")+ assert "Access-Control-Allow-Origin" not in resp.headersdef test_non_api_route_no_cors(self):app = _make_app(SECURITY_CORS_ALLOWED_ORIGINS="*")