Skip to content

fix(root): confine overwrite move in require mode - #750

Merged
steipete merged 4 commits into
mainfrom
codex/require-harden-move-20260927
Sep 28, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/require-harden-move-20260927

Conversation

@steipete

@steipete steipete commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Required-native overwrite move previously dispatched Node pathname rename after parent checks. It now retains both parents, verifies the source against its admitted identity, performs descriptor-relative replacement rename on POSIX or handle-relative FileRenameInfoEx on Windows, then verifies the destination and parents. Original source/target route checks around authority callbacks and the existing no-clobber contract remain intact.

The hardened overwrite path applies only to require; default auto keeps its previous best-effort behavior. Missing required capability fails with helper-unavailable, and a configuration change during asynchronous admission cannot downgrade the captured requirement. POSIX rename is not an expected-inode conditional operation; guarded platforms retain their existing best-effort labels. See #752 for the matrix and compatibility notes.

The Windows directory-replacement test accepts the OS-supported result: successful replacement must preserve the source directory identity and contents, while a rejected replacement must leave the trees intact. No CHANGELOG changes are included.

Validation: current-head CI is green (38 passing checks, seven skips), including full checks and native lanes; focused tests, git diff --check, and independent Codex TOCTOU review through P2 passed. The combined final runtime completed 60 x 20-second strict campaigns per platform/configuration with zero outside/denied effects and complete supported-operation coverage: Linux openat2 1,012,000 calls; forced fallback 966,990; macOS 711,310; Windows 133,858. Recursive directories were explicitly tested fail-closed where unsupported. Append creation uses a unique basename per attempt. The final timing sweep uses recorded 0-8 ms hostile/restored intervals; earlier faster incomplete campaigns are retained and are not called passing.

Proof: Linux, macOS/Windows. Platform best-effort labels and namespace limitations remain as documented.

Paired Linux method benchmark, same binary with A/A controls and interleaving: required overwrite move 428.49 -> 559.18 us/call; auto overwrite move 427.94 -> 414.42 us/call, within observed variation. Required-mode admission cost is intentional; default auto retains its existing path.

Performance evidence: paired method run, warmed auto control. The proof-only follow-ups change the harness/workflow; production src/native bytes match the measured runtime.

@clawsweeper

clawsweeper Bot commented Sep 28, 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 P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. 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. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 28, 2026, 10:37 AM ET / 14:37 UTC (Revision 7).

ClawSweeper review

What this changes

Root.move uses retained parent handles and a native identity-checked replacement rename for overwrite moves in required-native mode, with platform and integration tests.

Merge readiness

⛔ Blocked before merge - 11 items remain

Keep open. Current main and the latest release still use a pathname rename for overwrite moves, so the security fix remains useful. The proposed required-mode contract needs maintainer approval because it can change existing move outcomes, and the final POSIX source-reassignment interval remains unproven.

Priority: P0
Reviewed head: d80a51328870061e2d28fed70e1edbcff8730228
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Substantial native implementation and real-path campaign evidence remain limited by the final-effect proof gap and unresolved upgrade behavior.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Authority-chain proof required: Linked successful Linux, macOS, and Windows jobs exercised public required-mode Root.move overwrite with a real native binding and checked outside and denied effects. The inspected attacker harness does not force a different source between POSIX statat and renameat, so rejection before destination I/O remains unproved. Job logs and artifacts were blocked by the reviewer network proxy, which is an inspection limitation rather than evidence of a missing run. Supply a redacted allowed-move and late-reassignment final-effect trace; redact private paths, endpoints, and credentials. Updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. No stored-data contract changes. 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 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: Linked successful Linux, macOS, and Windows jobs exercised public required-mode Root.move overwrite with a real native binding and checked outside and denied effects. The inspected attacker harness does not force a different source between POSIX statat and renameat, so rejection before destination I/O remains unproved. Job logs and artifacts were blocked by the reviewer network proxy, which is an inspection limitation rather than evidence of a missing run. Supply a redacted allowed-move and late-reassignment final-effect trace; redact private paths, endpoints, and credentials. Updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. No stored-data contract changes. 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 13 items Current main still needs the fix: Current main routes no-clobber moves to native code but dispatches overwrite moves through Node's pathname rename after admission.
Release boundary: The latest identified release is v0.21.1, dated before this PR; the required-native overwrite route remains absent from current main.
Introduced dispatch and upgrade behavior: The introduced branch selects the new native method only for required-native overwrites and returns helper-unavailable when the loaded binding lacks it.
Findings 3 actionable findings [P1] Preserve a usable move outcome on rename-unstable mounts
[P1] Provide an upgrade path for older required-mode bindings
[P3] Record the required-mode behavior change under Unreleased
Security Needs attention Late source reassignment before POSIX overwrite: A peer able to replace the source basename after statat and before renameat may cause a different inode to replace the destination; the later identity check cannot reject before that effect. Establish the actual final-effect limit and obtain the required contract decision.

How this fits together

A Root handle accepts paths relative to an approved filesystem directory, applies mutation policy, and dispatches a move. The move path selects a native or Node rename and then reports the result to the caller.

flowchart LR
A[Relative move request] --> B[Root and mutation policy]
B --> C{Required native overwrite?}
C -->|Yes| D[Retained parent admission]
C -->|No| E[Existing move route]
D --> F[Native replacement rename]
E --> G[Caller result]
F --> G
Loading

Decision needed

Question Recommendation
Should required-native overwrite moves adopt this fail-closed behavior despite older-binding and FUSE failures and the remaining POSIX source-name race? Offer an explicit strict route: Preserve the existing default move outcome and expose retained-parent replacement through an approved strict setting with upgrade and final-effect proof.

Why: The choice changes a public safety and compatibility contract; the PR body describes the tradeoffs, but no recorded maintainer decision accepts them.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: Linked successful Linux, macOS, and Windows jobs exercised public required-mode Root.move overwrite with a real native binding and checked outside and denied effects. The inspected attacker harness does not force a different source between POSIX statat and renameat, so rejection before destination I/O remains unproved. Job logs and artifacts were blocked by the reviewer network proxy, which is an inspection limitation rather than evidence of a missing run. Supply a redacted allowed-move and late-reassignment final-effect trace; redact private paths, endpoints, and credentials. Updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. No stored-data contract changes. 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.
  • Preserve a usable move outcome on rename-unstable mounts (P1) - The added destination identity comparison runs after replacement. On the documented rclone-style FUSE behavior, rename changes the inode, so this can report path-mismatch after modifying the destination. Provide an approved compatible route or explicitly accept and document this strict result.
  • Provide an upgrade path for older required-mode bindings (P1) - The new capability check makes a required-mode overwrite fail with helper-unavailable when updated JavaScript loads an older binding, although current main attempts the move. Establish the mixed-installation contract and verify fresh and existing installations.
  • Record the required-mode behavior change under Unreleased (P3) - This changes a public Root operation's security and failure behavior, but the Unreleased section is empty. Add a concise user-facing note as required by the repository policy.
  • Resolve security concern: Late source reassignment before POSIX overwrite - A peer able to replace the source basename after statat and before renameat may cause a different inode to replace the destination; the later identity check cannot reject before that effect. Establish the actual final-effect limit and obtain the required contract decision.
  • Resolve merge risk (P1) - On POSIX, reassignment of the source basename between statat and renameat may move a different inode; the post-move check cannot prevent that final effect.
  • Resolve merge risk (P1) - An existing required-mode installation with an older or mismatched native binding will receive helper-unavailable for an overwrite move that current main attempts.
  • Resolve merge risk (P1) - On a rename-unstable FUSE mount, an overwrite may change the destination and then reject with path-mismatch.
  • Resolve merge risk (P1) - The reported paired Linux measurement increases required-mode overwrite latency from 428.49 to 559.18 microseconds per call; acceptance of that operator cost is not recorded.
  • Complete next step (P2) - Resolve the compatibility findings, add the Unreleased note, provide late-source final-effect proof, and obtain owner approval of the required-mode contract.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

  • [P1] Preserve a usable move outcome on rename-unstable mounts — src/root-move-noreplace.ts:226
  • [P1] Provide an upgrade path for older required-mode bindings — src/root-impl.ts:1421-1424
  • [P3] Record the required-mode behavior change under Unreleased — src/root-impl.ts:1421-1424
  • [medium] Late source reassignment before POSIX overwrite — native/src/unix.rs:390
Agent review details

Security

Needs attention: Retained parents improve confinement, but POSIX source identity is checked separately from the final replacement rename.

Review metrics

Metric Value Why it matters
Introduced lines production +128/-21; tests +195/-0 The production growth serves the stated confinement goal and carries focused tests, making its upgrade contract worth explicit review.
Required overwrite latency 428.49 to 559.18 µs/call The PR's paired Linux measurement shows a roughly 30.5% per-call increase for this route.

Merge-risk options

Maintainer options:

  1. Specify and prove a strict route (recommended)
    Add an approved compatibility path, test existing-binding and rename-unstable outcomes, and capture the late-source final effect.
  2. Accept the bounded tradeoff
    A maintainer can approve the failures and measured latency after the remaining security limit and upgrade instructions are explicit.
  3. Hold the native route
    Pause this branch if its required-mode guarantee cannot justify the compatibility and runtime cost.

Technical review

Best possible solution:

Define an approved strict overwrite contract that confines parent mutations, preserves a deliberate upgrade path for existing users, and states the POSIX source-name limit and performance cost in user-facing documentation.

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

No deterministic current-main race was run. Current source shows the pathname overwrite after parent admission, establishing the check-to-rename window.

Is this the best way to solve the issue?

No, not yet. Retained-parent renaming improves confinement, but the upgrade outcome and precise source-identity guarantee need an approved, tested contract.

Full review comments:

  • [P1] Preserve a usable move outcome on rename-unstable mounts — src/root-move-noreplace.ts:226
    The added destination identity comparison runs after replacement. On the documented rclone-style FUSE behavior, rename changes the inode, so this can report path-mismatch after modifying the destination. Provide an approved compatible route or explicitly accept and document this strict result.
    Confidence: 0.92
  • [P1] Provide an upgrade path for older required-mode bindings — src/root-impl.ts:1421-1424
    The new capability check makes a required-mode overwrite fail with helper-unavailable when updated JavaScript loads an older binding, although current main attempts the move. Establish the mixed-installation contract and verify fresh and existing installations.
    Confidence: 0.86
  • [P3] Record the required-mode behavior change under Unreleased — src/root-impl.ts:1421-1424
    This changes a public Root operation's security and failure behavior, but the Unreleased section is empty. Add a concise user-facing note as required by the repository policy.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.89

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P0: Current main's required-mode overwrite uses attacker-controlled pathnames at a filesystem confinement boundary.
  • merge-risk: 🚨 security-boundary: The new POSIX source identity check remains separate from the final overwrite, leaving late reassignment unresolved.
  • merge-risk: 🚨 compatibility: Older required-mode bindings can stop moving files, and rename-unstable mounts can report failure after replacement.
  • merge-risk: 🚨 other: The measured required-mode latency increase is an operator-visible cost that normal CI does not settle.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: Linked successful Linux, macOS, and Windows jobs exercised public required-mode Root.move overwrite with a real native binding and checked outside and denied effects. The inspected attacker harness does not force a different source between POSIX statat and renameat, so rejection before destination I/O remains unproved. Job logs and artifacts were blocked by the reviewer network proxy, which is an inspection limitation rather than evidence of a missing run. Supply a redacted allowed-move and late-reassignment final-effect trace; redact private paths, endpoints, and credentials. Updating the PR body should trigger re-review, or a maintainer can comment @clawsweeper re-review. No stored-data contract changes. 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] Late source reassignment before POSIX overwrite — native/src/unix.rs:390
    A peer able to replace the source basename after statat and before renameat may cause a different inode to replace the destination; the later identity check cannot reject before that effect. Establish the actual final-effect limit and obtain the required contract decision.
    Confidence: 0.9

What I checked:

  • Current main still needs the fix: Current main routes no-clobber moves to native code but dispatches overwrite moves through Node's pathname rename after admission. (src/root-impl.ts:1459, c4912a5d9a81)
  • Release boundary: The latest identified release is v0.21.1, dated before this PR; the required-native overwrite route remains absent from current main. (CHANGELOG.md:5, 305ff575ce13)
  • Introduced dispatch and upgrade behavior: The introduced branch selects the new native method only for required-native overwrites and returns helper-unavailable when the loaded binding lacks it. (src/root-impl.ts:1421, d80a51328870)
  • POSIX final-effect boundary: The new helper checks the source with statat and then calls renameat; its own comment says the rename is not conditional on the checked inode. (native/src/unix.rs:380, d80a51328870)
  • Post-effect verification: The new destination identity comparison occurs after the native rename, so a mismatch can be reported after a destination has changed. (src/root-move-noreplace.ts:226, d80a51328870)
  • Documented rename-unstable filesystem: The writing guide identifies rclone-style FUSE mounts where rename changes the destination inode; its content-based compatibility option applies to writes, while Root.move has no corresponding option. (docs/writing.md:662, d80a51328870)

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.

  • Capture the allowed overwrite and nearest late source-reassignment final effects through the real native path.
  • Settle and verify fresh-install and existing-installation behavior for older bindings and rename-unstable mounts.
  • Add an Unreleased note for the approved required-mode contract.

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 (6 earlier review cycles)
  • reviewed 2026-09-28T07:31:45.664Z sha ca4c81f :: needs real behavior proof before merge. :: [P3] Add an Unreleased note for the required-mode change
  • reviewed 2026-09-28T08:10:15.039Z sha ca4c81f :: needs real behavior proof before merge. :: [P1] Preserve successful moves on rename-unstable filesystems | [P2] Correct the Windows empty-directory replacement assertion | [P3] Add an Unreleased note for the required-mode change
  • reviewed 2026-09-28T08:29:37.962Z sha 4d51138 :: needs real behavior proof before merge. :: [P1] Preserve a compatible outcome for required-mode moves on FUSE | [P3] Add an Unreleased note for the required-mode change
  • reviewed 2026-09-28T11:08:57.547Z sha 7842167 :: needs real behavior proof before merge. :: [P1] Preserve a compatible outcome on rename-unstable FUSE mounts | [P1] Provide an upgrade path for older required-mode bindings | [P3] Add an Unreleased note for the required-mode change
  • reviewed 2026-09-28T13:15:23.309Z sha 7842167 :: needs real behavior proof before merge. :: [P1] Preserve a usable outcome on rename-unstable FUSE mounts | [P1] Provide an upgrade path for older required-mode bindings | [P3] Record the required-mode behavior change under Unreleased
  • reviewed 2026-09-28T13:21:39.346Z sha 7842167 :: needs real behavior proof before merge. :: [P1] Preserve a usable outcome on rename-unstable FUSE mounts | [P1] Provide an upgrade path for older required-mode bindings | [P3] Record the required-mode change under Unreleased

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 28, 2026
@steipete
steipete marked this pull request as ready for review September 28, 2026 13:10
@steipete
steipete requested a review from a team as a code owner September 28, 2026 13:10
@steipete
steipete force-pushed the codex/require-harden-move-20260927 branch from 7842167 to d80a513 Compare September 28, 2026 14:27
@steipete
steipete merged commit 2962033 into main Sep 28, 2026
47 checks passed
@steipete
steipete deleted the codex/require-harden-move-20260927 branch September 28, 2026 14:46
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. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant