Repository navigation
fix(memory): reject reads outside a replaced authorized directory - #156222
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
CI test cost for this exact head: run 35823086271 passed. In checks-node-compact-small-10, all 15 reader cases passed. Their logged case durations total 155 ms, including 2 ms for each directory-substitution regression; this is aggregate case time, not standalone file wall time. The containing 271-file shard took 33.34 seconds in Vitest and 36.22 seconds wrapper wall time (5,180 passed, 1 skipped). The standalone local reader run remains the 59.985-second wall measurement recorded in the PR body; these measurements include different preparation and suite grouping, so no speed comparison is claimed. |
|
@clawsweeper re-review The earlier exact-head review completed successfully in workflow 35823200396, but publishing its result hit a GitHub rate limit. Its saved artifact was accepted into the publication queue and has remained unpublished for more than 40 minutes. The original result and queue receipt remain retained for reconciliation; this is one recovery request through the normal revision-fenced workflow. The head is unchanged at |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Codex review: blocked before merge. Reviewed September 23, 2026, 2:36 AM ET / 06:36 UTC. ClawSweeper reviewWhat this changesThe memory reader retains its authorized filesystem root through content reads and retries, preventing directory replacement from redirecting reads outside that root. Merge readiness⛔ Blocked before merge - 1 item remains This remains a useful, focused fix: current main and the latest release still separate path admission from content reading. No actionable correctness or security regression was found. Priority: P2 Review scores
Verification
How this fits togetherMemory Core sends memory_get requests and remote workspace reads through the shared memory reader. It checks workspace and configured extra-path permissions, reads the permitted file, and returns a bounded excerpt. flowchart TD
A[Memory read request] --> B[Workspace and extra-path rules]
B --> C[Retained filesystem root]
C --> D[Identity and containment checks]
D --> E[Content read and transient retry]
E --> D
E --> F[Bounded memory excerpt]
D --> G[Missing result or read error]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -29, Tests +149. Total +120 across 3 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep admission and content reading under one retained filesystem root while preserving existing memory-path and error contracts. Do we have a high-confidence way to reproduce the issue? Yes: replace an admitted workspace or extra directory before the content-read callback. Current main still performs a separate absolute-path read; the contributor reports before/after filesystem reproduction, while this review remained read-only. Is this the best way to solve the issue? Yes: using the existing fs-safe Root removes the admission/read split without introducing a competing containment implementation or changing public memory APIs. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b568ad2e87ae. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Maintainer disposition: the data-model classification is not applicable to this diff. It changes only file admission/read ownership, error handling, and reader tests. There are no schema, embedding metadata, serialization, write, migration, or retention changes, and no operator-state conversion is needed. Existing Markdown files and configured extra paths remain the input. Compatibility controls cover contained workspace aliases, strict extra roots, hardlinks, literal filenames, Markdown/glob restrictions, unlimited prior size behavior, and missing/transient/I/O-error results. The review itself confirms no stored-data contract changes and sufficient real-filesystem proof. The root-replacement regressions failed on the original implementation and passed on the candidate; the focused 40-case proof and exact-head CI passed. There are no accepted actionable review findings. |
…enclaw#156222) Related: openclaw#154370 ## What Problem This Solves Fixes memory reads returning contents outside an authorized directory when that directory is replaced between path admission and the actual read. ## User Impact Memory reads and transient retries stay bound to the admitted filesystem root. Existing contained workspace aliases, strict extra-directory rules, hardlinks, literal filenames, Markdown/glob restrictions, file-size behavior, and missing-file versus I/O-error results remain supported. ## Why This Change Was Made The memory reader now retains the existing fs-safe Root through the content read and retry, replacing separate path checks followed by an unrelated absolute-path read. This removes duplicate containment helpers without changing configuration, stored formats, or public memory APIs. The existing `memory_get` and remote-worker routes continue to call the same reader. ## Evidence - Two real directory-substitution cases returned outside contents on the original implementation and now refuse the substituted data. Existing compatibility controls also passed on the original source. - Final focused proof passed 40 cases in 73.022 seconds. The changed reader suite passed all 15 cases with `node scripts/run-vitest.mjs packages/memory-host-sdk/src/host/read-file.test.ts --maxWorkers=1 --reporter=verbose` in 59.985 seconds wall time. Cold preparation differs between runs; no speed comparison is claimed. - Coverage includes contained workspace aliases, rejected extra-root aliases, hardlinks, literal `~`, Markdown/glob admission, transient `EAGAIN` retries, propagated `EIO`, and missing/error distinctions. - All selected check components passed across the initial runs and targeted lint corrections, including core and all 25 test type graphs, dead exports, formatting, and the remaining guards. The final ten-command recovery run passed in 583.501 seconds; the original failing check command is not represented as a pass. - Earlier review findings about retry and I/O propagation were fixed. The final review's Markdown-widening claim was rejected after source inspection: `matchesDirectory` still requires `.md`, its directory branch requires that predicate, and the retained `note.txt` rejection case passes. Raw review findings were preserved; there are no accepted actionable findings. The final lint edit only omitted an identical default `void` type argument. - Proof used synthetic local files on macOS. No Windows or live-Gateway execution is claimed.
Related: #154370
What Problem This Solves
Fixes memory reads returning contents outside an authorized directory when that directory is replaced between path admission and the actual read.
User Impact
Memory reads and transient retries stay bound to the admitted filesystem root. Existing contained workspace aliases, strict extra-directory rules, hardlinks, literal filenames, Markdown/glob restrictions, file-size behavior, and missing-file versus I/O-error results remain supported.
Why This Change Was Made
The memory reader now retains the existing fs-safe Root through the content read and retry, replacing separate path checks followed by an unrelated absolute-path read. This removes duplicate containment helpers without changing configuration, stored formats, or public memory APIs. The existing
memory_getand remote-worker routes continue to call the same reader.Evidence
node scripts/run-vitest.mjs packages/memory-host-sdk/src/host/read-file.test.ts --maxWorkers=1 --reporter=verbosein 59.985 seconds wall time. Cold preparation differs between runs; no speed comparison is claimed.~, Markdown/glob admission, transientEAGAINretries, propagatedEIO, and missing/error distinctions.matchesDirectorystill requires.md, its directory branch requires that predicate, and the retainednote.txtrejection case passes. Raw review findings were preserved; there are no accepted actionable findings. The final lint edit only omitted an identical defaultvoidtype argument.