Skip to content

fix(secure-file): verify read identities losslessly - #153

Merged
steipete merged 3 commits into
mainfrom
steipete/gifted-mendel-db6d8c
Aug 28, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/gifted-mendel-db6d8c

Conversation

@steipete

@steipete steipete commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Secure and secret readers verify descriptor, pathname, and resolved-target identities with lossless bigint metadata while preserving public numeric Stats receipts. 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 af8804e fixes 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:

  • Final native-enabled focused run: 384 passed, 5 existing skips, across 11 files covering native integration, root reads/writes, secure/secret identities, strict identity handling, and the original path-stress regressions.
  • Rust: 25 passed; Clippy passed with warnings denied. Release native build passed.
  • Build/typecheck, file-size lint, filesystem-boundary lint, documentation checks, package validation, and git diff --check passed.
  • Native smoke passed in auto, require, and off modes. Packed-tarball smoke verified the bundled binding, automatic fallback without the binding, and required-mode refusal without it.
  • Isolated Codex autoreview reported no blocking findings. A final compatibility guard preserves the previous EISDIR to not-file mapping and passed the native-enabled regression run.
  • The complete local pnpm check diagnostic 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 af8804e passed: 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.

@steipete
steipete requested a review from a team as a code owner August 28, 2026 07:48
@clawsweeper

clawsweeper Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 28, 2026
@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 12:46 PM ET / 16:46 UTC.

ClawSweeper review

What this changes

The 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 provenance

Possible regression — probable (reviewed change; reproduction). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This 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
Reviewed head: af8804e8786f3e2000235ea71adaa8126e5a7b79

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong focused regression evidence, documentation, and an implementation aligned with the package’s fail-closed filesystem contract support merge readiness.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body records an after-fix deterministic directory-swap regression and focused native-enabled validation across the affected reader and write paths.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body records an after-fix deterministic directory-swap regression and focused native-enabled validation across the affected reader and write paths.
Evidence reviewed 5 items Exact read identity implementation: The new helper retains known bigint device/inode components, retries only unknown Windows values once, and rejects mismatches or persistent ambiguity.
Guarded root reads use exact checks: The introduced root-read path captures bigint metadata before open, from the descriptor, pathname, and resolved target while retaining numeric Stats only for the public receipt.
Regression coverage: The added root-read test performs a real parent-directory swap while modelling bigint identities that collide when converted to Number, and asserts no replacement bytes are read.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Before merge

  • Resolve merge risk (P1) - On Windows installations that persistently report a zero device or inode, formerly readable secure, secret, or root paths will now fail with path-mismatch; this is an intentional documented fail-closed compatibility change.
  • Complete next step (P2) - No mechanical repair is indicated; maintainers should review the documented Windows compatibility tradeoff and final check results.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Implementation and regression coverage production +333/-291, tests +793/-45 The security-sensitive behavior change is accompanied by substantially more focused regression coverage than production growth.
Affected paths 26 files affected The change spans public docs, reader implementations, write verification, and focused cross-platform tests.

Merge-risk options

Maintainer options:

  1. Accept the documented fail-closed behavior (recommended)
    Merge with persistent unknown Windows identities continuing to return path-mismatch, which preserves the package’s filesystem safety boundary.
  2. Pause for a compatibility alternative
    Hold the PR only if maintainers want a separately designed and tested compatibility mode for opaque Windows identities.

Technical review

Best 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.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded correction to filesystem identity verification with limited but security-relevant user impact.
  • merge-risk: 🚨 compatibility: Persistent unknown Windows identity metadata now intentionally fails reads that older behavior could allow.
  • merge-risk: 🚨 security-boundary: The PR changes descriptor-to-path identity enforcement at a filesystem trust boundary.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body records an after-fix deterministic directory-swap regression and focused native-enabled validation across the affected reader and write paths.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body records an after-fix deterministic directory-swap regression and focused native-enabled validation across the affected reader and write paths.

Evidence

What I checked:

  • Exact read identity implementation: The new helper retains known bigint device/inode components, retries only unknown Windows values once, and rejects mismatches or persistent ambiguity. (src/strict-file-identity.ts:10, af8804e8786f)
  • Guarded root reads use exact checks: The introduced root-read path captures bigint metadata before open, from the descriptor, pathname, and resolved target while retaining numeric Stats only for the public receipt. (src/root-impl.ts:210, af8804e8786f)
  • Regression coverage: The added root-read test performs a real parent-directory swap while modelling bigint identities that collide when converted to Number, and asserts no replacement bytes are read. (test/root-read-identity.test.ts:18, af8804e8786f)
  • Current-main necessity: Fetched main contains only the later test-smoke commit beyond the PR base; its central reader paths have no diff from the base, so the fix is not already implemented there. (src/root-impl.ts:210, 2d8875c20da4)
  • Feature history: Recent history shows the same area evolving through retained-descriptor write verification and this follow-up exact root-read repair. (src/root-impl.ts:203, a5354d30cde9)

Likely related people:

  • steipete: Peter Steinberger authored the current-main retained-descriptor root work and the reviewed bigint root-read follow-up. (role: recent area contributor; confidence: high; commits: a5354d30cde9, af8804e8786f; files: src/root-impl.ts, src/root-write-verification.ts, src/strict-file-identity.ts)
  • Ayaan Zaidi: History attributes prior guarded-root FIFO race handling to this contributor. (role: adjacent race-hardening contributor; confidence: medium; commits: 99f917e55be4; files: src/root-impl.ts)
  • Josh Avant: History identifies prior Windows secure-reader ownership validation work in the affected secure-file surface. (role: secure-reader contributor; confidence: medium; commits: a7f366ed0874; files: src/secure-file.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-28T07:51:13.716Z sha a01ad88 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T15:36:44.900Z sha cad7200 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-28T15:46:47.607Z sha cad7200 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 28, 2026
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 28, 2026
@steipete
steipete merged commit ffd07ff into main Aug 28, 2026
29 checks passed
@steipete
steipete deleted the steipete/gifted-mendel-db6d8c branch August 28, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant