Repository navigation
fix(root): confine mkdir and writable-open creation in require mode - #751
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, 10:13 AM ET / 14:13 UTC (Revision 7). ClawSweeper reviewWhat this changesThe branch routes required-mode Root directory and missing-file creation through retained native parent directories and identity-checked file handles, while keeping automatic mode on its existing creation path. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 10 items remain Current main still uses pathname-based creation, so this security fix remains useful. The latest head retains two require-mode compatibility breaks, lacks an Unreleased entry, and needs its security guidance coordinated with the open documentation PR. Priority: P0 Review scores
Verification
How this fits togetherRoot accepts caller-supplied paths and mutation options, checks them against a filesystem root and policy, then creates directories or opens files. Native require mode is intended to constrain the filesystem effects of those operations. flowchart LR
A[Caller path and options] --> B[Root mutation]
B --> C{Native mode}
C --> D[Retained parent directory]
C --> E[Guarded pathname path]
D --> F[Directory or file creation]
E --> F
F --> G[Verified result or error]
Decision needed
Why: Preserving those creation cases may require a different descriptor handoff, while a fail-closed change intentionally stops some existing require-mode workflows. Before merge
Findings
Agent review detailsSecurityNeeds attention: The native path adds confinement, but its require-mode guarantee needs the operation-specific security guidance in the open companion PR. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep creation confined to retained native parents in require mode, preserve existing-file opens, and publish an approved restrictive-permission upgrade contract with the companion security guidance. Do we have a high-confidence way to reproduce the issue? Yes. The current-head source shows helper admission before an existing-file open, and the added restrictive-mode test explicitly expects require-mode rejection; this read-only review did not execute either case locally. Is this the best way to solve the issue? No, not yet. Retained native creation addresses the confinement gap, but existing-file opens should remain independent of creation support and the restrictive-mode change needs an approved upgrade path. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 682fe7589aa3. 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 (6 earlier review cycles)
|
554460a to
dc878d0
Compare
Required-mode Root mkdir and writable-open creation previously retained pathname mutations. Creation now admits and retains native parent directories, creates missing children relative to them, and opens missing files exclusively without following the final component. FileHandle handoff must match the originally created inode, and append retains creation-parent ownership through settlement so a rejected handoff cannot authorize cleanup of a replacement.
The native creation syscall receives the requested mode, preserving umask and inherited ACL restrictions without a widening post-create chmod. Unsupported handoffs fail closed. Windows uses handle-relative creation and cleanup; private Windows mkdir retains its existing protected native creator. Adjacent POSIX mkdir/open steps are fused into one native call while policy and identity fences remain.
The hardened path applies only to require. Default auto retains its previous best-effort creation paths even when the addon is loaded. Mode selection is captured before asynchronous admission and uses a cheap probe with unchanged configuration precedence. Missing-addon consumer probes explicitly verify helper-unavailable rather than restoring a JavaScript fallback. Compatibility and platform details are in #752. 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: required mkdir 236.40 -> 1,015.35 us/call; append creation with a missing parent 616.55 -> 1,860.02 us/call. Auto mkdir 232.98 -> 233.39 us/call (+0.2%); auto append creation 550.42 -> 556.41 us/call (+1.1%), within the controls. A focused warmed auto openWritable A/A/B control measured 210.03 -> 209.30 us/call with no demonstrated slowdown.
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.