Repository navigation
fix(root): confine removal in require mode - #744
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 28, 2026, 9:52 AM ET / 13:52 UTC (Revision 9). ClawSweeper reviewWhat this changesRoot removal in required-native mode now deletes through retained parent handles, adds descriptor-based POSIX recursive traversal, and tests the new removal path. Merge readiness⛔ Blocked before merge - 8 items remain Current main and v0.21.1 still use pathname removal, so this security repair remains necessary. The branch has credible cross-platform runtime proof, but its required-mode upgrade contract needs maintainer approval and two prior review findings remain unresolved. Priority: P0 Review scores
Verification
How this fits togetherRoot accepts paths and mutation options from an application, checks them against its filesystem root, then removes files or directory trees. The selected native mode determines whether removal uses retained filesystem handles or guarded pathname operations. flowchart LR
A[Remove request] --> B[Native mode]
B --> C{Require mode?}
C -->|No| D[Guarded pathname removal]
C -->|Yes| E[Admitted root and parent]
E --> F[Policy and identity checks]
F --> G[Native deletion]
D --> H[Result or typed error]
G --> H
Decision needed
Why: These limits change existing required-mode behavior and define what security boundary consumers may rely on; code and finite race campaigns cannot approve that contract. Before merge
Findings
Agent review detailsSecurityNeeds attention: Retained parents prevent the reported redirect, but the POSIX leaf-check/unlink window still needs an approved, precise public guarantee. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the retained-parent deletion with an approved platform contract, precise POSIX leaf-limit documentation, and an Unreleased note for required-mode users. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main admits the parent and later dispatches pathname unlink or rmdir, exposing the reported swap interval. I did not execute a local current-main reproduction. Is this the best way to solve the issue? No, not yet merge-ready. Retained-parent native deletion addresses the reported redirect, but required-mode compatibility, initial-inspection diagnostics, and the release note still need resolution. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cf71fe80db39. LabelsLabel changes: No label changes. Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
59bb904 to
a4e2746
Compare
Required-mode Root removal previously checked parent names and then dispatched pathname unlink/rmdir, allowing a concurrent parent swap to redirect deletion before the post-check rejected it. Removal now retains the admitted parent, matches its identity to the original admission, and uses identity-checked unlinkat on POSIX or exact-handle FileDispositionInfoEx on Windows. Recursive POSIX removal enumerates through retained directory descriptors and preserves ordering, budgets, cancellation, authority checks, force semantics, and error context.
These hardened paths apply only to require. Default auto keeps its previous best-effort implementation and does not confine removal under hostile concurrency. Required recursive directories fail closed with helper-unavailable on Windows and Linux without openat2/RESOLVE_NO_XDEV; auto keeps its existing behavior. POSIX checks are not an expected-inode conditional unlink, and guarded platform admission retains its best-effort label. The operation/platform matrix and compatibility notes are in #752.
The final post-authority leaf observation remains intact, including explicit symlink-policy rejection. The routing probe preserves mode precedence and live environment changes without scanning irrelevant legacy interpreter-path diagnostics on the auto path. 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 native binary with A/A controls and interleaved runs: required remove 169.90 -> 290.24 us/call; recursive filesystem-order removal 18,856.70 -> 8,013.04 us/call. Auto remove 168.43 -> 169.56 us/call (+0.7%, within observed variation).
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.