You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Check resolved project ancestry without string-prefix containment #1891
Follow-up from the reviewed CodeRabbit deep scan (K4). This ticket tracks one distinct fix; duplicate scan rows are consolidated here.
Reviewed evidence and scope
K4 (scan ID c949ff1a-cdb3-4354-9b75-67cf21ee7d38, review A, Medium): Resolved containment uses string startswith, allowing sibling-prefix paths through existing symlinks. Use path ancestry; local configured-root scope.
Source at current baseline: src/basic_memory/services/project_service.py:291.
Fix and validation
Check resolved project ancestry without string-prefix containment.
Recheck current callers and supported behavior before choosing the smallest complete fix.
Add a bounded regression at the affected public or service boundary; demonstrate it fails without the fix.
Preserve legitimate inputs and tenant/project boundaries. Run focused tests plus repository static/type checks.
The scan/review establishes the code-level concern described above; it does not establish production exploitation. Conditional branches and local/tooling-only exposure must retain that scope.
Priority: Medium. This is a local, configured-root scope concern. The issue doesn't establish production exploitation.
Component: Core services (ProjectService.add_project). Not Cloud-specific, though the code path only runs when project_root is set, which is how cloud deployments configure it.
Complexity: Simple
Findings
The check is at src/basic_memory/services/project_service.py:291. It uses resolved_path.startswith(base_path.resolve().as_posix()). If project_root is /app/data, a resolved path of /app/data-evil/x passes the check. A symlink under the root that points to a sibling directory would reach that case.
The check is marked # pragma: no cover, so no test currently exercises it.
The fix is to compare path ancestry, for example Path(resolved_path).is_relative_to(base_path.resolve()), instead of comparing strings.
A regression test should create a symlink inside project_root that points to a sibling directory with the same prefix, such as root-evil. It should assert that add_project raises ValueError, and it should fail before the fix.
Remove the pragma: no cover once the test covers the branch, because the repo requires 100% coverage.
I found no duplicate issues.
Per triage scope, I haven't made any code changes.
Activity
claude commentedon Oct 28, 2026
Claude finished @phernandez's task in 16s —— View job
Triage
ProjectService.add_project). Not Cloud-specific, though the code path only runs whenproject_rootis set, which is how cloud deployments configure it.Findings
src/basic_memory/services/project_service.py:291. It usesresolved_path.startswith(base_path.resolve().as_posix()). Ifproject_rootis/app/data, a resolved path of/app/data-evil/xpasses the check. A symlink under the root that points to a sibling directory would reach that case.# pragma: no cover, so no test currently exercises it.Path(resolved_path).is_relative_to(base_path.resolve()), instead of comparing strings.project_rootthat points to a sibling directory with the same prefix, such asroot-evil. It should assert thatadd_projectraisesValueError, and it should fail before the fix.pragma: no coveronce the test covers the branch, because the repo requires 100% coverage.Per triage scope, I haven't made any code changes.