Repository navigation
fix(atomic): bind directory modes to descriptors - #95
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 6:14 PM ET / 22:14 UTC. ClawSweeper reviewWhat this changesThe PR replaces pathname-based parent-directory mode changes during atomic file replacement with verified, no-follow directory descriptor operations on POSIX, while retaining bounded Windows behavior. Merge readiness⛔ Blocked until stronger real behavior proof is added - 6 items remain This PR pursues a valid security hardening, but its new synchronous injected-filesystem guard permits an adapter without Priority: P1 Review scores
Verification
How this fits togetherThe atomic write subsystem creates a sibling temporary file, applies security-relevant modes, and renames it into place. Its injectable filesystem adapters support tests and alternate implementations, so descriptor-mode handling must retain both filesystem safety guarantees and the public adapter contract. flowchart LR
A[Caller options] --> B[Atomic replacement]
B --> C[Create parent directory]
C --> D[Open verified parent descriptor]
D --> E[Apply directory mode]
E --> F[Write pinned temp file]
F --> G[Rename into destination]
G --> H[Published file]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The descriptor hardening is security-positive, but the synchronous injected-adapter guard introduces a concrete permission-boundary regression. Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Preserve the effective default parent-directory mode for synchronous injected adapters by failing before mutation when descriptor chmod is unavailable, or explicitly redesign and approve that adapter contract; add a regression that covers omitted Do we have a high-confidence way to reproduce the issue? Yes. On POSIX, inject a synchronous filesystem without Is this the best way to solve the issue? No. Descriptor-bound directory chmod is the right safety mechanism, but the synchronous capability guard must account for the effective default Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8926c3303c5b. LabelsLabel 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
|
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
dirModethrough verified, no-follow directory descriptors on POSIXchmod/chmodSynccalls from atomic replacementnode:fsinjection and reuse the existing optionalfchmodSyncsync capabilitymkdir(mode)behaviorSecurity impact
The previous pathname chmod could be redirected through a symlink when an attacker could rename entries in the destination directory's parent. That prerequisite is stronger than write access inside the destination directory and, on sticky directories, also depends on ownership or equivalent privilege. The caller must additionally have chmod authority over the unrelated symlink target.
The regression swaps the directory entry at the mode-application boundary with real syscalls under umask
0077. Onorigin/main, both async and sync paths leave the requested directory at0755and change the unrelated directory to0751. This branch leaves the unrelated directory at0755and applies0751to the opened real target.Windows does not enforce POSIX directory modes and Node cannot consistently open directory descriptors there. The implementation therefore keeps mode passing on
mkdirbut does not make a vulnerable pathname fallback.Verification
pnpm check(679 passed, 32 skipped)pnpm test:security(64 passed)git diff --check