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 remaining OWASP ZAP security warnings (10049, 10055)

LearningCircuitf2210d9ecb14
diff --git a/.zap/rules.tsv b/.zap/rules.tsv
index e7eb7a018b..0f17ea74f8 100644
--- a/.zap/rules.tsv
+++ b/.zap/rules.tsv
@@ -77,7 +77,6 @@
100000 WARN A Client Error response code was returned by the server
# Informational alerts - expected behavior, not vulnerabilities
-10036 IGNORE Server Leaks Version Information (suppressed in code, but ignore if detected)
10111 IGNORE Authentication Request Identified (expected - we have login form)
10112 IGNORE Session Management Response Identified (expected - we use sessions)
90005 IGNORE Sec-Fetch-Dest Header is Missing (browser-added header, not server responsibility)
diff --git a/src/local_deep_research/security/security_headers.py b/src/local_deep_research/security/security_headers.py
index 41811f4fc1..0a31d04439 100644
--- a/src/local_deep_research/security/security_headers.py
+++ b/src/local_deep_research/security/security_headers.py
@@ -101,8 +101,11 @@ class SecurityHeaders:
"style-src 'self' 'unsafe-inline'; "
"font-src 'self' data:; "
"img-src 'self' data:; "
+ "media-src 'self'; "
"worker-src blob:; "
+ "child-src 'self' blob:; "
"frame-src 'self'; "
+ "manifest-src 'self'; "
"object-src 'none'; "
"base-uri 'self'; "
"form-action 'self';"
@@ -181,6 +184,15 @@ class SecurityHeaders:
"max-age=31536000; includeSubDomains"
)
+ # Cache-Control - prevent caching of sensitive content
+ # Static assets are handled separately by the static file route
+ if not request.path.startswith("/static/"):
+ response.headers["Cache-Control"] = (
+ "no-store, no-cache, must-revalidate, max-age=0"
+ )
+ response.headers["Pragma"] = "no-cache" # HTTP/1.0 compatibility
+ response.headers["Expires"] = "0"
+
# Add CORS headers for API requests if enabled
if self._is_api_route(request.path) and self.app.config.get(
"SECURITY_CORS_ENABLED", True
diff --git a/tests/security/test_security_headers.py b/tests/security/test_security_headers.py
index 4312cdfcb5..db17b13e03 100644
--- a/tests/security/test_security_headers.py
+++ b/tests/security/test_security_headers.py
@@ -372,6 +372,51 @@ class TestCspPolicy:
assert "https://api.mysite.com" in csp
+ def test_csp_includes_media_src(self):
+ """CSP should include media-src directive."""
+ from flask import Flask
+ from local_deep_research.security.security_headers import (
+ SecurityHeaders,
+ )
+
+ app = Flask(__name__)
+ app.config["SECRET_KEY"] = "test-key"
+
+ sh = SecurityHeaders(app)
+ csp = sh.get_csp_policy()
+
+ assert "media-src 'self'" in csp
+
+ def test_csp_includes_child_src(self):
+ """CSP should include child-src directive."""
+ from flask import Flask
+ from local_deep_research.security.security_headers import (
+ SecurityHeaders,
+ )
+
+ app = Flask(__name__)
+ app.config["SECRET_KEY"] = "test-key"
+
+ sh = SecurityHeaders(app)
+ csp = sh.get_csp_policy()
+
+ assert "child-src 'self' blob:" in csp
+
+ def test_csp_includes_manifest_src(self):
+ """CSP should include manifest-src directive."""
+ from flask import Flask
+ from local_deep_research.security.security_headers import (
+ SecurityHeaders,
+ )
+
+ app = Flask(__name__)
+ app.config["SECRET_KEY"] = "test-key"
+
+ sh = SecurityHeaders(app)
+ csp = sh.get_csp_policy()
+
+ assert "manifest-src 'self'" in csp
+
class TestPermissionsPolicy:
"""Tests for get_permissions_policy method."""
@@ -454,6 +499,45 @@ class TestServerHeaderRemoval:
assert "Server" not in response.headers
+class TestCacheControlHeaders:
+ """Test Cache-Control headers are properly set."""
+
+ def test_cache_control_on_root(self, client):
+ """Root page should have Cache-Control headers."""
+ response = client.get("/")
+ assert "Cache-Control" in response.headers
+ cache_control = response.headers["Cache-Control"]
+ assert "no-store" in cache_control
+ assert "no-cache" in cache_control
+
+ def test_cache_control_on_login(self, client):
+ """Login page should have Cache-Control headers."""
+ response = client.get("/auth/login")
+ assert "Cache-Control" in response.headers
+ cache_control = response.headers["Cache-Control"]
+ assert "no-store" in cache_control
+ assert "no-cache" in cache_control
+
+ def test_cache_control_on_api(self, client):
+ """API endpoints should have Cache-Control headers."""
+ response = client.get("/api/health")
+ assert "Cache-Control" in response.headers
+ cache_control = response.headers["Cache-Control"]
+ assert "no-store" in cache_control
+
+ def test_pragma_header_present(self, client):
+ """Pragma header should be present for HTTP/1.0 compatibility."""
+ response = client.get("/")
+ assert "Pragma" in response.headers
+ assert response.headers["Pragma"] == "no-cache"
+
+ def test_expires_header_present(self, client):
+ """Expires header should be present."""
+ response = client.get("/")
+ assert "Expires" in response.headers
+ assert response.headers["Expires"] == "0"
+
+
class TestContentTypeHeaders:
"""Test Content-Type headers are properly set for HTML routes."""