Skip to content

fix(fs): adopt fs-safe 0.5.2 untrusted filename sanitization - #119363

Merged
steipete merged 11 commits into
mainfrom
claude/fs-safe-reserved-names-908b94
Aug 5, 2026
Merged

steipete merged 11 commits into
mainfrom
claude/fs-safe-reserved-names-908b94

Conversation

@steipete

@steipete steipete commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

@openclaw/fs-safe 0.5.2 (openclaw/fs-safe#83) moved untrusted-filename ownership fully into the package: sanitizeUntrustedFileName() now strips Windows-invalid characters (<>:"|?*, C1 controls) and underscore-suffixes Windows reserved basenames (CON -> CON_, aux.c -> aux_.c) while preserving case and extensions. OpenClaw was pinned to 0.5.0 and carried a deliberately weaker local fork of that function in src/infra/fs-safe-advanced.ts, so attachment, canvas, media-store, and browser-download filenames kept reserved names and Windows-invalid characters that break on Windows/SharePoint targets.

Why This Change Was Made

Adopt the canonical dependency implementation and delete the local fork. One sanitizer now owns untrusted filename handling for the Plugin SDK, media store, canvas documents, file-context rendering, and browser download capture. The bump also picks up fs-safe 0.5.1/0.5.2 hardening (linear-time sanitizers, typed remove() failure codes, pinned-descriptor atomic writes, identity-guarded lock cleanup, stricter symlink resolution), which required keeping OpenClaw's own contracts intact on top:

  • src/infra/fs-safe-advanced.ts: local sanitizeUntrustedFileName fork deleted; re-exported from @openclaw/fs-safe/advanced.
  • Workspace symlink contract preserved: fs-safe 0.5.2 rejects every symlink path component by default, which broke in-workspace directory aliases (bootstrap files, agent read/edit/apply-patch). New openRootFileFollowingParents in src/infra/boundary-file-read.ts canonicalizes contained symlink parents before the pinned open; final-symlink targets and out-of-root escapes stay rejected. Workspace write/read ops in src/agents/agent-tools.read.ts canonicalize the same way, and writes now explicitly reject a final-symlink target (fs-safe would otherwise atomically replace the link).
  • Operator symlink contracts preserved with explicit rejectSymlinks: false (canonical containment still enforced by fs-safe): config include files (src/config/includes.ts), control-ui assets (src/gateway/control-ui.ts), skill roots (src/skills/loading/local-loader.ts), hook roots (src/hooks/workspace.ts). Follow-up flagged to audit the remaining ~20 openRootFile* call sites (plugin loaders etc.) for the same silent-drop risk.
  • src/media/web-media.ts maps fs-safe path-mismatch (pre-open identity drift from symlink/hardlink races) to the product code path-not-allowed instead of the invalid-path fallthrough — a race denial is an access denial, not a malformed path.
  • src/infra/path-guards.ts stops trimming in normalizeWindowsPathPreservingCase, matching fs-safe's comparison variant, which now keeps surrounding whitespace (whitespace can disguise reserved device names).
  • pnpm-workspace.yaml minimumReleaseAgeExclude updated @openclaw/[email protected] -> @0.5.2 (existing own-package exclusion pattern); env-var budget tightened 515 -> 513 to match current main (ratchet-mandated); Plugin SDK API baseline regenerated (same export name/signature, new source identity).
  • Tests asserting old fs-safe internals updated (errno codes -> typed codes, fsync open-count proxy, lock-cleanup identity guard, sanitizer passthrough); new boundary test src/infra/fs-safe-advanced.test.ts guards the adopted filename contract.

User Impact

Untrusted filenames (chat attachments, browser downloads, canvas imports) are now portable to Windows/SharePoint: reserved device names get an underscore suffix and Windows-invalid characters are stripped. Workspace agents keep reading and writing through in-workspace directory symlinks (dotfile-style alias setups), while symlink escapes and symlinked write targets stay rejected. No config or API surface changes.

Evidence

Runtime proof transcript (current head)

$ node -e "...sanitizeUntrustedFileName probe (installed @openclaw/fs-safe 0.5.2)"
"CON" -> "CON_"
"nul.txt" -> "nul_.txt"
"aux.c" -> "aux_.c"
"re<po|rt?.pdf" -> "report.pdf"
"report.pdf" -> "report.pdf"

$ node -e "...openRootFileSync symlink containment probe (installed 0.5.2, rejectSymlinks:false)"
link-in.txt OK -> inside.txt
link-out.txt REJECTED reason=validation

$ node scripts/run-vitest.mjs src/agents/agent-tools.workspace-paths.test.ts src/agents/apply-patch.test.ts (current head)
      Tests  88 passed | 1 skipped (89)

$ node scripts/run-vitest.mjs src/gateway/config-reload.test.ts src/gateway/control-ui.http.test.ts src/infra/fs-safe-advanced.test.ts src/media (current head)
      Tests  193 passed (193)
      Tests  307 passed (307)
      Tests  379 passed (379)

$ ...apply-patch + workspace symlink tests, verbose (current head)
 ✓ |agents-core| src/agents/apply-patch.test.ts > applyPatch > refuses existing symlinks in both host modes without changing their targets 3ms
 ✓ |agents-core| src/agents/apply-patch.test.ts > applyPatch > rejects symlink escape attempts by default 2ms
 ✓ |agents-core| src/agents/apply-patch.test.ts > applyPatch > rejects broken final symlink targets outside cwd by default 1ms
 ✓ |agents-core| src/agents/apply-patch.test.ts > applyPatch > rejects hardlink alias escapes by default 2ms
 ✓ |agents-core| src/agents/apply-patch.test.ts > applyPatch > rejects symlinks within cwd by default 2ms
 ✓ |agents-core| src/agents/apply-patch.test.ts > applyPatch > updates files through contained directory aliases 16ms
 ✓ |agents-core| src/agents/apply-patch.test.ts > applyPatch > rejects delete path traversal via symlink directories by default 2ms
 ✓ |agents-core| src/agents/apply-patch.test.ts > applyPatch > allows deleting a symlink itself even if it points outside cwd 2ms
 ✓ |agents-core| src/agents/agent-tools.workspace-paths.test.ts > workspace path resolution > writes through in-workspace symlink parents when workspaceOnly is enabled 17ms
 ✓ |agents-core| src/agents/agent-tools.workspace-paths.test.ts > workspace path resolution > edits through in-workspace symlink parents when workspaceOnly is enabled 17ms
 ✓ |agents-core| src/agents/agent-tools.workspace-paths.test.ts > workspace path resolution > rejects writes through symlink parents that resolve outside the workspace 3ms
 ✓ |agents-core| src/agents/agent-tools.workspace-paths.test.ts > workspace path resolution > rejects writes to final symlinks when workspaceOnly is enabled 3ms
 ✓ |agents-core| src/agents/agent-tools.workspace-paths.test.ts > workspace path resolution > rejects symlink escapes inside resolved skill roots 2ms

ClawSweeper review responses

  • [P1] apply_patch mutations through contained aliases — fixed: mutations (write/create/remove/mkdirp) now canonicalize contained symlink parents like the read path (toCanonicalMutationRelative in src/agents/apply-patch-file-ops.ts), with regression updates files through contained directory aliases (green in the transcript above).
  • [P2] final-symlink rejection atomicity — consciously accepted tradeoff, not fixed: fs-safe 0.5.2 exposes no commit-time "write but refuse to replace a final symlink" primitive (RootWriteOptions carries only mkdir/mode/denyMutations/renameIdentity/overwrite). The lstat guard is a product-courtesy rejection; if the race is lost, fs-safe's pinned write atomically replaces the link in-root without following it — the link target is untouched and no out-of-root write can occur, so the security boundary is fs-safe's, not the guard's. Building a bespoke O_NOFOLLOW write path would bypass fs-safe's atomic machinery and add a parallel write path for a same-privilege in-workspace race with no boundary impact.
  • fs-safe source inspection — done directly: behavior verified against the local ~/Projects/fs-safe checkout at tag v0.5.2 (PRs Bug: .dmg download on clawdis.ai site doesn't work due to fixed /Users/steipete path #83 reserved names, Discord: add ignored channel/category filters #93 typed remove codes, WhatsApp messages batch/queue instead of sending immediately #113 identity-guarded cleanup, 0.5.2 symlink hardening) and against the published npm tarball bytes (probe in the transcript).

@steipete
steipete marked this pull request as ready for review August 4, 2026 22:31
@steipete
steipete requested a review from a team as a code owner August 4, 2026 22:31
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: onepassword 1Password plugin size: S maintainer Maintainer-authored PR labels Aug 4, 2026
@github-actions github-actions Bot added the dependencies-changed PR changes dependency-related files label Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Dependency Guard

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

Changed files:

  • extensions/onepassword/package.json
  • package.json
  • pnpm-lock.yaml
  • pnpm-workspace.yaml

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfiles or workspace dependency policy changes are present.
  • Treat pnpm-lock.yaml and package-lock.json diffs as dependency 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 Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

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: c51a70d125b05e121a71bbf44535e8e0fcb9c618
  • Trusted actor: @steipete
  • Trusted role: pull request author; openclaw-secops

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

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Aug 4, 2026
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime labels Aug 4, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Aug 4, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 4, 2026, 8:05 PM ET / August 5, 2026, 00:05 UTC.

ClawSweeper review

What this changes

This PR upgrades OpenClaw to fs-safe 0.5.2, adopts its untrusted-filename sanitizer, and adapts filesystem callers to its stricter symlink and race protections.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked until real behavior proof is added - 8 items remain

Keep open: the fs-safe upgrade has a useful canonicalization direction, but it leaves apply_patch unable to write through the contained directory aliases the PR says it preserves, and its final-symlink guard is racy.

Priority: P1
Reviewed head: bd6bfe3f68bd8b29a97d5691e77d9271905fe12c

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The central dependency upgrade is useful, but two actionable workspace-boundary defects and missing inspectable runtime proof make the PR unready.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body describes local runs but provides no inspectable after-fix artifact; add redacted current-head terminal output or a reproducible transcript covering reserved names, contained aliases, and rejected escapes/final links. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body describes local runs but provides no inspectable after-fix artifact; add redacted current-head terminal output or a reproducible transcript covering reserved names, contained aliases, and rejected escapes/final links. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 4 items apply_patch has asymmetric alias handling: The changed read canonicalizes parent aliases, but the subsequent mutation still passes the lexical relative path to Root.write; the update flow always reads and then writes.
final-symlink check is not commit-time safe: The new lstat occurs before a separate awaited write even though the branch documents that fs-safe atomically replaces final symlinks; an alias installed in that gap can be replaced instead of rejected.
branch provenance: The affected symlink adaptation was introduced by the branch commit titled “keep workspace symlink contract under fs-safe 0.5.2.”.
Findings 2 actionable findings [P1] Canonicalize apply_patch mutations through contained aliases
[P2] Make final-symlink rejection atomic
Security Needs attention Final-symlink validation races the write: A symlink created after lstat but before Root.write can be atomically replaced, defeating the stated reject-and-preserve contract.

How this fits together

OpenClaw filesystem boundaries turn agent, media, configuration, skill, hook, and UI paths into contained file operations. The upgraded fs-safe dependency sits below those features and decides whether a path may be read, written, or served.

flowchart LR
  A[Agent patch request] --> B[Workspace boundary]
  B --> C[Contained directory alias]
  C --> D[Safe read and mutation]
  D --> E[Updated workspace file]
  B --> F[Reject escape or final symlink]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body describes local runs but provides no inspectable after-fix artifact; add redacted current-head terminal output or a reproducible transcript covering reserved names, contained aliases, and rejected escapes/final links. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Canonicalize apply_patch mutations through contained aliases (P1) - This hunk canonicalizes parent aliases only for the read. The update flow then calls the unchanged lexical Root.write, so a contained alias/file can be read and still fail on write under fs-safe 0.5.2. Apply the same contained-parent policy to mutations and add an alias-update regression.
  • Make final-symlink rejection atomic (P2) - The lstat and Root.write are separate awaited operations. Because this branch states the new write atomically replaces a final symlink, a link installed after the check can be silently replaced rather than rejected. Use a commit-time nofollow/pinned primitive and add a rebind-race test.
  • Resolve security concern: Final-symlink validation races the write - A symlink created after lstat but before Root.write can be atomically replaced, defeating the stated reject-and-preserve contract.
  • Resolve merge risk (P1) - The exact upstream fs-safe 0.5.2 source/types could not be independently inspected because the checkout has no cached package copy and GitHub/registry DNS was unavailable.
  • Improve patch quality - Repair and test apply_patch mutations through contained directory aliases.
  • Improve patch quality - Replace the lstat-to-write final-link check with atomic protection and add a race regression.
  • Improve patch quality - Attach redacted after-fix terminal or runtime evidence; updating the PR body should trigger a fresh review.

Findings

  • [P1] Canonicalize apply_patch mutations through contained aliases — src/agents/apply-patch-file-ops.ts:110-114
  • [P2] Make final-symlink rejection atomic — src/agents/agent-tools.read.ts:1147-1152
  • [medium] Final-symlink validation races the write — src/agents/agent-tools.read.ts:1148
Agent review details

Security

Needs attention: The new final-symlink protection has a concrete TOCTOU gap that can replace a symlink at a filesystem security boundary.

PR surface

Source +47, Tests +40, Config 0, Generated 0, Other 0. Total +87 across 33 files.

View PR surface stats
Area Files Added Removed Net
Source 12 78 31 +47
Tests 15 73 33 +40
Docs 0 0 0 0
Config 3 3 3 0
Generated 1 2 2 0
Other 2 8 8 0
Total 33 164 77 +87

Review metrics

Metric Value Why it matters
Dependency upgrade 2 direct specifiers changed from 0.5.0 to 0.5.2 The package changes filesystem semantics used across core and the bundled 1Password plugin.
Production vs test delta production +91/-44, tests +73/-33 The production growth adapts filesystem safety policy, so complete sibling mutation coverage matters before merge.

Stored data model

Persistent data-model change detected: serialized state: src/infra/gateway-lock.test.ts, serialized state: src/plugin-sdk/session-write-lock-runtime.test.ts, unknown-data-model-change: src/plugin-sdk/session-write-lock-runtime.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Repair workspace alias mutations (recommended)
    Canonicalize contained parent aliases for every apply_patch mutation and cover an update through a directory alias without permitting escapes or final links.
  2. Use an atomic final-link primitive
    Move final-symlink rejection into an fs-safe primitive that validates the destination at commit time rather than relying on a pre-write lstat.
  3. Pause the dependency upgrade
    Keep fs-safe 0.5.0 until the new stricter symlink behavior has a complete and race-safe OpenClaw adaptation.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Repair the workspace-only apply_patch mutation path so contained directory-symlink parents are canonicalized for reads and mutations, while final symlinks and escapes remain rejected; add focused alias-update and final-link race regression coverage.

Technical review

Best possible solution:

Use one canonical, contained-parent mutation flow for all workspace-only apply_patch operations, make final-symlink rejection atomic at the write owner, retain escape rejection, and add race and alias-update regression coverage.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: update a file through a contained directory symlink; the changed apply_patch read accepts it, then the lexical Root.write path rejects it under the PR’s stated fs-safe default. A final symlink swapped between lstat and write also demonstrates the second race.

Is this the best way to solve the issue?

No: centralizing filename sanitization in fs-safe is the right direction, but the surrounding OpenClaw workspace mutation policy is incomplete and the final-link protection must be atomic.

Full review comments:

  • [P1] Canonicalize apply_patch mutations through contained aliases — src/agents/apply-patch-file-ops.ts:110-114
    This hunk canonicalizes parent aliases only for the read. The update flow then calls the unchanged lexical Root.write, so a contained alias/file can be read and still fail on write under fs-safe 0.5.2. Apply the same contained-parent policy to mutations and add an alias-update regression.
    Confidence: 0.96
  • [P2] Make final-symlink rejection atomic — src/agents/agent-tools.read.ts:1147-1152
    The lstat and Root.write are separate awaited operations. Because this branch states the new write atomically replaces a final symlink, a link installed after the check can be silently replaced rather than rejected. Use a commit-time nofollow/pinned primitive and add a rebind-race test.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 9ff9aac71a8b.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.

Label justifications:

  • P1: Existing workspace directory aliases can make the agent apply_patch workflow fail after the read phase.
  • merge-risk: 🚨 compatibility: The new default symlink policy changes behavior for existing workspace alias setups.
  • merge-risk: 🚨 security-boundary: A final-link check separated from the committing write can silently replace a newly installed symlink.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body describes local runs but provides no inspectable after-fix artifact; add redacted current-head terminal output or a reproducible transcript covering reserved names, contained aliases, and rejected escapes/final links. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [medium] Final-symlink validation races the write — src/agents/agent-tools.read.ts:1148
    A symlink created after lstat but before Root.write can be atomically replaced, defeating the stated reject-and-preserve contract.
    Confidence: 0.91

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/agents/apply-patch.test.ts.
  • [P1] node scripts/run-vitest.mjs src/agents/agent-tools.workspace-paths.test.ts.
  • [P1] git diff --check.

What I checked:

  • apply_patch has asymmetric alias handling: The changed read canonicalizes parent aliases, but the subsequent mutation still passes the lexical relative path to Root.write; the update flow always reads and then writes. (src/agents/apply-patch-file-ops.ts:110, bd6bfe3f68bd)
  • final-symlink check is not commit-time safe: The new lstat occurs before a separate awaited write even though the branch documents that fs-safe atomically replaces final symlinks; an alias installed in that gap can be replaced instead of rejected. (src/agents/agent-tools.read.ts:1148, bd6bfe3f68bd)
  • branch provenance: The affected symlink adaptation was introduced by the branch commit titled “keep workspace symlink contract under fs-safe 0.5.2.”. (src/agents/apply-patch-file-ops.ts:110, 3eb373d9d006)
  • dependency resolution: The PR consistently changes the root and 1Password direct dependency specifiers and lockfile from fs-safe 0.5.0 to 0.5.2; upstream package source was not locally cached and GitHub/registry DNS was unavailable for an independent source inspection. (package.json:1961, bd6bfe3f68bd)

Likely related people:

  • steipete: Authored the branch’s fs-safe and workspace-symlink adaptation. (role: recent area contributor; confidence: high; commits: 3eb373d9d006, bd6bfe3f68bd; files: src/agents/agent-tools.read.ts, src/agents/apply-patch-file-ops.ts, src/infra/boundary-file-read.ts)
  • Shakker: Current-main blame/history attributes the pre-upgrade workspace and sanitizer path to this contributor. (role: recent area contributor; confidence: medium; commits: 2929dde43e1b; files: src/agents/apply-patch-file-ops.ts, src/infra/fs-safe-advanced.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 5, 2026
@steipete
steipete merged commit 58025dd into main Aug 5, 2026
124 checks passed
@steipete
steipete deleted the claude/fs-safe-reserved-names-908b94 branch August 5, 2026 00:53
@steipete

steipete commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 5, 2026
…time

* origin/main:
  fix(ui): clear split-pane questions after answers and cancellations (#118787)
  fix(slack): authorize reaction and message reads before applying limits (#118736)
  fix(ci): isolate cache warmer configs (#119381)
  fix(slack): Fix bad escaping in slack tool commentary (#119373)
  feat(audit): add execution identity inspection (#117034)
  fix(fs): adopt fs-safe 0.5.2 untrusted filename sanitization (#119363)
  fix(ci): preserve release evidence across reruns (#119380)
  fix(telegram): keep commands responsive during Codex login
  perf(memory): defer session backfill runtime (#119372)
  fix(ci): isolate built TUI PTY fixture (#119339)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 5, 2026
…w#119363)

* fix(fs): adopt fs-safe 0.5.2 untrusted filename sanitization

* fix(media): classify pre-open identity drift as access denial

* chore(checks): refresh SDK baseline and env-var budget for fs-safe adoption

* test(media): compact sanitizer cases under max-lines

* fix(agents): keep workspace symlink contract under fs-safe 0.5.2

* fix(infra): align path normalization and atomic-write proofs with fs-safe 0.5.2

* fix(fs): keep operator symlink contracts on config, control-ui, skills, hooks

* fix(fs): restore sandbox and session-lock contracts under fs-safe 0.5.2

* test(claws): expect symlink diagnostic for tampered plan parents

* fix(agents): canonicalize apply-patch mutations through contained aliases

* test(agents): split alias-update regression into focused file

---------

Co-authored-by: Peter Steinberger <[email protected]>
william-antoline-boon added a commit to getboon/openclaw that referenced this pull request Nov 5, 2026
…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]>
william-antoline-boon added a commit to getboon/openclaw that referenced this pull request Nov 5, 2026
…-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]>
william-antoline-boon added a commit to getboon/openclaw that referenced this pull request Nov 5, 2026
…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]>
william-antoline-boon added a commit to getboon/openclaw that referenced this pull request Nov 6, 2026
…sted tar) + owner-scoped lock migration, 2026.6.35-boon.4 (#327)

* test(archive): pin npm-pack tarball extraction through the fs-safe facade

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]>

* test(locks): pin session/file lock nesting before the fs-safe 0.8.5 migration

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]>

* fix(deps): bump @openclaw/fs-safe 0.3.0 -> 0.8.5 and migrate locks to 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]>

* chore(release): bump version 2026.6.35-boon.2 -> 2026.6.35-boon.3

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]>

* fix(build): scope peer-suffixed forked deps in the shrinkwrap generator; 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]>

* chore(release): bump version 2026.6.35-boon.3 -> 2026.6.35-boon.4

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]>

* fix(fs-safe): default native helper off instead of the retired Python 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]>

* fix(secrets): tighten OpenClaw-owned private dirs before fs-safe 0.8 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]>

* test(fs): drive fault injection through fs-safe 0.8's sync metadata calls

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]>

* fix(fs): keep workspace, operator, and avatar symlink contracts on fs-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]>

* fix(media): never leave a failed producer's temp file beside media

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]>

* test(fs): accept fs-safe 0.8 filename sanitization and read-path metadata

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]>

* test(channels): keep session-store fixtures out of the shared temp root

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]>

* fix(file-transfer): report the canonical target for fs-safe 0.8 symlink 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]>

* test(whatsapp): observe real credential descriptors under fs-safe 0.8

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]>

* test(archive): real ZIP fixtures for fs-safe 0.8 preflight; restore strict 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]>

* test(memory): inject faults through fs-safe 0.8's descriptor and unlink 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]>

* test(security): follow fs-safe 0.8's fail-closed Windows ACL verification

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]>

* test(signal): keep the tool-result session store out of /tmp

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]>

* fix(locks): reject allowReentrant at runtime; resolve the join owner 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]>

* docs(changelog): record fs-safe 0.8 behaviour changes and lock API for 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]>

* test(file-lock): release each nested handle exactly once without a flag

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]>

* test(secrets): stall file-provider reads through FileHandle.read for 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]>

* fix(infra): compare full private-dir mode and surface failed tightens

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]>

* refactor(agents): drop unused transcript-owner helpers; joinInProcessHolder 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]>

* fix(media): report fs-safe path-mismatch as a retryable read error, not 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]>

* fix(memory-host-sdk): keep not-file out of isFileMissingError

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]>

* test(sandbox): make the apply-patch mkdir rebind race fire; scope the 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]>

* test: restore mocks, remove leaked temp dirs, assert durable fsync options

- 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]>

* test(infra): satisfy unbound-method lint in the platform-restore check

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

* test(locks): pin that a released holder's owner is never reused; document 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]>

* test: route new test temp dirs through the shared helper or mark extension 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]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui dependencies-changed PR changes dependency-related files docs Improvements or additions to documentation extensions: onepassword 1Password plugin gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant