Repository navigation
fix(secure-file): verify read identities losslessly - #153
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 12:46 PM ET / 16:46 UTC. ClawSweeper reviewWhat this changesThe branch uses lossless bigint filesystem identities in secure, secret, and guarded root readers, with bounded fail-closed Windows re-inspection and regression coverage for replacement races. Regression provenancePossible regression — probable (reviewed change; reproduction). No predecessor PR is attributed. Merge readinessThis PR remains necessary: current main does not contain the bigint identity checks. The reviewed head has no actionable correctness finding and provides focused race coverage; it should remain open for maintainer merge once the remaining Windows checks finish. Priority: P2 Review scores
Verification
How this fits togetherThe package protects applications handling untrusted paths by pinning file descriptors and verifying that path aliases still identify the intended file. Secure and secret readers plus guarded root reads consume those checks before returning bytes or publishing a write. flowchart LR
A[Untrusted file path] --> B[Preview identity check]
B --> C[Open pinned descriptor]
C --> D[Bigint identity verification]
D --> E[Path and canonical target checks]
E --> F{Identity remains trusted?}
F -->|Yes| G[Return bytes or publish write]
F -->|No| H[Fail closed]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the exact-identity checks after final Windows validation, retaining the documented fail-closed response for identities that cannot be verified. Do we have a high-confidence way to reproduce the issue? Yes, at source level: the added regression deterministically swaps a parent directory while modelling bigint identities that round to the same numeric value, and asserts the reader rejects before reading replacement bytes. Is this the best way to solve the issue? Yes. A shared exact-identity helper with a bounded Windows-only re-inspection removes numeric rounding from the security decision while preserving numeric public receipts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2d8875c20da4. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
Secure and secret readers verify descriptor, pathname, and resolved-target identities with lossless bigint metadata while preserving public numeric
Statsreceipts. Definite mismatches reject immediately; unknown Windows identity components receive one bounded re-inspection that retains every known component. Persistent ambiguity fails closed, and permission options do not bypass identity checks.The follow-up in
af8804efixes the remaining guarded root-read path. The failed Node 22 Windows check in run 33185670061 accepted a parent-directory replacement. That reader still compared numeric inode values and used the general Windows unknown-identity compatibility rule. A deterministic real directory-swap regression reproduced the problem: distinct exact IDs with equal numeric representations returned replacement bytes under both symlink policies. The original CI did not record identity samples, so it cannot distinguish rounding from unknown metadata; the fix rejects both cases. The original real parent-swap test remains unchanged.Windows publication verification now owns its reopen path instead of borrowing the reader. A writer can compare the reopened descriptor against its independently retained exact identity, without reading bytes. Link, canonical-path, parent/root confinement, descriptor cleanup, and existing open-error handling remain enforced. Tests preserve the existing successful opaque-path writes and rejection cases, and add symlink/hardlink races during reopen. The general identity comparator and generic synchronous pinning contract remain unchanged. Documentation and the Unreleased changelog describe the boundary.
Validation:
git diff --checkpassed.auto,require, andoffmodes. Packed-tarball smoke verified the bundled binding, automatic fallback without the binding, and required-mode refusal without it.EISDIRtonot-filemapping and passed the native-enabled regression run.pnpm checkdiagnostic run, before the final error-mapping regression was added, reported 1,440 passed, 11 timeouts, 312 existing skips. All 11 timed-out cases passed an isolated rerun with their original limits. Another full attempt hit a different timeout in a test that passed the completed run. The local full gate is not claimed green. No test limits, security assertions, or existing skip conditions were relaxed.Fresh checks for
af8804epassed: CI, coverage, and CodeQL; benchmarks passed as well. The formerly failing Node 22 Windows job completed with 1,054 passed and 710 existing skips, including the unchanged parent-directory swap regression. No CI rerun was needed. The PR remains open and unmerged.