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): don't log the user's path when blocking a restricted directory (#4820)

LearningCircuit335ebb2df8c2
diff --git a/changelog.d/4820.security.md b/changelog.d/4820.security.md
new file mode 100644
index 0000000000..b983007955
--- /dev/null
+++ b/changelog.d/4820.security.md
@@ -0,0 +1 @@
+**Restricted-directory access blocks no longer log the user's path.** When local file/RAG path validation blocks access to a system directory, the error log now names only which restricted directory was hit (e.g. `/etc`) instead of the user's full resolved path, which could contain a username.
diff --git a/src/local_deep_research/security/path_validator.py b/src/local_deep_research/security/path_validator.py
index 1e0821959a..2d80d3605b 100644
--- a/src/local_deep_research/security/path_validator.py
+++ b/src/local_deep_research/security/path_validator.py
@@ -285,8 +285,10 @@ class PathValidator:
except OSError:
restricted_resolved = restricted
if validated_path.is_relative_to(restricted_resolved):
+ # Log WHICH restricted dir was hit, not the user's submitted
+ # path — a resolved local path can contain a username.
logger.error(
- f"Security: Blocked access to restricted directory: {validated_path}"
+ f"Security: blocked access to a restricted directory ({restricted})"
)
raise ValueError("Cannot access system directories")
diff --git a/tests/security/test_path_validator.py b/tests/security/test_path_validator.py
index 48f6874d2e..c44a6ed030 100644
--- a/tests/security/test_path_validator.py
+++ b/tests/security/test_path_validator.py
@@ -231,6 +231,35 @@ class TestValidateLocalFilesystemPath:
)
assert result is not None
+ def test_restricted_dir_block_does_not_log_user_path(self, temp_safe_dir):
+ """The restricted-dir block must log WHICH restricted dir was hit, not
+ the user's submitted path — a resolved local path can contain a
+ username."""
+ from loguru import logger
+
+ secret_segment = "alice-private-7f3a2b"
+ target = str(temp_safe_dir / secret_segment / "file.txt")
+
+ # The package disables loguru by default (__init__.py); enable it so the
+ # error emitted from inside the module reaches our sink.
+ logger.enable("local_deep_research")
+ logged: list[str] = []
+ sink_id = logger.add(
+ lambda m: logged.append(m.record["message"]), level="ERROR"
+ )
+ try:
+ with pytest.raises(ValueError):
+ PathValidator.validate_local_filesystem_path(
+ target, restricted_dirs=[temp_safe_dir]
+ )
+ finally:
+ logger.remove(sink_id)
+ logger.disable("local_deep_research")
+
+ blocked = [m for m in logged if "restricted directory" in m.lower()]
+ assert blocked, "expected a restricted-dir block error log"
+ assert all(secret_segment not in m for m in blocked)
+
class TestValidateConfigPath:
"""Tests for PathValidator.validate_config_path()."""