Skip to content

fix(security): make no-clobber root moves atomic - #357

Merged
steipete merged 4 commits into
mainfrom
codex/root-move-native-noreplace-20260914
Sep 16, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/root-move-native-noreplace-20260914

Conversation

@steipete

@steipete steipete commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Root moves without overwrite could race a separate destination check and replace a file created by another writer. This change uses native atomic no-replace rename, snapshots overwrite before admission, and rechecks deny rules against the canonical source and destination actually selected by native parent admission. Missing atomic support fails closed with the documented helper-unavailable result.

Native-off isolated producers retain a zero-copy hard-link handoff. Maintainer review found and fixed legacy Windows deletion behavior: the pin transfers to an already-verified sibling descriptor before source retirement, and a cleared read-only attribute is restored and verified through that descriptor. Identity, one-link publication, original callback receivers, cleanup ownership, and existing sync access requirements remain enforced.

The integrated JavaScript suites pass 80 tests (2 platform skips), all 88 Rust workspace tests pass, and fresh independent review through P2 is clean. Real Windows NTFS probes reproduced the original directory-cleanup and read-only-bit failures on Node 22.0.0 and proved the descriptor-transfer/restoration approach; current Node 24 controls also passed. The packed package passed real Windows NTFS tests on Node 22.0.0 and Node 24.11.1: identity, contents, mode, and cleanup were verified, with existing write-access failures preserved for read-only outputs requesting sync. A follow-up preserves the established Windows admission-error precedence when cleanup also fails; 23 focused tests pass and independent review is clean. Final head c6e02f3c47f5970cd3d5abbf8b9c3dd32a9ab944 passed the full CI matrix, including Windows native coverage of admission-error precedence, and was fast-forwarded onto main.

@steipete
steipete requested a review from a team as a code owner September 14, 2026 13:32
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. 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. labels Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 16, 2026, 5:32 AM ET / 09:32 UTC (Revision 6).

ClawSweeper review

What this changes

The branch makes no-clobber moves atomic, preserves isolated producer publication through identity-checked hard links, and strengthens temporary-workspace admission and cleanup.

Merge readiness

⛔ Blocked before merge - 3 items remain

This remains a useful security fix: current main still separates the destination check from a replacing rename. No blocking code defect was found. The previous workspace-authority proof hold is no longer applicable because that work merged separately.

Priority: P2
Reviewed head: c6e02f3c47f5970cd3d5abbf8b9c3dd32a9ab944

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A sound security repair with relevant real Windows evidence and focused regression coverage; the promised performance qualification remains unfinished.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The supplied Windows runtime trace exercises Root.move through the real addon and preserves both competing files; packed-package NTFS results cover producer identity, mode, and cleanup on Node 22.0.0 and 24.11.1. The latest error-precedence change has focused supplemental coverage. Workspace-authority proof is no longer a new merge requirement because that implementation already landed unchanged through the separate workspace PR.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The supplied Windows runtime trace exercises Root.move through the real addon and preserves both competing files; packed-package NTFS results cover producer identity, mode, and cleanup on Node 22.0.0 and 24.11.1. The latest error-precedence change has focused supplemental coverage. Workspace-authority proof is no longer a new merge requirement because that implementation already landed unchanged through the separate workspace PR.
Evidence reviewed 10 items Repository policy: Read the complete root AGENTS.md and CONTRIBUTING.md. No nested AGENTS.md or .agents/maintainer-notes directory was present. Applied filesystem-boundary, compatibility, and changelog guidance; did not run target code or autoreview helpers.
Central defect remains on main: Current main checks target absence, performs additional awaited admission, and then calls fs.rename. The branch instead dispatches no-clobber moves to the existing native atomic primitive.
Latest release still has the old move path: The v0.12.0 source also contains the absence check followed by fs.rename. Its resolved commit is 914cd7b; this PR's central fix is not already shipped there.
Findings None None.
Security None None.

How this fits together

fs-safe guards filesystem operations requested by Node.js applications. Root moves and isolated producer publication turn caller-supplied paths and completed output files into guarded filesystem mutations.

flowchart TD
  A[Caller paths or producer output] --> B[Root and parent admission]
  B --> C{Publication operation}
  C --> D[Native no-replace move]
  C --> E[Identity-pinned hard-link handoff]
  D --> F[Published file or collision rejection]
  E --> F
  F --> G[Identity verification and owned cleanup]
Loading

Before merge

  • Resolve merge risk (P1) - Existing default Root.move calls without usable native support will now reject with helper-unavailable; native-off isolated producers also require hard-link support. The discussion explicitly accepts these documented compatibility boundaries.
  • Resolve merge risk (P1) - Final performance qualification for the remaining move and Windows producer changes is still outstanding.
  • Complete next step (P2) - Post the promised final-head performance qualification for atomic moves and Windows producer publication against the agreed baseline.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
TypeScript production and test growth Production +2,287 lines; test directory +4,793 lines across the pinned introduction delta Growth supports explicit security guards and regression coverage, but includes workspace work already merged separately.
Remaining surface against current main 35 files, versus 59 in the pinned introduction delta The merged workspace changes no longer represent additional landing scope.

Merge-risk options

Maintainer options:

  1. Retain the documented support boundary (recommended)
    Honor the recorded acceptance of native-required moves and hard-link-dependent producer fallback while completing the promised performance qualification.

Technical review

Best possible solution:

Retain atomic no-clobber publication and the accepted native-required boundary, with identity-preserving producer compatibility and quantified performance costs.

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

Yes: current main exposes a target-creation window between its absence check and replacing rename. This review established the mechanism from source, without executing it.

Is this the best way to solve the issue?

Yes: using the existing atomic native primitive fixes the collision decision directly, while the guarded hard-link handoff preserves isolated producer behavior without restoring the unsafe rename fallback.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 59e85b8656ca.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The supplied Windows runtime trace exercises Root.move through the real addon and preserves both competing files; packed-package NTFS results cover producer identity, mode, and cleanup on Node 22.0.0 and 24.11.1. The latest error-precedence change has focused supplemental coverage. Workspace-authority proof is no longer a new merge requirement because that implementation already landed unchanged through the separate workspace PR.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The supplied Windows runtime trace exercises Root.move through the real addon and preserves both competing files; packed-package NTFS results cover producer identity, mode, and cleanup on Node 22.0.0 and 24.11.1. The latest error-precedence change has focused supplemental coverage. Workspace-authority proof is no longer a new merge requirement because that implementation already landed unchanged through the separate workspace PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.
  • remove merge-risk: 🚨 security-boundary: Current PR review merge-risk labels are merge-risk: 🚨 compatibility.

Label justifications:

  • P2: This fixes a concrete filesystem race without evidence of an active widespread outage or exploitation.
  • merge-risk: 🚨 compatibility: Previously working native-free no-clobber moves and producer publication on filesystems without hard links can now reject.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The supplied Windows runtime trace exercises Root.move through the real addon and preserves both competing files; packed-package NTFS results cover producer identity, mode, and cleanup on Node 22.0.0 and 24.11.1. The latest error-precedence change has focused supplemental coverage. Workspace-authority proof is no longer a new merge requirement because that implementation already landed unchanged through the separate workspace PR.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied Windows runtime trace exercises Root.move through the real addon and preserves both competing files; packed-package NTFS results cover producer identity, mode, and cleanup on Node 22.0.0 and 24.11.1. The latest error-precedence change has focused supplemental coverage. Workspace-authority proof is no longer a new merge requirement because that implementation already landed unchanged through the separate workspace PR.

Evidence

What I checked:

  • Repository policy: Read the complete root AGENTS.md and CONTRIBUTING.md. No nested AGENTS.md or .agents/maintainer-notes directory was present. Applied filesystem-boundary, compatibility, and changelog guidance; did not run target code or autoreview helpers. (AGENTS.md:1, c6e02f3c47f5)
  • Central defect remains on main: Current main checks target absence, performs additional awaited admission, and then calls fs.rename. The branch instead dispatches no-clobber moves to the existing native atomic primitive. (src/root-impl.ts:1493, c6e02f3c47f5)
  • Latest release still has the old move path: The v0.12.0 source also contains the absence check followed by fs.rename. Its resolved commit is 914cd7b; this PR's central fix is not already shipped there. (src/root-impl.ts, 914cd7b41388)
  • Workspace proof hold superseded by merged work: GitHub confirms fix(security): verify temp workspace creation roots #373 merged at 2026-09-16T09:25:28Z with merge SHA 59e85b8. Workspace admission, descriptor, permission, and cleanup implementation matches current main. Its earlier proof hold should not be carried forward as newly introduced authority in this PR. (src/temp-workspace-admission.ts, 59e85b8656ca)
  • Verified merge-result boundary: The raw test-merge parents are fetched main 59e85b8 followed by exact head c6e02f3. Its tree matches HEAD. This independently establishes the result against fetched main without treating the host's stale-base classification as introduction evidence. (4a2cdc60494c)
  • Real runtime evidence and accepted compatibility boundary: The supplied comment fix(security): make no-clobber root moves atomic #357 (comment) records real Windows addon collision rejection with source and competitor preserved, plus native-off hard-link publication preserving identity and a final single link. It explicitly accepts native-required no-clobber moves and hard-link-required fallback publication. The captured body additionally reports packed-package Windows NTFS validation on Node 22.0.0 and 24.11.1, including legacy deletion, read-only mode, cleanup, and retained sync-access failures. Captured context sourceRevision: d9804a541d2121165e617a3e087a819e435f7f0ebc0c72e32fa2f412d1941b07. (src/private-producer-handoff.ts:296, c6e02f3c47f5)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Complete the promised final-head performance comparison for no-clobber moves and ordinary/read-only Windows producer publication; exclude already-merged workspace work from this PR's remaining qualification.

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.

History

Review history (5 earlier review cycles)
  • reviewed 2026-09-14T13:38:16.172Z sha ef66845 :: needs real behavior proof before merge. :: [P1] [P1] Preserve native-off isolated-producer publication
  • reviewed 2026-09-14T20:45:22.542Z sha 1abdf36 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-14T20:51:35.904Z sha 1abdf36 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-14T20:56:19.964Z sha 1abdf36 :: blocked before merge. :: none
  • reviewed 2026-09-16T09:10:49.162Z sha 5fe53dd :: needs real behavior proof before merge. :: none

@steipete
steipete force-pushed the codex/root-move-native-noreplace-20260914 branch from ef66845 to 1abdf36 Compare September 14, 2026 20:40
@steipete

Copy link
Copy Markdown
Contributor Author

Exact-head runtime evidence for 1abdf368a16309999bc078919b058771f911171b on Windows x64:

Node 22.23.2
root-move-native-integration.test.ts
{"proof":"root-move-native-no-replace-race","competitor":"preserved","source":"preserved"}
1 passed

sibling-producer-isolation.test.ts
temp isolated sibling producer > publishes native-off output without copying or changing its identity
output isolated sibling producer > publishes native-off output without copying or changing its identity
2 passed

The native collision case loaded the real bundled addon through the production loader, used mode require, created the competitor after native parent admission, and observed typed already-exists with both source and competitor bytes intact. The isolated producer cases used mode off, real filesystem hard links, exact inode preservation, final nlink === 1, expected bytes, and no leftover sibling stage. The same native collision proof also passed on Node 26.8.2. The full GitHub Linux/macOS/Windows matrix is green.

Owner decision: accept the documented upgrade boundary. Public default no-clobber Root.move() is native-required; restoring a check-then-replacing-rename fallback is not acceptable. Native-off isolated producer publication requires hard-link support and fails explicitly on unsupported filesystems rather than copying or replacing a competing stage.

Final performance qualification is still pending and will be posted separately before merge.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 14, 2026
Admit temporary-workspace roots and children before use, preserve existing permissions, and bind mode initialization and cleanup to retained directory identities.
Keep real sidecar acquisition and draining outside the wrapper-construction timeout. Track setup and test completion so fixture removal cannot race timed-out filesystem work.
Make no-clobber Root moves atomic through native rename primitives and preserve identity-pinned isolated producer handoff, including legacy Windows delete-pending behavior.
@steipete
steipete force-pushed the codex/root-move-native-noreplace-20260914 branch from 1abdf36 to 5fe53dd Compare September 16, 2026 09:05
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient Contributor real behavior proof is sufficient. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 16, 2026
Keep boundary error codes and details primary when Windows descriptor disposal also fails. Retain combined-error behavior on POSIX and cover both root and parent admission with real closed-descriptor checks.
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. labels Sep 16, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 16, 2026
@steipete
steipete merged commit c6e02f3 into main Sep 16, 2026
37 of 38 checks passed
@vincentkoc
vincentkoc deleted the codex/root-move-native-noreplace-20260914 branch September 25, 2026 11:15

This branch was previously deployed

1 inactive deployment
github-pages — c6e02f3c Deployed Sep 16, 2026 by steipete via Deploy docs #264
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant