Skip to content

[ENG-22031] Bump @openclaw/fs-safe 0.3.0 -> 0.8.5 (drop vulnerable nested tar) + owner-scoped lock migration, 2026.6.35-boon.4 - #327

Merged
william-antoline-boon merged 34 commits into
boonfrom
eng-22031-fs-safe-0.8.5
Nov 6, 2026
Merged

william-antoline-boon merged 34 commits into
boonfrom
eng-22031-fs-safe-0.8.5

Conversation

@william-antoline-boon

@william-antoline-boon william-antoline-boon commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Draft until the controller marks it ready. The fs-safe 0.8 behaviour-change follow-up, the boon merge (re-cut as 2026.6.35-boon.4), Step 7 and all review items are done; see "Follow-up" below.

Why

All 78 paid hosts carry a vulnerable nested tar 7.5.13 at openclaw/node_modules/@openclaw/fs-safe/node_modules/tar. @openclaw/[email protected] pins it as an exact optional dependency, and npm i -g ignores overrides, so the existing top-level tar 7.5.22 does not fix it. fs-safe 0.8.2+ drops tar entirely. This PR moves to 0.8.5 and cuts 2026.6.35-boon.4 (ENG-22031).

Any future upstream sync (e.g. #307 → v2026.7.35, which brings fs-safe 0.4.1 = tar 7.5.19, still vulnerable) must keep @openclaw/fs-safe ≥ 0.8.2.

We also tried fs-safe 0.5.6, the smallest version without the vulnerable tar (it pins tar 7.5.22). It was rejected: it breaks 32 test files with the same main causes, and adds a regression where npm-pack tarballs with PAX headers (paths over 100 characters) are refused. Tar would also stay a dependency.

Commits

  1. test(archive): pins npm-pack tarball extraction through extractArchive. It uses a system tar PAX .tgz with nested dirs and a 120-character name, and checks for identical bytes, mode 0644, no symlinks, and that ../escape.js is rejected. It passed on 0.3.0 first.
  2. test(locks): pins lock nesting on the real call paths. It passed on 0.3.0 first, and failed on 0.8.5 before the migration.
  3. fix(deps): the fs-safe bump plus the lock migration and API-drift fixes.
  4. chore(release): the boon.3 version bump (same 206 files as chore(release): bump version 2026.6.35-boon.1 -> 2026.6.35-boon.2 #308) and the CHANGELOG entry.
  5. fix(build): scripts/generate-npm-shrinkwrap.mjs scopes peer-suffixed forked deps (with a test), and the shrinkwraps are regenerated by the generator, not by hand.

Lock-ownership migration (the part to review)

fs-safe 0.5 removed the process-scoped allowReentrant option. Every fs-safe release with a fixed tar (≥ 0.5) lacks it, so this migration cannot be avoided. Its replacement is reentrantOwner: an acquisition can reuse a held lock only if it passes the same owner key.

This ports upstream openclaw#113705 ("scope lock reentrancy to logical owners", "preserve owner-scoped file lock nesting"):

  • acquireSessionWriteLock now takes reentrantOwner?: string and allowReentrant?: never, matching upstream's shape.
    • Every acquisition now carries an owner. When the caller omits one, it gets a fresh session-write-lock:<pid>:<uuid>.
    • That owner is recorded in the held entry's metadata. This is how nested writers can find and join it, while independent acquisitions still contend.
  • joinInProcessHolder: true is a new acquireSessionWriteLock option. Right before each acquire attempt, it looks up this process's current holder of that session lock.
    • If there is a holder, the writer joins its owner. If not, it takes a fresh owner and contends.
    • Possible holders are an agent attempt, compaction, transcript rewrite, or tool-result truncation.
    • An earlier revision exported precomputed owner resolvers; those are removed (f922043).
Former call site Was Owner key now
src/config/sessions/session-accessor.ts (transcript-turn batch, persistSessionTranscriptTurn) allowReentrant: true joinInProcessHolder: true: joins the in-process holder of that session lock, else a fresh owner
src/config/sessions/transcript-append.ts (withSessionTranscriptWriteLock, used by append message / event / transaction) allowReentrant: true joinInProcessHolder: true: same rule
src/plugin-sdk/file-lock.ts (acquireFileLock / withFileLock) allowReentrant: true options.reentrantOwner ?? "openclaw.plugin-sdk.file-lock:process:<pid>": a new optional field; omitted means one process-wide owner
src/agents/sandbox/registry.ts allowReentrant: false dropped (non-reentrant is the default)

Deliberate deviations from upstream

The review confirmed that both behave exactly as 0.3.0 did, so neither is a regression.

  • Transcript writers join any in-process holder, the same way 0.3.0's allowReentrant: true did.
    • Upstream mints a per-call owner for transcript appends. That works there because upstream sessions moved to SQLite.
    • In the fork, the agent attempt, compaction, rewrite and truncation hold the file lock via a returned handle. Appends that run inside them would otherwise wait for the whole operation and then fail as "session busy".
  • The plugin SDK file lock defaults to a process-wide owner. This keeps its documented re-entrant contract, so no plugin call site changes. Callers can pass a per-operation reentrantOwner to opt into stricter scoping, as documented in docs/plugins/sdk-migration.md and sdk-subpaths.md.

Other fs-safe 0.8.5 API drift, fixed at the call sites (no as any)

  • shouldReclaim / shouldRemoveStaleLock payloads are now typed unknown. They are narrowed with a record guard in plugin-sdk/file-lock.ts.
  • tempWorkspace().cleanup() now returns a receipt. The callers await it and discard the result: agents/cli-runner/helpers.ts and extensions/discord/src/send.voice.ts.
  • Archive tests were updated for 0.8.5's error shapes. Each one still asserts that the archive is rejected and that nothing lands outside the destination.

Lockfiles

  • pnpm-lock.yaml has no [email protected]. The only tar is 7.5.22, and @openclaw/[email protected] has no tar dependency.
  • In every npm-shrinkwrap.json, no tar is below 7.5.22 and there is no nested fs-safe tar (checked in review).
  • pnpm-workspace.yaml: the @openclaw/[email protected] exclusion from minimumReleaseAge is removed. 0.8.5 is older than the age gate.

Follow-up: fs-safe 0.8 behaviour changes, boon merge, review fixes

Version. boon already shipped 2026.6.35-boon.3 (#316). So origin/boon (7aac127) is merged in with a merge commit, and this release is re-cut as 2026.6.35-boon.4: the same 206 files and 469 strings, plus a CHANGELOG section that covers ENG-22031 and #318, #323, #324 and #326. The shrinkwraps are regenerated with the fixed generator (--all --check exits 0). Apart from the version strings, they match boon's hand-edited pins.

fs-safe 0.8 adaptations. Most of these are ported from upstream openclaw (v2026.9.4, which ships fs-safe 0.8.5), with the upstream commits cited in each commit message.

  • Private secret/store dirs (f91bb7b76db6, with a fork addition):
    • OpenClaw-owned dirs are tightened to 0700 through an O_NOFOLLOW descriptor before fs-safe's fail-closed mode check.
    • Symlinked or swapped dirs are never touched.
    • A drifted dir owned by another user is not chmodded. The write fails with an error that names the path, the owner and the fix.
    • fs-safe's check stays on.
  • Python mode: the retired Python mode is replaced with configureFsSafeNative({ mode: "off" }) (0d7fb8eb392f). This removes FS_SAFE_PYTHON_DEPRECATED from stderr.
  • Symlink contracts (58025dd33cea, 5295f2578e1b):
    • The workspaceOnly write tool refuses a final symlink again. fs-safe 0.8 would otherwise replace it.
    • Contained parent aliases keep working, as do symlinked skill/hook roots, config includes, control-ui assets and sandbox mounts. Workspace avatars keep working too (fork addition).
    • Escaping hops are still rejected.
  • Owned temp handoff (75bcd267f5e7): a failed media producer no longer leaves a partial temp file beside saved media.
  • file-transfer (f91bb7b76db6): symlink refusals report the canonical target again.
  • Tests aligned to stricter or descriptor-based fs-safe behaviour. No security assertion was relaxed.
    • The race tests now actually fire through realpathSync.native.
    • The ZIP entry-limit assertion is strict again: the earlier widening to also accept "invalid ZIP metadata" is reverted.
    • The hooks traversal test now also asserts that nothing was installed.
    • The Windows ACL tests add a fail-closed case.
    • Session-store fixtures moved out of the shared /tmp root.

Review items:

  • I1: Step 7 is done (evidence below).
  • M1: new joinInProcessHolder: true resolves the holder immediately before each acquire. The transcript writers use it, and a mutation-checked window test covers it.
  • M2: allowReentrant: true now throws a TypeError.
  • M3: each nested file-lock handle is released exactly once.
  • M4: FileLockOptions and acquireSessionWriteLock are not on the API baseline's documented entrypoints (file-lock and agent-harness-runtime are not in plugin-sdk-doc-metadata), so regenerating records nothing for them. Regenerating produces only the pre-existing boon drift (zod printing, line numbers), so the baseline was not committed.
  • M5: the CHANGELOG now names the generator-driven pin changes.

Step 7: global install, linux/arm64/glibc

npm pack (prepack: full build plus UI build) produced openclaw-2026.6.35-boon.4.tgz (18 MB, 8806 files). It was then installed with:

npm i -g --prefix <tmp> --os=linux --cpu=arm64 --libc=glibc --ignore-scripts <tgz>   # added 333 packages

Results:

  • find … -path '*node_modules/tar/package.json': only lib/node_modules/openclaw/node_modules/tar (7.5.22).
  • @openclaw/fs-safe is 0.8.5, and @openclaw/fs-safe-linux-arm64-gnu is 0.8.5 (fs-safe-native.node, package.json). No musl helper was installed, so libc already filters it and no shrinkwrap change is needed.
  • @openclaw/fs-safe/node_modules does not exist.
  • openclaw --version prints OpenClaw 2026.6.35-boon.4.

Review-bot feedback (cubic, 24 threads, all resolved at aabca6c0): 23 fixed and 1 declined with a reason.

  • Private-dir modes (50cdad8):
    • The mode checks compare the full 0o7777 bits, so setgid and sticky bits are no longer mistaken for 0700.
    • tightenPrivateDirRootSync throws its real fchmod error.
    • privateFileStore logs a failed root tighten as a warning and still opens the store. fs-safe 0.8.5 still writes the files at 0600.
  • Locks (f922043): the unused owner-resolver exports are removed. Transcript writers use joinInProcessHolder.
  • Media (05e0188): fs-safe path-mismatch, an identity-drift race, is now a retryable invalid-path error with the cause attached. It is not a path-not-allowed denial, and it has a test.
  • memory-host-sdk (8d09b20): not-file is no longer treated as "missing" globally. Only the non-directory-parent case in isAllowedAdditionalDirectoryPath counts as missing.
  • Tests (75bc1cf, d6d77cb, aabca6c):
    • the apply-patch mkdir rebind race actually fires;
    • platform mocks are restored;
    • leaked temp dirs are removed;
    • the json-files durable:false contract is asserted;
    • test titles and comments are tidied.
  • The targeted run is 29 files with 858 tests, all passing. pnpm tsgo and pnpm check pass.

Tests

  • pnpm check exits 0, and pnpm tsgo, tsgo:core:test and tsgo:extensions:test all exit 0.
  • Full suite not run: disk was below the 6 GB floor. Instead, every file is run individually through node scripts/test-projects.mjs: the 59 files that failed on the original 0.8.5 run, every test file this branch or fix(agents): classify a caller's external timeout abort during compaction-retry wait #326 touched, and the new tests. That is 71 files: 2,855 tests pass.
  • The only failures are in 10 of the 12 pre-existing boon baseline files, with the same tests failing as on boon:
    • event-projector, msteams actions, telegram dispatch, whatsapp media;
    • exec-host-gateway, mcp-http, backup-create, plugins/uninstall;
    • resolve-openclaw-ref, shared-image-artifact.
  • Two baseline files pass in this run: install-policy and the secrets fork-timeout case.

Secret-directory rollout notes

The canary uses umask 0002, so existing dirs sit at 0775. These are tightened to 0700 on their next private write:

  • agents/*/sessions
  • agents/*/agent
  • identity
  • commitments
  • tui
  • settings
  • discord
  • credentials/*

fs-safe 0.3.0 already did this on every private write, so the end state is unchanged. Root-owned backups* dirs are not private-store roots.

🤖 Generated with Claude Code

william-antoline-boon and others added 24 commits November 2, 2026 12:10
…cade

Adds a case that builds a real .tgz with the system tar (PAX format,
nested dirs, a 120-char file name), extracts it through extractArchive,
and asserts identical bytes, mode 0644, no symlinks and an exact file set,
plus a second tarball with a "../escape.js" member that must be rejected.

Passes on @openclaw/fs-safe 0.3.0; it guards the 0.8.5 bump (ENG-22031),
whose tar backend no longer depends on the npm `tar` package.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…igration

fs-safe 0.5 replaced the process-scoped `allowReentrant` lock option with
owner-scoped `reentrantOwner`. Pin today's behaviour on the real call paths
so the migration (ENG-22031) can be checked against it:

- transcript append / event / append transaction and the session-accessor
  transcript turn (persistSessionTranscriptTurn) complete while this process
  already holds the session write lock (compaction / rewrite shape), instead
  of timing out behind it;
- two independent session-lock holders on the same session still
  serialize (second waits for release, or times out);
- the plugin SDK file lock lets the same caller nest acquireFileLock and
  withFileLock on one file, keeping the sidecar until the final release.

All pass on @openclaw/fs-safe 0.3.0. Flipping the transcript writers to
non-reentrant makes the two nesting cases fail (verified).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… owner-scoped re-entry (ENG-22031)

fs-safe 0.3.0 pins an exact optional `tar: 7.5.13`, which npm global
installs nest under openclaw/node_modules/@openclaw/fs-safe (overrides do
not apply to `npm i -g`). fs-safe 0.8.2+ drops `tar` entirely; 0.8.5 ships
prebuilt native helpers (incl. linux-arm64-gnu) as optional deps.

Lock migration. fs-safe 0.5 removed the process-scoped `allowReentrant`
option in favour of owner-scoped `reentrantOwner` (only acquisitions with
the same owner share a held lock). Ported from upstream openclaw#113705
("scope lock reentrancy to logical owners", "preserve owner-scoped file
lock nesting"), adapted to the fork:

- acquireSessionWriteLock takes `reentrantOwner?: string` and
  `allowReentrant?: never`. Every acquisition now carries an owner (a fresh
  `session-write-lock:<pid>:<uuid>` when omitted) recorded in the held
  entry's metadata, so independent acquisitions still serialize.
- New resolveSessionTranscriptWriteLockOwner(sessionFile): the owner of the
  session lock this process currently holds for that file (agent attempt,
  compaction, transcript rewrite, tool-result truncation), else a fresh one.
  transcript-append (withSessionTranscriptWriteLock) and the session-accessor
  transcript-turn batch pass it, so a transcript write nested inside the
  holding operation joins its lock exactly as `allowReentrant: true` did.
- sandbox/registry: dropped `allowReentrant: false` (now the default).
- plugin-sdk/file-lock: new optional `FileLockOptions.reentrantOwner`;
  omitted means one process-wide owner, preserving the documented
  re-entrant contract for existing plugin callers (no call-site changes).

Other 0.8.5 API drift fixed at the call site: shouldReclaim /
shouldRemoveStaleLock payloads are `unknown` (narrowed, no casts), and
tempWorkspace().cleanup() returns a receipt (cli-runner helpers, discord
voice send). Archive tests updated for 0.8.5's error shapes (tar traversal
-> ArchiveSecurityError code "entry-path"; under-declared ZIP central
directory -> "invalid ZIP metadata"; hardlink race no longer truncates the
shared inode; preflight counts rejected entries), each still asserting the
rejection and that nothing lands outside the destination. Session-lock
stale-diagnostics tests now key on the fork's own diagnostics read (fs-safe
no longer reads sidecars via fs.readFile).

Root npm-shrinkwrap.json: fs-safe 0.8.5 + its 7 platform optional entries,
edited from pnpm-lock.yaml metadata because generate-npm-shrinkwrap.mjs
still fails on boon (pre-existing @sentry/node @opentelemetry 2.12.0
registry drift, see #311). No extension shrinkwrap references fs-safe.
pnpm-workspace: removed the [email protected] minimumReleaseAge exclusion.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cuts the fork release carrying the ENG-22031 fs-safe 0.8.5 bump (drops
the nested tar 7.5.13 from global installs) plus #311-#315 merged since
boon.2.

Bump root package.json/npm-shrinkwrap.json, all bundled plugin
manifests, and the version + openclaw peer floor in every extension
npm-shrinkwrap.json (same 206 files / 469 strings as #308). Add the
2026.6.35-boon.3 CHANGELOG.md section and the matrix plugin changelog
alignment entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…or; regenerate shrinkwraps

generate-npm-shrinkwrap.mjs derives scoped npm overrides from pnpm-lock
snapshots for packages locked at more than one version, but skipped every
edge whose spec carries pnpm's peer suffix (e.g.
"2.11.0(@opentelemetry/[email protected])"), because the suffix fails the exact
version check. @sentry/node's nested @opentelemetry/sdk-trace-base and
resources therefore got no override, npm floated them to 2.12.0 (absent
from pnpm-lock.yaml), and the npm shrinkwrap guard in `pnpm check` failed on
boon (the drift #309/#311 worked around by hand).

Strip the peer suffix before the exact-version check (extracted as
collectPnpmLockScopedVersionOverrides, unit-tested: RED returned {}, GREEN
returns the per-parent pins). Regenerated with
`node scripts/generate-npm-shrinkwrap.mjs --all`; `--all --check` passes.
Root shrinkwrap now comes from the generator (fs-safe 0.8.5 + platform
entries replace the hand edit); discord/tlon/amazon-bedrock(-mantle) pick up
pnpm-locked versions and registry `deprecated` metadata. No tar < 7.5.22,
no fs-safe 0.3.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
boon already released 2026.6.35-boon.3 (#316). Version conflicts resolved
by taking boon's side; this branch's release is re-cut as boon.4 next.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
boon already shipped 2026.6.35-boon.3 (#316), so the ENG-22031 fs-safe
0.8.5 release is re-cut as boon.4. Same 206 manifest/shrinkwrap files and
469 strings as #316. Shrinkwraps regenerated with the fixed generator
(--all, --check exits 0): apart from the version strings they match
boon's hand-edited pins for #317/#318/#323/#324. Adds the boon.4
CHANGELOG section (ENG-22031 plus #318, #323, #324, #326) and the matrix
plugin alignment entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… mode

fs-safe 0.5+ deprecates configureFsSafePython; calling it prints an
FS_SAFE_PYTHON_DEPRECATED warning to stderr on every process start, which
broke every CLI script test that asserts clean stderr. Port upstream's
replacement (openclaw 0d7fb8e, openclaw#113705, as shipped in v2026.9.4):
configureFsSafeNative({ mode: "off" }) unless any
(OPENCLAW_)FS_SAFE_(NATIVE|PYTHON)_MODE override is set, so fs-safe can
still migrate a legacy PYTHON_MODE=require. Same default as before: the
guarded JavaScript paths, no helper process or binding.

Applied to src/infra/fs-safe-defaults.ts and the memory-host-sdk fs facade,
with upstream's defaults test and the secure-file-operations docs.

Also ports upstream 2d06d46 ("restore missing extra-path reads"):
fs-safe 0.8 reports a non-directory parent as code "not-file", so a
missing memory file below a regular file was rejected as "path required"
instead of reading as empty. Symlinked parents still fail closed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…writes

fs-safe 0.3.0 chmod'ed the private root and every component to 0700 on
each secret/private-store write. fs-safe 0.8 only sets the mode on
directories it creates itself and throws "Private secret directory ... has
insecure permissions" for an existing directory at any other mode. Hosts
run with umask 0002, so directories created by earlier code paths sit at
0775 and every private write into them (session transcript rewrites,
models.json, commitments, device identity, auth stores) would throw.

Port upstream's adapter (openclaw f91bb7b, openclaw#138500, as shipped in
v2026.9.4): new src/infra/private-dir-mode.ts opens each directory
O_NOFOLLOW|O_DIRECTORY and fchmods the pinned descriptor, so symlinked or
swapped components are never mutated and stay fs-safe's to reject.
privateFileStore/privateFileStoreSync tighten their root at creation;
writePrivateSecretFileAtomic tightens root -> parent before delegating.

Fork addition: a drifted directory owned by another user is never chmod'ed.
On the secret-write path it now fails with a message naming the path,
owner, and fix instead of a raw EPERM; the store factory (which also serves
reads) leaves it for fs-safe's insecure-permissions error on write. The
check itself stays on: nothing here relaxes fs-safe's mode enforcement.

Tests: upstream's private-file-store tests and symlinked-root regression,
plus private-dir-mode tests for 0775 chains, missing components, and the
not-owned case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…alls

fs-safe 0.8 resolves path components with realpathSync.native and checks
child metadata with lstatSync. The symlink-rebind race helper and the
workspace EAGAIN injection still patched the async APIs, so the injected
races never fired: the remove/mkdir/apply-patch race tests asserted a
rejection that no longer happened, and the workspace retry test counted 0
attempts. Port upstream's helper and fixtures (openclaw 870195a,
openclaw#141165): withRealpathSymlinkRebindRace gains realpathApi: "native-sync",
and the race cases use it. With the race actually firing again fs-safe
rejects each operation and the out-of-root file/directory stays untouched,
so these security tests are exercised again rather than relaxed.

Also from upstream (v2026.9.4):
- workspace retry counts >= 2 lstat attempts (0.8 lstats the child more
  than once per successful open); the file must still load.
- apply-patch symlink update accepts fs-safe's "unsafe path" boundary-read
  message (58025dd, openclaw#119363); the patch is still rejected and the
  symlink target is still unchanged.
- resolveOpenedFileRealPathForHandle returns the canonical real path of the
  moved inside file (macOS reports /private/var for /var); compare against
  realpath(movedPath), still never the outside symlink target.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-safe 0.8

fs-safe 0.5.2+ rejects every symlink path component by default and
atomically replaces a final symlink on write. That broke documented
contracts (in-workspace directory aliases, symlinked skill/hook roots) and,
for the workspaceOnly write tool, silently turned "refuse to write through a
symlink" into "replace the symlink". Port upstream's fixes (openclaw
58025dd, openclaw#119363; 5295f25, openclaw#121508; as shipped in v2026.9.4):

- agent-tools workspaceOnly: reject writes whose final component is a
  symlink (restores the security contract), and canonicalize contained
  symlink parents for read/edit/access like the write path already did.
- boundary-file-read: openRootFileFollowingParents canonicalizes contained
  parent aliases; workspace bootstrap reads use it. Final symlinks and
  out-of-root escapes are still rejected by openRootFile.
- skills, hooks, config includes, control-ui, sandbox fs-bridge: pass
  rejectSymlinks: false so in-root symlink hops work; fs-safe still rejects
  any hop whose canonical target escapes the root.
- sandbox fs-bridge: map fs-safe's generic "not-file" to the
  operation-specific "Sandbox boundary checks failed; cannot <action>".

Fork addition with the same pattern: gateway avatar reads pass
rejectSymlinks: false so avatars symlinked inside the workspace keep
working; the existing test that an avatar symlink escaping the workspace is
refused still passes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fs-safe 0.8's writeSiblingTempFile only removes a sibling temp it has
pinned. When the producer callback throws first (an oversized media stream
hitting its byte cap), the partial ".<uuid>...tmp" it wrote is left in the
media directory, where 0.3.0 removed it.

Port upstream's owned-temp handoff (openclaw src/infra/owned-temp-file.ts
and the sibling-temp-file wrapper, 75bcd26, as shipped in v2026.9.4):
the producer writes into a private fs-safe temp workspace that is cleaned up
on failure and moved into place only after it succeeds, with directory
identity guards on both sides so a swapped parent is never deleted from.
The infra fs-safe-advanced re-export (and so plugin-sdk security-runtime)
now hands out the wrapper too.

Tests: upstream's owned-temp-file tests (fixture paths canonicalized for the
macOS /var -> /private/var tmpdir), plus a producer-failure cleanup case.
media store "rejects oversized streams before writing a final artifact"
passes again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…data

Port upstream's test alignment for fs-safe's untrusted-filename sanitizer
and descriptor handling (openclaw 58025dd, openclaw#119363, as shipped in
v2026.9.4). Each is a stricter or equivalent behaviour, accepted rather than
worked around:

- file-context / openresponses: fs-safe strips Windows-invalid characters
  (<>:"/\|?*) from untrusted filenames before XML-escaping, so injected
  markup never reaches the name attribute at all. Content escaping of
  </file> markers is unchanged and still asserted.
- media store: the same sanitizer drops Windows-invalid characters instead
  of turning them into "_".
- media-understanding: local attachment opens may add O_NONBLOCK (so a raced
  FIFO cannot pin a worker); O_RDONLY|O_NOFOLLOW is still required.
- json-files: non-durable writes still open pinned descriptors, so open-call
  counting no longer proxies fsync work; the write must still land.
- web-media: classify fs-safe's pre-open identity drift (path-mismatch) as
  "path-not-allowed" rather than a bad path, as upstream does.

Fork-only: the json-files "File changed during read" retry tests now inject
the identity change through fs.lstatSync, which fs-safe 0.8 uses for the
pre-open check; the retry, exhaustion and tryReadJson-null assertions are
unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fs-safe's replaceFileAtomic has always set the parent directory to dirMode
(0700) on each write. 0.3.0 did it with a best-effort chmod that followed
symlinks and ignored errors. 0.8 pins the parent with O_NOFOLLOW and fchmods
the descriptor, so it now fails when the parent is a symlink (macOS /tmp:
"Atomic replace parent must be a real directory") or is not owned by the
writer (root-owned sticky /tmp: EPERM fchmod).

Real session stores live in OpenClaw-owned directories, so production
writes are unaffected. Several tests, however, wrote stores straight into
/tmp or the OS temp root. Move those fixtures into private mkdtemp
directories, as upstream's tests do (v2026.9.4): directive-handling.model,
telegram bot / create-bot harness, telegram and slack approval-native, and
discord /think autocomplete. Assertions are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nk refusals

fs-safe 0.8 no longer attaches the canonical target to its symlink error,
so SYMLINK_REDIRECT refusals lost the canonicalPath the operator needs to
update allowWritePaths. Port upstream's resolver (openclaw f91bb7b,
openclaw#138500): use the error's canonical path when present, else realpath the
target (final-component symlink) or walk the existing ancestor (symlinked
parent of a missing leaf).

fs-safe also now reports a final symlink during path resolution, so with
the default followSymlinks=false it is refused as SYMLINK_REDIRECT instead
of SYMLINK_TARGET_DENIED. Port upstream's split test (9094e10,
openclaw#120082): the default case expects SYMLINK_REDIRECT plus the canonical
target, and a new followSymlinks=true case still expects
SYMLINK_TARGET_DENIED. Both assert the target file is untouched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fs-safe 0.8 writes WhatsApp creds through descriptors: an "wx" temp handle,
handle writes, fchmod/fsync on the handle, and a pinned O_NOFOLLOW parent
directory. The test helper faked path-based fs.writeFile/fs.open calls, so
it threw "unexpected fs.open call" and saw no writes, failing 5 tests
(QR socket, backup rotation, corrupted-backup guard, serialized saves,
atomic write).

Port upstream's helper (openclaw 6aee279, openclaw#119621): wrap real
fs.open handles and spy on their chmod/sync/close, and record the writes
made through them. The atomic-write test now runs against a real temp auth
dir and asserts more than before: temp file mode 0600 and flags "wx",
fchmod(0600) + fsync + close on the temp handle, a single rename from temp to
creds.json, parent pinned with O_RDONLY|O_DIRECTORY|O_NOFOLLOW|O_NONBLOCK,
final contents, creds.json 0600, and auth dir 0700. Per f91bb7b
(openclaw#138500), fs-safe 0.8 skips the parent chmod when it is already 0700.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…trict limits

fs-safe 0.8 preflights ZIP bytes (local records, central directory) before
JSZip parses anything. Fixtures that were placeholder text, or that held a
central directory with no local records, now fail as "invalid ZIP
metadata" / "failed while reading the downloaded archive" before reaching
the limit under test. Port upstream's fixtures (openclaw v2026.9.4:
zip-central-directory-fixture with valid local records and file/directory
entry types; 8f295f1 / 75bcd26):

- archive.test: the actual-central-directory entry-limit case asserts
  "archive entry count exceeds limit" exactly again. The earlier bump had
  widened it to also accept "invalid ZIP metadata"; that is reverted, so
  the limit check is pinned rather than relaxed.
- clawhub: the _meta.json size-limit case uses a real ZIP on disk (the
  oversized entry is still injected through the loadAsync mock), and the
  two entry-limit cases become upstream's file/directory it.each over a
  real 50,001-entry central directory. Each asserts JSZip is never invoked
  and nothing is installed.
- hooks install (eaa614a, openclaw#138870): tar/zip traversal must fail with
  an ArchiveSecurityError, and the test now also asserts that no hooks dir
  was created.
- json-file: fs-safe names sibling temps ".fs-safe-<uuid>.tmp"; assert a
  same-directory temp renamed onto the target, as upstream does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nk paths

fs-safe 0.8 writes atomic temps through file handles, removes its owned
temps with identity-checked unlink(), and reads through lstatSync and handle
reads. Four memory tests injected faults or stubs on the old path-based
calls, so the injected failure never fired. The production code is
unchanged and each assertion keeps its intent:

- short-term-promotion: the EFBIG mid-write is now also injected on handles
  opened for MEMORY.md.promotion*, as upstream does (v2026.9.4). MEMORY.md
  must still be byte-identical afterwards, with no promotion temp left.
- dreaming-narrative: the cleanup failure is injected on fs.unlink, so the
  "replace failed ... cleanup also failed" error must still surface.
- qmd-manager (fork-only; upstream removed qmd): write the exported session
  file for real instead of stubbing fs.lstat/readFile. The
  collection-scoped read must still return its content.
- active-memory: fs-safe renames a temp workspace aside before removing it,
  so assert that the temp transcript directory no longer exists after the
  hook, not the exact rm() argument.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tion

fs-safe 0.8 changed how inspectWindowsAcl stays locale-independent (openclaw#35834).
It no longer passes /sid to icacls. Instead it translates each principal
name to a SID through PowerShell (NTAccount -> SecurityIdentifier), and the
permission inspector first runs a PowerShell owner query. If any principal
cannot be verified, the inspection fails closed with ok:false. That is
stricter than 0.3.0, which trusted whatever names icacls printed.

The tests mocked only the icacls call, so every inspection now failed
closed, and the audit test's "no findings" cases passed only because the
ACL was "unknown". Update the mocks to the new contract instead of relaxing
anything:

- windows-acl: icacls is invoked as [path]; name-based listings get a
  PowerShell translation response, and the test asserts the resolved SIDs
  and the trusted classification. New case: an untranslatable principal
  must fail closed (ok:false, no entries).
- audit-filesystem-windows: answer the PowerShell owner query with
  upstream's fixture (v2026.9.4), so the world-writable (S-1-5-7) and
  BUILTIN\Users-readable findings are produced from a verified ACL again.

Windows-only; the paid fleet is Linux.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The signal tool-result harness wrote its session store to
/tmp/openclaw-signal-tool-result-sessions-<pid>.json. fs-safe 0.8 pins and
chmods the store's parent on atomic replace, which fails for a symlinked or
root-owned /tmp ("Atomic replace parent must be a real directory: /tmp").
The debounce flush therefore failed and no reply was sent. Move the store
into a private mkdtemp directory.

This is not a lock problem. The review asked us to rule that out, and the
failure output contains no SessionWriteLockTimeoutError or "session file
locked"; the only error is the /tmp atomic-replace refusal above.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…per attempt

Review M2: acquireSessionWriteLock typed allowReentrant as never, but JS
callers (compiled plugins) could still pass allowReentrant: true, and it was
silently dropped. Their nested acquire would then contend with its own
outer hold and fail with "session file locked" after the timeout. It now
throws a TypeError that names the replacements. allowReentrant: false
matches the default and is still accepted.

Review M1: transcript writers resolved the holder's owner before
acquireSessionWriteLock ran its own realpath/mkdir awaits. An operation that
took the lock inside that window was contended instead of joined, which
could stall a transcript write until its timeout. A new
joinInProcessHolder: true option looks the holder up synchronously right
before each SESSION_LOCKS.acquire call; transcript-append and the
session-accessor transcript turn use it. This shrinks the window back to the
size it had under fs-safe 0.3.0. Passing it together with reentrantOwner is
a TypeError.

Review M3: the plugin file-lock nesting test released the inner handle
twice. fs-safe's release is not idempotent per handle, so the second call
dropped the outer reference and the final ENOENT check could not catch a
broken outer release. Each handle is now released exactly once.

Tests (TDD): allowReentrant true/false; joinInProcessHolder joining via
symlinks, fresh-owner behaviour, mutual exclusion with reentrantOwner, and a
window test. The window test takes the lock during the joiner's mkdir. It
fails if the owner is precomputed (checked by mutation) and passes with the
late lookup.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r boon.4

Adds the ENG-22031 file-handling notes (private-dir tightening, native-mode
default, symlink contracts, media temp cleanup, atomic-replace parent
pinning, Windows ACL fail-closed) and the joinInProcessHolder /
allowReentrant TypeError lock changes. Review M5: the plugin line now names
the generator-driven shrinkwrap pin changes instead of claiming
version-only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Restructure the review-M3 fix so oxlint's no-useless-assignment is
satisfied: outer is released in finally, inner once in the body. The final
ENOENT check still proves that it is outer.release() that removes the lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fs-safe 0.8

fs-safe 0.8 reads secret files with a bounded FileHandle.read loop instead of
FileHandle.readFile, so the stall injected on readFile never fired and the
file-provider timeout test resolved the secret. Stub read instead, as upstream
does (openclaw v2026.9.4); the timeout assertion is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@william-antoline-boon william-antoline-boon changed the title [ENG-22031] Bump @openclaw/fs-safe 0.3.0 -> 0.8.5 (drop vulnerable nested tar) + owner-scoped lock migration, 2026.6.35-boon.3 [ENG-22031] Bump @openclaw/fs-safe 0.3.0 -> 0.8.5 (drop vulnerable nested tar) + owner-scoped lock migration, 2026.6.35-boon.4 Nov 5, 2026
@william-antoline-boon
william-antoline-boon marked this pull request as ready for review November 5, 2026 08:32
@william-antoline-boon
william-antoline-boon requested a review from a team November 5, 2026 08:32
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Dependency Guard

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • extensions/acpx/npm-shrinkwrap.json
  • extensions/acpx/package.json
  • extensions/admin-http-rpc/package.json
  • extensions/alibaba/package.json
  • extensions/amazon-bedrock-mantle/npm-shrinkwrap.json
  • extensions/amazon-bedrock-mantle/package.json
  • extensions/amazon-bedrock/npm-shrinkwrap.json
  • extensions/amazon-bedrock/package.json
  • extensions/anthropic-vertex/npm-shrinkwrap.json
  • extensions/anthropic-vertex/package.json
  • extensions/anthropic/package.json
  • extensions/arcee/npm-shrinkwrap.json
  • extensions/arcee/package.json
  • extensions/azure-speech/package.json
  • extensions/bonjour/package.json
  • extensions/boon-pdf-prep/package.json
  • extensions/brave/npm-shrinkwrap.json
  • extensions/brave/package.json
  • extensions/browser-handoff/package.json
  • extensions/browser/package.json
  • extensions/byteplus/package.json
  • extensions/canvas/package.json
  • extensions/cerebras/npm-shrinkwrap.json
  • extensions/cerebras/package.json
  • extensions/chutes/npm-shrinkwrap.json
  • 183 additional dependency-related files not shown

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfile, shrinkwrap, or workspace dependency policy changes are present.
  • Treat package-lock.json and npm-shrinkwrap.json diffs as security-review surfaces.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Dependency graph changes noted

This PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin or a member of @openclaw/openclaw-secops.

  • Current SHA: 61036890e6fd8047d87846e06d2d73c972345e63
  • Trusted actor: @william-antoline-boon
  • Trusted role: pull request author; repository admin

Security review is still recommended before merge when the dependency graph change is intentional.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 284 files

Note: This PR contains a large number of files. cubic selects up to 200 of the highest-priority eligible files for this review, so some files may not have been reviewed.
This PR changes concurrency-sensitive code such as locks, queues, or retries. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread src/infra/fs-safe-defaults.test.ts Resolved
Comment thread src/media/web-media.ts Resolved
Comment thread extensions/whatsapp/src/session.test.ts Resolved
Comment thread src/infra/private-dir-mode.ts Resolved
Comment thread src/agents/session-write-lock.ts Resolved
Comment thread src/infra/private-dir-mode.ts Resolved
william-antoline-boon and others added 7 commits November 5, 2026 15:46
Compare all 0o7777 permission bits so a setgid/sticky 0700 directory is
tightened (fs-safe compares them too). tightenPrivateDirRootSync now only
ignores open/close failures; a failed fchmod on an owned root throws, and
privateFileStore logs it with the real cause. Shorten the module comment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Holder is the path

resolveSessionTranscriptWriteLockOwner and resolveSessionWriteLockHolderOwner
had no production callers (transcript writers pass joinInProcessHolder: true),
and a precomputed holder owner is the racy pattern joinInProcessHolder avoids.
Remove them, keep the private held-owner lookup, and move their coverage onto
joinInProcessHolder tests. Clarify a test title, make the nesting suite
hermetic against the acquire-timeout env override, and use American spelling.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ot a denial

A path-mismatch from readLocalFileSafely is a transient swap race, not a
policy decision. Mapping it to path-not-allowed made the image and PDF tools
return a silent 'outside allowed directories' denial that skips Sentry.
Keep it an invalid-path error with a retry hint and the fs-safe cause, and
cover it with a web-media test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
fs-safe's not-file means an existing directory or special file, so treating
it as missing made memory reads and indexing silently skip real paths.
Handle the regular-file-parent case locally in
isAllowedAdditionalDirectoryPath, where assertNoSymlinkParents reports it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… fs-bridge comment

fs-safe 0.8 resolves the existing ancestor with realpathSync.native, so the
mkdir race test's async realpath spy never rebound the alias. Spy on the
native API, rebind on the parent re-check that precedes mkdir, and assert
the rebind happened. Narrow the fs-bridge rejectSymlinks comment: reads rely
on fs-safe's mount-root containment; only mutations re-check the canonical
container path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tions

- fs-safe-defaults: restore the process.platform spy after each test.
- json-files: assert durable:false (and the default) reach replaceFileAtomic
  as syncTempFile/syncParentDir instead of only checking the write lands.
- discord, slack, telegram, directive-handling: remove the private store
  temp dirs in afterAll.
- file-transfer: reuse canonicalPathFromFsSafeError; drop upstream commit
  and PR references from test comments (also archive-helpers).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 27 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread src/agents/session-write-lock.test.ts Resolved
Comment thread src/infra/private-dir-mode.ts Resolved
william-antoline-boon and others added 3 commits November 6, 2026 14:09
…ment the path-walk bound

Address review: the joinInProcessHolder stale-owner test now gives the
released holder a known owner and asserts that owner contends afterwards
(mutation-checked: reusing the last owner makes it fail). Restore the
note that ancestor tightening walks by path, so a same-user swap can
redirect a chmod while fs-safe still validates the final write.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nsion exceptions

Address check-guards warnings: src tests use test/helpers/temp-dir.ts
(makeTempDir / createTempDirTracker); extension tests, which cannot import
root test helpers, carry the repo's openclaw-temp-dir allow marker.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@boon-hermes-bot boon-hermes-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security & Code Review Summary

Verdict: Approved

Reviewed head commit 61036890e6fd8047d87846e06d2d73c972345e63.

1. Dependency & Manifest Verification

  • Bumped @openclaw/fs-safe from 0.3.0 to 0.8.5.
  • Successfully drops the vulnerable nested [email protected] pinned under @openclaw/[email protected].
  • Verified lockfiles (pnpm-lock.yaml) and all extension shrinkwraps: no tar below 7.5.22 remains anywhere in dependency trees.
  • pnpm-workspace.yaml: cleanly removed @openclaw/[email protected] from minimumReleaseAgeExclude (0.8.5 satisfies the release age gate).
  • Release cut as 2026.6.35-boon.4 in package.json, extension manifests, and CHANGELOG.md.

2. Registry & Integrity Vetting

  • Queried npm registry metadata for @openclaw/[email protected] and all 7 optional native platform packages (@openclaw/fs-safe-darwin-{arm64,x64}, @openclaw/fs-safe-linux-{arm64,x64}-{gnu,musl}, @openclaw/fs-safe-win32-x64-msvc).
  • Confirmed dist.tarball hosts (registry.npmjs.org) and verified SHA-512 integrity hashes match the pnpm-lock.yaml and shrinkwrap resolutions byte-for-byte.

3. Architecture & API Drift Adaptations

  • Lock-Ownership Migration:
    • Migrated from deprecated allowReentrant: boolean to reentrantOwner: string.
    • Added joinInProcessHolder: true option in acquireSessionWriteLock to allow transcript appends and session-accessor turns to dynamically join in-process holding operations before each acquire attempt, matching 0.3.0 nesting behavior without deadlocks.
    • Runtime validation: allowReentrant: true throws an explicit TypeError to catch legacy callers.
    • openclaw/plugin-sdk/file-lock: defaults to process-scoped owner preserving the documented SDK contract while allowing optional reentrantOwner.
  • Filesystem & Security Boundaries:
    • private-dir-mode: openclaw-owned private directories are tightened to 0700 through O_NOFOLLOW descriptors before private writes; foreign-owned directories fail closed with clear actionable error messages.
    • Symlink contracts: workspaceOnly write tools reject final symlink targets, while parent directory aliases, workspace avatars, and symlinked hooks/skills continue to work without allowing root escapes.
    • writeOwnedTempFile: ensures failed producers do not leave partial temp artifacts beside media.
    • web-media: handles transient path-mismatch as retryable invalid-path error.
    • generate-npm-shrinkwrap.mjs: properly strips peer suffixes on forked dependency specs.

4. Commit Signatures & CI Checks

  • All 30 commits on the branch are GPG-signed and cryptographically verified (verified: true).
  • All GitHub Actions check runs (including dependency-guard, security-sensitive-guard, check-dependencies, check-lint, check-prod-types, check-shrinkwrap, cubic · AI code reviewer, and test suites) have completed with success.
  • All cubic bot review threads are resolved.

@william-antoline-boon
william-antoline-boon merged commit a0e2078 into boon Nov 6, 2026
146 checks passed
@william-antoline-boon
william-antoline-boon deleted the eng-22031-fs-safe-0.8.5 branch November 6, 2026 09:05
orswn added a commit that referenced this pull request Nov 9, 2026
Cut the fork release for the PRs merged to boon after the
v2026.6.35-boon.4 tag:

- #328 (ENG-22237): replayed user turns keep the same bytes, so a new
  user message in Boon Web, Slack and MS Teams reads the previous
  prompt from cache instead of writing the whole history again.
- #280 (ENG-21157): opt-in model compat flag
  requiresGoogleThoughtSignatures, so Gemini 3 tool loops work behind
  an OpenAI-compatible proxy. No fleet model config sets it yet.
- #327: the v2026.6.35-boon.4 tag was cut from the PR branch. The
  review fixes that merged after it change tests and one comment only.

Bump the root package.json and npm-shrinkwrap.json, all 136 bundled
plugin manifests (scripts/sync-plugin-versions.ts), and the version and
openclaw peer floor in every extension npm-shrinkwrap.json
(scripts/generate-npm-shrinkwrap.mjs --all). The regeneration also
picks up the registry's updated deprecation text for @smithy/core
3.24.6 in amazon-bedrock, amazon-bedrock-mantle and tlon; no resolved
version or integrity changes. Add the 2026.6.35-boon.5 CHANGELOG.md
section. No source or dependency change beyond the merged PRs above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants