Skip to content

Enforce destination containment for imports and local materialization #1908

Closed

Description

@phernandez

Problem

Follow-up from the reviewed CodeRabbit deep scan (K34 K41 K42). This ticket tracks one distinct fix; duplicate scan rows are consolidated here.

Reviewed evidence and scope

  • K34 (scan ID 68903da2-6e54-4b1a-bf7a-6b9d2e169d1f, review A, Medium): Importer writes use unvalidated destination/name paths and local FileService joining. Enforce final resolved project containment; group with K41/K42.
    Source at current baseline: src/basic_memory/importers/base.py:103.
  • K41 (scan ID 4662f14c-6f14-4529-a89a-d897c5692539, review D, Medium local): Same project-containment family as K34; existing symlink ancestors can redirect local accepted-note materialization. Preserve arbitrary local-root feature while enforcing chosen project boundary.
    Source at current baseline: src/basic_memory/index/note_content_materialization.py:551.
  • K42 (scan ID 38a0f9e8-fcfc-485f-868a-18f29b6f8696, review D, Medium local): Regular-file move sink differs from Markdown materialization; include in K34/K41 containment work and tests.
    Source at current baseline: src/basic_memory/index/note_content_materialization.py:558.

Fix and validation

  • Enforce destination containment for imports and local materialization.
  • 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.

Activity

  1. added
    security
    on Oct 28, 2026
  2. claude commented on Oct 28, 2026

    @claude
    Contributor

    Claude finished @phernandez's task in 18s —— View job


    Triage

    • Type: Bug (path-containment gap, security hardening). I applied the bug label.
    • Priority: Medium. The scan rates K34, K41 and K42 as Medium, local or tooling-only. The issue says it doesn't establish production exploitation, so I kept that scope. It sits above Low because it touches note-content write paths.
    • Component: Importers (importers/base.py), local FileService joining, and index/note_content_materialization.py (the Markdown sink and the regular-file move sink). It is not Cloud-specific.
    • Complexity: Medium. The fix needs one shared "resolved path must stay inside the project root, symlink ancestors included" check. That check has to cover importers, Markdown materialization and the regular-file move sink. Local projects can use arbitrary roots, so that feature must keep working and only the chosen project boundary is enforced. It also needs regression tests at the service or public boundary for each of the three sinks.

    Possibly related issues

    These are open and look like the same family, but they are not duplicates:

    I'd suggest coordinating the helper design across #1891, #1896 and #1908 so the same check isn't implemented three ways. The issue has enough detail, so I have no questions for the reporter.

    Triage only, as requested. I made no code changes.

  3. added
    bug
    on Oct 28, 2026
  4. added a commit that references this issue on Oct 29, 2026
    d68feae
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsecurity

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions