Repository navigation
fix(move): bind staging modes to descriptors - #94
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 6:27 PM ET / 22:27 UTC. ClawSweeper reviewWhat this changesThe branch applies copied-file modes through the open staging file descriptor and POSIX directory modes through a no-follow descriptor, adding deterministic staging-symlink-swap regressions for cross-device moves. Merge readiness⛔ Blocked until stronger real behavior proof is added - 4 items remain Keep this PR open for merge review: the descriptor-bound permission changes are a focused security repair with no source-level correctness finding, but the updated body still lacks inspectable after-fix runtime evidence. Likely related person: Priority: P2 Review scores
Verification
How this fits together
flowchart LR
Source[Source path] --> Stage[Temporary staging entry]
Stage --> Copy[Copy and verify source identity]
Copy --> Mode[Apply requested mode]
Mode --> Publish[Guarded rename]
Publish --> Destination[Published destination]
Attacker[Staging pathname swap] -. blocked by .-> Mode
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the descriptor-bound POSIX behavior and Windows no-pathname fallback only after a redacted real-filesystem proof visibly shows the swap, the unchanged victim mode, and the published entry's requested mode; preserve the established Windows policy rather than restoring an unsafe pathname chmod. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main applies modes to visible staging pathnames, and the branch's focused tests define a deterministic swap at that boundary. The submitted PR does not yet include inspectable output from that real filesystem run. Is this the best way to solve the issue? Yes, subject to proof: descriptor-bound chmod mirrors the current-main atomic-directory hardening and removes the unsafe pathname operation rather than adding a new API or fallback mode. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against eda9a61fcf7f. LabelsLabel justifications:
EvidenceWhat 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 (1 earlier review cycle)
|
18b0836 to
34f24b7
Compare
34f24b7 to
fae42b4
Compare
movePathWithCopyFallback() closed the staging descriptor and then applied the mode to the staging pathname, and applied staged directory modes by path. The staging names are randomized but visible to anyone who can list the writable target directory, so the entry could be replaced with a symlink before the chmod and the mode change redirected before publication. Regular files now keep the staging handle and use FileHandle.chmod(). POSIX directories use an O_RDONLY|O_DIRECTORY|O_NOFOLLOW handle. Windows performs no pathname fallback, since Node cannot portably open a directory descriptor there and POSIX modes are not enforced. No injectable filesystem member was added.
fae42b4 to
c7cd3cc
Compare
The 10-second bound added in #89 was too tight for the command fallback and fired on contended Windows runners, producing an intermittent permission-unverified failure on unrelated pull requests. That code means "we could not verify", which a consumer may reasonably treat as a security signal, so emitting it because a runner was busy is a false alarm with real consequences. Successful runs of the affected secure-read test measure 1.930s to 5.400s, and one Node 24 leg passed at 9.349s with roughly 651ms of margin. The contended failures on #94 and #95 landed at 10.130s and 10.173s, which is the old bound firing rather than a hang. Thirty seconds is over five times the slowest observed success and about three times the overloaded cutoff, while still terminating a genuinely wedged command rather than letting it hang indefinitely. The deadline stays per process, since each child is the independently wedgable unit and an overall budget would let several slow-but-successful commands compete for one allowance and reproduce the same false result. Fail-closed behavior is unchanged: a real failure or timeout still yields source "unknown", and secure reads still reject it as permission-unverified.
Summary
Proof
pnpm checkpnpm test:securitygit diff --checkThe regression demonstrates the old behavior redirecting the requested mode to an unrelated symlink target while leaving the published entry umask-clamped. With this patch, the same swap occurs once, the unrelated target remains unchanged, and the requested mode lands on the real published file or directory.