~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): Harden Content Security Policy with nonce support
LearningCircuit11031d20ae4f
diff --git a/src/local_deep_research/web/app_factory.py b/src/local_deep_research/web/app_factory.pyindex e08d656835..479aaf8c6c 100644--- a/src/local_deep_research/web/app_factory.py+++ b/src/local_deep_research/web/app_factory.py@@ -314,18 +314,36 @@ def apply_middleware(app):finally:g.db_session = None- # Add Content Security Policy headers to allow Socket.IO to function+ # Generate CSP nonce for each request+ @app.before_request+ def generate_csp_nonce():+ """Generate a unique nonce for CSP on each request."""+ from flask import g+ import secrets++ # Generate a cryptographically secure nonce+ g.csp_nonce = secrets.token_urlsafe(16)++ # Add Content Security Policy headers with nonce support@app.after_requestdef add_security_headers(response):- # Define a permissive CSP for development that allows Socket.IO to function+ from flask import g++ # Get the CSP nonce for this request+ nonce = getattr(g, "csp_nonce", "")++ # Define a secure CSP with nonce support+ # Removed unsafe-eval for security+ # Using unsafe-hashes to allow inline event handlers (onclick, etc.) temporarily+ # connect-src restricted to specific protocols and selfcsp = ("default-src 'self'; "- "connect-src 'self' ws: wss: http: https:; "- "script-src 'self' 'unsafe-inline' 'unsafe-eval'; "- "style-src 'self' 'unsafe-inline'; "+ f"script-src 'self' 'nonce-{nonce}' 'unsafe-hashes'; "+ f"style-src 'self' 'nonce-{nonce}' 'unsafe-inline'; "+ "connect-src 'self' ws://localhost:* wss://localhost:* ws://127.0.0.1:* wss://127.0.0.1:*; ""font-src 'self' data:; "- "img-src 'self' data:; "- "worker-src blob:; "+ "img-src 'self' data: blob:; "+ "worker-src 'self' blob:; ""frame-src 'self';")diff --git a/src/local_deep_research/web/templates/base.html b/src/local_deep_research/web/templates/base.htmlindex e4028c0a1d..9cf4b3a413 100644--- a/src/local_deep_research/web/templates/base.html+++ b/src/local_deep_research/web/templates/base.html@@ -59,7 +59,7 @@<script src="/static/js/config/urls.js"></script><!-- Logo click handler -->- <script>+ <script nonce="{{ g.csp_nonce }}">document.addEventListener('DOMContentLoaded', function() {const logoLink = document.getElementById('logo-link');if (logoLink) {@@ -88,7 +88,7 @@<!-- Page-specific JS -->{% block page_scripts %}{% endblock %}- <script>+ <script nonce="{{ g.csp_nonce }}">// Configure marked to not use evalif (typeof marked !== 'undefined') {marked.setOptions({