Skip to content

fix: use exact publication identities on Windows - #126

Merged
steipete merged 3 commits into
mainfrom
fix/windows-publication-identity-deps-20260810
Aug 10, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/windows-publication-identity-deps-20260810

Conversation

@steipete

@steipete steipete commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • compare exclusive-publication source, target, parent, and cleanup ownership with exact bigint filesystem identities
  • preserve the existing numeric Stats result and numeric failure-detail shape
  • refresh @types/node, eligible pnpm transitive locks, and compatible Rust manifest and lock entries

Why

Windows file indexes can exceed JavaScript's safe-integer range. Numeric ino values can therefore round two distinct files to the same value, allowing a replaced source pathname to pass the post-hardlink identity fence. The same ambiguity could affect target verification and rollback ownership.

The internal publication fences now use bigint stats throughout hardlink, copy, native-parent, rename, and cleanup paths. Public result and error payloads remain compatible.

Validation

  • pnpm check — 100 test files passed, 1,035 tests passed, 61 skipped
  • pnpm test:security — 70 tests passed
  • cargo test --workspace --locked — 18 tests passed
  • cargo clippy --workspace --locked -- -D warnings
  • pnpm audit --audit-level high — no known vulnerabilities
  • cargo audit --deny warnings — no advisories
  • Node 24 on Windows: pnpm exec vitest run test/publish-file-failure.test.ts — 6 passed, 7 platform skips
  • built-library integration call published and read a real hardlink successfully

@steipete
steipete requested a review from a team as a code owner August 10, 2026 06:45
@clawsweeper

clawsweeper Bot commented Aug 10, 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: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 10, 2026
@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 10, 2026, 2:48 AM ET / 06:48 UTC.

ClawSweeper review

What this changes

The PR moves exclusive-publication source, target, parent, and cleanup checks to bigint filesystem identities while retaining numeric public result and failure payloads, plus dependency refreshes.

Merge readiness

⛔ Blocked until real behavior proof is added - 5 items remain

Keep open: the PR improves several identity fences, but its optional expected-source identity check still compares unsafe numeric Windows identities and can accept a replaced source.

Priority: P1
Reviewed head: 86fc7735538fb00859a9718deb196d119970f4ab

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The intended hardening is focused, but a remaining P1 source-fence bypass and absent inspectable runtime proof make the PR not merge-ready.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The body lists Windows and built-library runs, but it contains no inspectable terminal output, redacted log, screenshot, recording, or linked artifact showing the after-fix behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The body lists Windows and built-library runs, but it contains no inspectable terminal output, redacted log, screenshot, recording, or linked artifact showing the after-fix behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 4 items Unsafe expected-source fallback: The new branch deliberately uses numeric source stats whenever the caller supplies numeric expectedSourceIdentity fields, leaving the caller-provided source fence subject to the same rounding collision the PR fixes elsewhere.
Public numeric identity use: The existing failure test supplies expectedSourceIdentity from ordinary fs.stat(), which returns numeric Stats by default; this is a supported call shape rather than a bigint-only internal path.
Publication feature provenance: Current main attributes the exclusive-publication implementation to the v0.5.0 feature commit, and the latest release preparation also touched this surface; steipete is the established area contributor.
Findings 1 actionable finding [P1] Reject unsafe numeric expected source identities
Security Needs attention Numeric expected identity can still collide: The optional caller identity is compared against a numeric stat when its fields are numbers, permitting the same Windows precision collision the patch otherwise removes.

How this fits together

Exclusive publication pins a source, creates a no-clobber target through hardlink, copy, or rename, then verifies identities and cleans up safely on failure. These checks protect applications handling attacker-controlled filesystem paths.

flowchart LR
  A[Source pathname] --> B[Pin source file]
  B --> C[Exact identity fence]
  C --> D[Hardlink copy or rename]
  D --> E[Verify target and parent]
  E --> F[Publication result]
  E --> G[Safe rollback cleanup]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The body lists Windows and built-library runs, but it contains no inspectable terminal output, redacted log, screenshot, recording, or linked artifact showing the after-fix behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Reject unsafe numeric expected source identities (P1) - When callers pass ordinary numeric fs.stat() output, this branch compares it with numeric source.stat() instead of the bigint identity. On Windows, two distinct indexes above Number.MAX_SAFE_INTEGER can round to the same value, so a replacement source can still satisfy the optional source fence. Fail closed for unsafe numeric fields (or require bigint input) and add a rounding-collision regression.
  • Resolve security concern: Numeric expected identity can still collide - The optional caller identity is compared against a numeric stat when its fields are numbers, permitting the same Windows precision collision the patch otherwise removes.
  • Resolve merge risk (P1) - Merging still permits a numeric expectedSourceIdentity from a large Windows file index to match a different replacement source after both identities round to the same Number.
  • Complete next step (P2) - A narrow code-and-test repair can close the remaining numeric caller-identity bypass, while the contributor must separately provide real Windows proof.

Findings

  • [P1] Reject unsafe numeric expected source identities — src/publish-file.ts:321-327
  • [high] Numeric expected identity can still collide — src/publish-file.ts:321
Agent review details

Security

Needs attention: The diff substantially hardens publication checks but leaves one security-sensitive numeric source-identity comparison reachable through the public API.

Review metrics

Metric Value Why it matters
Production versus test delta production +63/-40, tests +0 The security-boundary rewrite has no focused regression covering the large-identity collision it targets.
Total patch surface 6 files, +271/-237 Most changed lines are dependency locks; the security-relevant implementation is confined to two source files.

Merge-risk options

Maintainer options:

  1. Fail closed for ambiguous caller identities (recommended)
    Reject unsafe numeric expected-source identities or require exact bigint values, add a rounding-collision regression, and provide redacted Windows after-fix proof before merge.

Technical review

Best possible solution:

Make the caller-provided source fence fail closed for unsafe numeric identities, compare only exact bigint identities when available, and preserve the existing numeric result and error-detail contract.

Do we have a high-confidence way to reproduce the issue?

Yes—source inspection provides a high-confidence reproduction shape: provide numeric expected identity from one Windows file index above the safe-integer limit, replace it with a distinct index that rounds identically, then publish; the branch selects numeric comparison at the caller fence.

Is this the best way to solve the issue?

No—the bigint conversion is appropriate, but retaining a numeric expected-source comparison leaves the reported ambiguity at the public caller fence; reject ambiguous numeric inputs or require exact bigint identity there.

Full review comments:

  • [P1] Reject unsafe numeric expected source identities — src/publish-file.ts:321-327
    When callers pass ordinary numeric fs.stat() output, this branch compares it with numeric source.stat() instead of the bigint identity. On Windows, two distinct indexes above Number.MAX_SAFE_INTEGER can round to the same value, so a replacement source can still satisfy the optional source fence. Fail closed for unsafe numeric fields (or require bigint input) and add a rounding-collision regression.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8a7935972492.

Labels

Label changes:

  • add P1: The remaining flaw can allow a replaced source to pass a filesystem identity fence on affected Windows volumes.
  • add merge-risk: 🚨 security-boundary: This PR changes source-identity validation and rollback ownership in a path designed to resist filesystem replacement attacks.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The body lists Windows and built-library runs, but it contains no inspectable terminal output, redacted log, screenshot, recording, or linked artifact showing the after-fix behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P1: The remaining flaw can allow a replaced source to pass a filesystem identity fence on affected Windows volumes.
  • merge-risk: 🚨 security-boundary: This PR changes source-identity validation and rollback ownership in a path designed to resist filesystem replacement attacks.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The body lists Windows and built-library runs, but it contains no inspectable terminal output, redacted log, screenshot, recording, or linked artifact showing the after-fix behavior. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [high] Numeric expected identity can still collide — src/publish-file.ts:321
    The optional caller identity is compared against a numeric stat when its fields are numbers, permitting the same Windows precision collision the patch otherwise removes.
    Confidence: 0.98

Acceptance criteria:

  • [P1] pnpm test -- test/publish-file-failure.test.ts.
  • [P1] pnpm test -- test/stage1-primitives.test.ts.
  • [P1] pnpm check.
  • [P1] git diff --check.

What I checked:

  • Unsafe expected-source fallback: The new branch deliberately uses numeric source stats whenever the caller supplies numeric expectedSourceIdentity fields, leaving the caller-provided source fence subject to the same rounding collision the PR fixes elsewhere. (src/publish-file.ts:321, 283a980085dd)
  • Public numeric identity use: The existing failure test supplies expectedSourceIdentity from ordinary fs.stat(), which returns numeric Stats by default; this is a supported call shape rather than a bigint-only internal path. (test/publish-file-failure.test.ts:73, 8a7935972492)
  • Publication feature provenance: Current main attributes the exclusive-publication implementation to the v0.5.0 feature commit, and the latest release preparation also touched this surface; steipete is the established area contributor. (src/publish-file.ts:314, 12f5525b5fac)
  • Repository policy: Repository policy requires fail-closed identity handling and focused regression coverage for swap races and platform-specific fallbacks; this PR changes that security boundary without adding a regression test. (AGENTS.md:27)

Likely related people:

  • steipete: Current-main blame attributes the publication path to Peter Steinberger, and steipete authored both the original publication feature/release work and this PR. (role: publication API introducer and recent area contributor; confidence: high; commits: b1be2a119986, 12f5525b5fac, 283a980085dd; files: src/publish-file.ts, src/publish-file-failure.ts, test/publish-file-failure.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Fail closed for unsafe numeric expected-source identities and add a focused rounding-collision regression.
  • Attach a redacted Windows terminal transcript or artifact showing the after-fix publication path; updating the PR body should trigger fresh review.

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.

@steipete
steipete merged commit a260e42 into main Aug 10, 2026
26 checks passed
@steipete
steipete deleted the fix/windows-publication-identity-deps-20260810 branch August 10, 2026 06:58
steipete added a commit to openclaw/openclaw that referenced this pull request Aug 10, 2026
The @openclaw/fs-safe 0.5.4 bump in 5295f25 (#121508), carrying exact Windows publication identity checks from a260e42d7782 (openclaw/fs-safe#126), changed this mocked path to fail closed with the shipped publication-source identity message on Windows. Assert the complete platform-specific message without weakening target-cleanup coverage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 security-boundary 🚨 Merging this PR could weaken sandboxing, authorization, credentials, or sensitive data. P1 Urgent regression or broken agent/channel workflow affecting real users now. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant