~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(proxy): warn after earlier plain HTTP requests (#7034)
LearningCircuita290ca2b4341
diff --git a/changelog.d/+proxy-warning-observation.bugfix.md b/changelog.d/+proxy-warning-observation.bugfix.mdnew file mode 100644index 0000000000..68680e3033--- /dev/null+++ b/changelog.d/+proxy-warning-observation.bugfix.md@@ -0,0 +1 @@+Keep checking plain-HTTP requests for an untrusted HTTPS proxy header until the configuration warning is emitted, so an earlier health check or direct request cannot suppress the warning.diff --git a/src/local_deep_research/web/fastapi_app.py b/src/local_deep_research/web/fastapi_app.pyindex 7c706bd157..a360af2272 100644--- a/src/local_deep_research/web/fastapi_app.py+++ b/src/local_deep_research/web/fastapi_app.py@@ -1035,19 +1035,12 @@ class SecureCookieMiddleware:The tell is a request that carries ``X-Forwarded-Proto: https`` whilethe connection is not being treated as HTTPS. Cheap: this only runs onthe not-https path (a correctly configured deployment never reaches- it), and short-circuits on a bool before touching headers, so it scans- them at most once per process.+ it), and stops checking headers after the first warning. Until then,+ each request must be checked: a headerless health check or an+ untrusted direct client must not conceal a later proxy request."""if self._warned_untrusted_forwarded_proto:return- # Set BEFORE deciding whether to warn, not after. The diagnosis is a- # per-process property, so scanning once is enough either way. Setting- # it only on the warn path (the original shape) meant the common- # deployment — plain HTTP with no proxy, so the header is absent —- # never set it and re-scanned every header of every request for the- # life of the process, which is the opposite of what this method's- # docstring promised.- self._warned_untrusted_forwarded_proto = True# Only meaningful from a proxy on the loopback/private network. This# header is untrusted client input: any remote client could otherwise@@ -1064,6 +1057,7 @@ class SecureCookieMiddleware:# Left-most value is the original client protocol when a chain of# proxies has appended to the header.if value.split(b",")[0].strip().lower() == b"https":+ self._warned_untrusted_forwarded_proto = Truelogger.warning("Received X-Forwarded-Proto: https but this connection is ""not being treated as HTTPS, so session cookies will NOT "diff --git a/tests/web/test_forwarded_proto_warning.py b/tests/web/test_forwarded_proto_warning.pyindex 44f1d11587..e77eb35c32 100644--- a/tests/web/test_forwarded_proto_warning.py+++ b/tests/web/test_forwarded_proto_warning.py@@ -11,6 +11,7 @@ HTTPS.`_maybe_warn_untrusted_forwarded_proto` covers exactly that gap."""+import pytestfrom starlette.responses import PlainTextResponsefrom starlette.testclient import TestClient@@ -64,6 +65,36 @@ def test_warns_at_most_once_per_process(loguru_caplog_full):)[email protected]("first_headers", [{}, {"X-Forwarded-Proto": "http"}])+def test_later_proxy_request_warns_after_plain_http_request(+ loguru_caplog_full, first_headers+):+ """A health check must not use up the one warning for a later proxy."""+ client = _client()+ with loguru_caplog_full.at_level("WARNING"):+ client.get("/", headers=first_headers)+ client.get("/", headers={"X-Forwarded-Proto": "https"})+ client.get("/", headers={"X-Forwarded-Proto": "https"})++ assert len(_warnings(loguru_caplog_full)) == 1+++def test_public_request_cannot_suppress_later_private_proxy_warning(+ loguru_caplog_full,+):+ """An untrusted direct client must not silence the operator's warning."""+ middleware = SecureCookieMiddleware(_ok_app, testing=False)+ public = TestClient(middleware, client=("8.8.8.8", 40000))+ private = TestClient(middleware, client=("127.0.0.1", 40001))++ with loguru_caplog_full.at_level("WARNING"):+ public.get("/", headers={"X-Forwarded-Proto": "https"})+ assert not _warnings(loguru_caplog_full)+ private.get("/", headers={"X-Forwarded-Proto": "https"})++ assert len(_warnings(loguru_caplog_full)) == 1++def test_silent_when_no_forwarded_proto_header(loguru_caplog_full):"""Negative control. Without it, a middleware that warned on EVERY plainHTTP request would satisfy the first test for the wrong reason — and would