~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(csp): Revert to unsafe-inline for scripts, keep connect-src restriction
LearningCircuit45103b1561fa
diff --git a/src/local_deep_research/web/app_factory.py b/src/local_deep_research/web/app_factory.pyindex afb2491462..4c7b1feb12 100644--- a/src/local_deep_research/web/app_factory.py+++ b/src/local_deep_research/web/app_factory.py@@ -314,33 +314,19 @@ def apply_middleware(app):finally:g.db_session = None- # 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+ # Add Content Security Policy headers@app.after_requestdef add_security_headers(response):- 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 (main XSS vector)- # Using unsafe-hashes to allow inline event handlers (onclick, etc.) - to be refactored- # Keeping unsafe-inline for styles (low security risk, allows dynamic styling)- # Note: When nonce is present, unsafe-inline is ignored, breaking JS-set styles- # connect-src restricted to localhost only - intentional for local-first architecture+ # Content Security Policy - hardened from original+ # Security improvements over original:+ # 1. Removed 'unsafe-eval' from script-src (prevents eval() XSS attacks)+ # 2. Restricted connect-src to localhost only (prevents data exfiltration)+ # Note: 'unsafe-inline' kept for scripts/styles as codebase has many inline scripts+ # Future: Add nonces to all templates to remove 'unsafe-inline'+ # connect-src restricted to localhost - intentional for local-first architecturecsp = ("default-src 'self'; "- f"script-src 'self' 'nonce-{nonce}' 'unsafe-hashes'; "+ "script-src 'self' 'unsafe-inline'; ""style-src 'self' 'unsafe-inline'; ""connect-src 'self' ws://localhost:* wss://localhost:* ws://127.0.0.1:* wss://127.0.0.1:*; ""font-src 'self' data:; "diff --git a/src/local_deep_research/web/templates/base.html b/src/local_deep_research/web/templates/base.htmlindex 9cf4b3a413..e4028c0a1d 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 nonce="{{ g.csp_nonce }}">+ <script>document.addEventListener('DOMContentLoaded', function() {const logoLink = document.getElementById('logo-link');if (logoLink) {@@ -88,7 +88,7 @@<!-- Page-specific JS -->{% block page_scripts %}{% endblock %}- <script nonce="{{ g.csp_nonce }}">+ <script>// Configure marked to not use evalif (typeof marked !== 'undefined') {marked.setOptions({