openclaw/packages
Peter Steinberger 6619a0e5eb
fix(memory): reject reads outside a replaced authorized directory (#156222)
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_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.
2026-09-23 07:36:09 -07:00
..
acp-core refactor: move type-only tests to compiler contracts (#154841) 2026-09-21 08:29:51 -07:00
agent-core refactor(tests): reuse single-turn agent loop streams (#156414) 2026-09-23 05:43:05 -07:00
ai test: require Anthropic pre-start rejection details (#156403) 2026-09-23 05:25:22 -07:00
gateway-client fix(ui): avoid duplicated replies after model fallback (#155336) 2026-09-22 02:13:45 +00:00
gateway-protocol fix: respect role model restrictions in model pickers (#154839) 2026-09-23 14:04:13 +01:00
llm-core improve(llm-core): avoid unnecessary tool validation sets (#152066) 2026-09-23 00:12:14 -07:00
markdown-core refactor: consolidate nested Markdown list tests (#155217) 2026-09-21 17:59:36 -07:00
media-core test(media): isolate base64 memory accounting per VM (#155638) 2026-09-22 13:07:01 -07:00
media-generation-core docs(packages): remove repetitive module captions (#141500) 2026-09-07 13:01:23 -07:00
media-understanding-common refactor(test): remove duplicate transcript formatting case (#150232) 2026-09-17 03:06:41 +08:00
memory-host-sdk fix(memory): reject reads outside a replaced authorized directory (#156222) 2026-09-23 07:36:09 -07:00
mermaid-renderer chore(deps): refresh dependencies with seven-day release cutoff (#152220) 2026-09-18 19:59:52 -07:00
model-catalog-core feat(catalog): define the model-first v2 feed contract (#156518) 2026-09-23 14:19:06 +00:00
net-policy refactor: use authored configuration metadata without field badges (#149162) 2026-09-16 11:46:41 -07:00
normalization-core refactor: remove unused normalization array helpers (#153233) 2026-09-19 17:55:55 -07:00
plugin-package-contract fix(release): publish frozen plugins with valid ClawHub categories (#144615) 2026-09-11 00:22:21 -07:00
plugin-sdk feat: read GitHub issues, pull requests, and commits beside chat (#148464) 2026-09-18 23:54:04 -07:00
retry fix(retry): honor waits beyond the native timer limit (#145718) 2026-09-13 14:29:02 +03:00
sdk fix: keep cold child compilation outside CI test deadlines (#156011) 2026-09-22 17:41:19 -07:00
session-url-contract fix: open Incognito sessions with their exact URLs (#154644) 2026-09-22 08:36:48 +00:00
terminal-core fix: keep cold child compilation outside CI test deadlines (#156011) 2026-09-22 17:41:19 -07:00
tool-call-repair improve: speed up streaming text with inline brackets (#154398) 2026-09-20 21:36:11 -07:00
workboard-contract refactor: check type contracts without runtime test startup (#155099) 2026-09-23 02:05:05 -07:00