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(security): pin diagnose=False in the benchmark CLI logger (#4185) (#4403)

LearningCircuit4d932dc7bd6d
diff --git a/changelog.d/+benchmark-cli-loguru-diagnose-lockdown.security.md b/changelog.d/+benchmark-cli-loguru-diagnose-lockdown.security.md
new file mode 100644
index 0000000000..f3033c8415
--- /dev/null
+++ b/changelog.d/+benchmark-cli-loguru-diagnose-lockdown.security.md
@@ -0,0 +1 @@
+The benchmark CLI (``ldr-benchmark`` / ``benchmarks/cli/benchmark_commands.py``) now pins ``diagnose=False`` on both of its ``logger.add(sys.stderr, ...)`` calls. loguru defaults ``diagnose=True``, which renders ``repr()`` of every traceback frame's locals on exception, so the many ``logger.exception(...)`` paths in the benchmarks package (LLM grader calls, search-engine runners, dataset loaders) were writing frame-local credentials — LLM ``api_key``, ``Authorization`` headers, search-engine secrets — to stderr on any failure. Companion to the ``LDR_LOGURU_DIAGNOSE`` lockdown for the web/CLI logger (#4384) and the MCP subprocess (#4394); the benchmark CLI also bypasses ``config_logger``, so the env-var gate did not reach it.
diff --git a/src/local_deep_research/benchmarks/cli/benchmark_commands.py b/src/local_deep_research/benchmarks/cli/benchmark_commands.py
index 45fd4f33a3..73a5f02554 100644
--- a/src/local_deep_research/benchmarks/cli/benchmark_commands.py
+++ b/src/local_deep_research/benchmarks/cli/benchmark_commands.py
@@ -340,10 +340,19 @@ def main():
args = parser.parse_args()
# Set up logging with loguru
+ # diagnose=False: loguru defaults to True, which renders repr() of every
+ # local in every traceback frame on exception. The benchmarks code path
+ # has many logger.exception() call sites whose frame locals hold LLM
+ # api_key, search-engine secrets, and Authorization headers; leaving the
+ # default on would write them to stderr on any failure. Companion to
+ # #4185 / #4384 (config_logger) and #4394 (MCP); the benchmark CLI also
+ # bypasses config_logger, so the LDR_LOGURU_DIAGNOSE gate does not reach
+ # it. Pinned off here unconditionally — the CLI has --verbose for level
+ # but no operator workflow that needs frame-local repr dumps.
if args.verbose:
- logger.add(sys.stderr, level="DEBUG")
+ logger.add(sys.stderr, level="DEBUG", diagnose=False)
else:
- logger.add(sys.stderr, level="INFO")
+ logger.add(sys.stderr, level="INFO", diagnose=False)
# Run command
if hasattr(args, "func"):
diff --git a/tests/benchmarks/test_cli.py b/tests/benchmarks/test_cli.py
index 7d079e5cd3..9ade89b4e2 100644
--- a/tests/benchmarks/test_cli.py
+++ b/tests/benchmarks/test_cli.py
@@ -533,6 +533,39 @@ class TestMain:
captured = capsys.readouterr()
assert "Available Benchmarks" in captured.out
+ def test_main_pins_diagnose_false_on_logger_add(self, mock_data_directory):
+ """main() must pass diagnose=False to every logger.add (issue #4185).
+
+ loguru defaults diagnose=True, which renders repr() of every
+ traceback frame's locals on exception. Benchmarks invoke LLMs and
+ search engines whose handlers hold api_key/Authorization headers as
+ frame locals; leaving the default on would dump those to stderr on
+ any failure. The benchmark CLI bypasses config_logger, so the fix
+ lives at this entry point.
+ """
+ import local_deep_research.benchmarks.cli.benchmark_commands as module
+
+ for verbose_flag in (["--verbose"], []):
+ argv = ["ldr-benchmark"] + verbose_flag + ["list"]
+ with patch.object(sys, "argv", argv):
+ with patch(
+ "local_deep_research.benchmarks.cli.benchmark_commands.get_available_datasets",
+ return_value=[],
+ ):
+ with patch.object(module, "logger") as mock_logger:
+ module.main()
+
+ assert mock_logger.add.call_args_list, (
+ f"no logger.add calls observed for argv={argv}"
+ )
+ for add_call in mock_logger.add.call_args_list:
+ assert add_call.kwargs.get("diagnose") is False, (
+ f"benchmark CLI logger.add must pass "
+ f"diagnose=False; got "
+ f"{add_call.kwargs.get('diagnose')!r} "
+ f"for argv={argv}"
+ )
+
class TestSearchConfigBuilding:
"""Tests for search config building logic."""