Repository navigation
fix(windows): reject dangling writable leaves before creation - #823
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: needs maintainer review before merge. Reviewed October 1, 2026, 7:38 PM ET / 23:38 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR rejects dangling final symlinks before Windows fallback writable-file creation and adds regression tests, creation-contract documentation, and an Unreleased changelog entry. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix: neither current main nor v0.22.0 contains the pre-creation guard. No introduced correctness or security defect was found. Priority: P2 Review scores
Verification
How this fits togetherfs-safe gives Node.js applications filesystem roots for handling untrusted paths. Its writable-file admission path resolves destinations, opens or creates files, and verifies their identities before returning a handle or appending data. flowchart TD
A[Untrusted destination path] --> B[Root and parent checks]
B --> C[Open existing file]
C --> D{File missing?}
D -->|Yes| E[Reject observed final symlink]
E --> F[Create file]
D -->|No| G[Verify descriptor and path identity]
F --> G
G --> H[Return handle or append data]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Keep the shared pre-creation rejection while preserving ordinary creation, existing contained-link behavior, and the documented best-effort fallback boundary. Do we have a high-confidence way to reproduce the issue? Yes: an unchanged dangling file symlink reaches fallback creation in auto/off modes before descriptor rejection; the PR supplies a focused regression and reports real Windows before/after results. This read-only review did not execute that reproduction. Is this the best way to solve the issue? Yes: reusing the final-component rejection helper directly before creation is a narrow repair that preserves existing successful paths and avoids claiming atomic confinement. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e074abeeae2f. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Verified on the exact head Minimal Windows repro, using a fresh directory configureFsSafeNative({ mode: "auto" });
await fs.symlink("missing", path.join(dir, "leaf"), "file");
await (await root(dir)).openWritable("leaf"); // rejects with "symlink"Before the fix, Codex autoreview is clean through P2. An earlier head had an Intel macOS Bun child-process startup timeout; its one exact-job retry was superseded when main advanced and the branch was updated. Exact-head all-OS CI and CodeQL passed before the SHA-pinned squash merge. No release, tag, or publication. |
Add bounded transition checks for small pending-hint budgets, missing descendants, case and Unicode aliases, undecodable names, exclusions, directory lifecycle, scope replacement and subscription isolation. Verify invalidation-only cache convergence and calibrate failure cleanup and four-pass polling bounds. Add seeded TypeScript reference properties, 65,536 Rust Pending operations, and sync/async atomic fault-injection coverage. Include the finite corpus in the nightly five-runner stress workflow. No new dependency or test-only restructuring. Validated with 500 poll and 500 event seeds on Linux, APFS macOS and NTFS Windows, focused properties and Rust checks on each OS, plus exact-head all-OS CI and CodeQL. Parent-close precedence and Windows dangling-leaf creation were fixed separately in #820 and #823.
Reject observed symlink leaves before portable Windows exclusive creation across standalone creators, Root create-only writes, lock records, exclusive copy publication, and internal stages. Preserve exclusive-create collisions, lock-denial provenance, and descriptor-bound cleanup. Extend #823 with outside-target regressions: existing Root admission already rejected escaping absolute, relative, UNC, and device targets. Real Windows proof reproduces the remaining in-Root creation cases and standalone outside-target cases, including source-content writes after actual cross-volume EXDEV. Preserve the documented best-effort boundary against concurrent replacement. Validation: real Windows AWS before/main/fixed matrices and focused suites; pnpm check; independent Codex review through P2; exact-head CI and CodeQL.
Windows Node opens can follow a dangling file symlink even with
O_CREAT | O_EXCL. With native modeautooroff,openWritable()andRoot.append()created the missing referent and then rejected the symlink during descriptor admission. An unchanged dangling link reproduces this; no race is needed.Check the final leaf immediately before fallback creation when
O_NOFOLLOWis unavailable. Preserve the missing referent and link, ordinary creation, and the existing contained-link behavior when mutation policy is omitted. Required native creation is unchanged; this preflight does not promise atomic confinement against concurrent replacement.Validation: the real Windows AWS regression fails on main's production code in all eight negative cases (
auto/off× replace/append/update/Root.append). With the fix, all ten regressions pass, plus eleven neighboring descriptor-identity tests; one POSIX-only case is skipped. TypeScript compilation passes. Codex autoreview is clean through P2. Includes an Unreleased Fixes entry and the creation-contract documentation. Exact-head all-OS CI and CodeQL are required before merge.