Files
NetMesh/docs/research/sftp-local-publish-safety.md
zhaolei 3c72efcb7f
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
[Init] Initial commit - NetMesh terminal manager
2026-09-13 18:24:01 +08:00

2.4 KiB

Local transfer publication safety audit

Confirmed defect

The completed download moves an existing destination to a backup, checks that its pathname is unoccupied, then renames the prepared download into place. Another program can save to that pathname between the check and rename. The rename overwrites those bytes and successful cleanup deletes the original backup. Backup restoration and post-publication rollback have equivalent races.

Real filesystem regressions inject concurrent creation at the actual final publication and restoration boundary. Both lose concurrent contents on the baseline. An explicitly absent destination can also appear after validation and be incorrectly moved aside. These tests fail before the change.

Contract and design

  • Prepared data and an original backup remain private sibling files.
  • Publication and backup restoration use the same no-overwrite primitive.
  • On hardlink-capable filesystems, linking publishes complete bytes atomically.
  • On filesystems without that operation, exclusive open plus writes through the owned handle preserves compatibility without overwriting another destination. This fallback exposes partial contents during copying; it does not promise atomic visibility. It never deletes the destination pathname on failure.
  • Failed fallback copies retain complete prepared data and original backup, with their locations in the error. A concurrent replacement is never removed.
  • Successful publication is the commit boundary. Cancellation checked before it restores the original where possible. Cancellation arriving after publication does not attempt unsafe pathname-based rollback.
  • A validated absent target is distinct from an omitted validation callback.
  • This change does not claim to prevent another program writing through an already-open handle or provide durable power-loss transactions.

Validation

The focused tests cover publication and restoration boundary races, absent validation, normal mode-preserving replacement, early/late cancellation, unsupported-hardlink fallback and write failure with concurrent replacement. Real unsupported-filesystem hardware has not been exercised; the fallback uses real files with hardlink capability failure injected.

Related audit themes: #3186 replacement attributes and #3213 interrupted recovery. These reports do not establish the cause of this separately reproduced defect.