~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: improve CORS validation and code quality
LearningCircuit763bb25cd4c9
diff --git a/src/local_deep_research/security/security_headers.py b/src/local_deep_research/security/security_headers.pyindex 835b1fcc2f..6062adad16 100644--- a/src/local_deep_research/security/security_headers.py+++ b/src/local_deep_research/security/security_headers.py@@ -20,14 +20,13 @@ class SecurityHeaders:- Information leakage: Server header removal"""- def __init__(self, app=None):+ def __init__(self, app=None) -> None:"""Initialize security headers middleware.Args:app: Flask application instance (optional, can call init_app later)"""self.app = app- self.config = {}if app is not None:self.init_app(app)@@ -62,6 +61,10 @@ class SecurityHeaders:self.app = appapp.after_request(self.add_security_headers)++ # Validate CORS configuration at startup+ self._validate_cors_config()+logger.info("Security headers middleware initialized")logger.warning("CSP configured with 'unsafe-inline' and 'unsafe-eval' for Socket.IO compatibility. "@@ -178,6 +181,37 @@ class SecurityHeaders:"""return path.startswith("/api/") or path.startswith("/research/api/")+ def _validate_cors_config(self) -> None:+ """Validate CORS configuration at startup to catch misconfigurations early.++ Raises:+ ValueError: If CORS configuration is invalid+ """+ if not self.app.config.get("SECURITY_CORS_ENABLED", True):+ return++ allowed_origins = self.app.config.get(+ "SECURITY_CORS_ALLOWED_ORIGINS", "*"+ )+ allow_credentials = self.app.config.get(+ "SECURITY_CORS_ALLOW_CREDENTIALS", False+ )++ # Validate credentials with wildcard origin+ if allow_credentials and allowed_origins == "*":+ raise ValueError(+ "CORS misconfiguration: Cannot use credentials with wildcard origin '*'. "+ "Set SECURITY_CORS_ALLOWED_ORIGINS to a specific origin or disable credentials."+ )++ # Validate credentials with multi-origin strings+ if allow_credentials and "," in allowed_origins:+ raise ValueError(+ f"CORS misconfiguration: Cannot use credentials with multiple origins. "+ f"Found: '{allowed_origins}'. Only a single origin is allowed when credentials are enabled. "+ f"Either disable credentials or specify a single origin."+ )+def _add_cors_headers(self, response: Response) -> Response:"""Add CORS headers for API routes.