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): confine_to_base symlink-loop detection on Python 3.13+ (3.14 CI failures) (#4864)

LearningCircuit4c5f26f5b3fb
diff --git a/changelog.d/4864.security.md b/changelog.d/4864.security.md
new file mode 100644
index 0000000000..c24b889a37
--- /dev/null
+++ b/changelog.d/4864.security.md
@@ -0,0 +1 @@
+Symlink-loop confinement for RAG local indexing now works on Python 3.13+. The check relied on `Path.resolve()` raising on a symlink loop, which newer Python no longer does; it now resolves with `strict=True` so a planted in-base symlink loop is correctly skipped rather than silently kept.
diff --git a/src/local_deep_research/security/path_validator.py b/src/local_deep_research/security/path_validator.py
index 14801d3651..b738c00a64 100644
--- a/src/local_deep_research/security/path_validator.py
+++ b/src/local_deep_research/security/path_validator.py
@@ -341,12 +341,15 @@ class PathValidator:
``base``. The basename of each dropped entry is logged — never the full
path, which can contain a username.
- A candidate that cannot be resolved is dropped. ``Path.resolve()`` raises
- ``RuntimeError`` (not ``OSError``) on a symlink loop, so both are caught —
- otherwise a single planted loop would propagate to the caller instead of
- just skipping that entry. (A *broken* symlink does not raise; it resolves
- to its missing target and is kept or dropped by location, then handled by
- the caller's own existence check.)
+ A candidate that cannot be resolved is dropped. Resolution must use
+ ``resolve(strict=True)``: a symlink loop then raises (``RuntimeError``
+ through 3.12, ``OSError``/ELOOP on 3.13+, both caught) so the entry is
+ skipped instead of propagating. The default ``resolve(strict=False)``
+ cannot be relied on — 3.13+ reimplements it on
+ ``os.path.realpath(strict=False)``, which returns the loop path
+ unchanged, silently keeping a planted in-base loop. A *broken* symlink
+ also raises under ``strict=True`` (its target is missing) and is
+ dropped, the same end result as the caller's own existence check.
Known limits — both require write access to ``base``, the same
precondition as the symlink escape this closes, so they don't widen the
@@ -361,17 +364,19 @@ class PathValidator:
# Log the basename only — the full path can contain a username.
name = Path(p).name
try:
- if Path(p).resolve().is_relative_to(resolved_base):
- confined.append(p)
- else:
- logger.warning(
- f"Skipped a path resolving outside the base "
- f"directory: {name}"
- )
+ real = Path(p).resolve(strict=True)
except (OSError, RuntimeError):
logger.warning(
f"Skipped a path that could not be resolved: {name}"
)
+ continue
+ if real.is_relative_to(resolved_base):
+ confined.append(p)
+ else:
+ logger.warning(
+ f"Skipped a path resolving outside the base directory: "
+ f"{name}"
+ )
return confined
@staticmethod