Skip to content

fix: SFTP overwrite data loss and Windows open_remote cmd injection - #27

Draft
cursor[bot] wants to merge 1 commit into
developfrom
cursor/critical-bug-management-5ba3
Draft

fix: SFTP overwrite data loss and Windows open_remote cmd injection#27
cursor[bot] wants to merge 1 commit into
developfrom
cursor/critical-bug-management-5ba3

Conversation

@cursor

@cursor cursor Bot commented Aug 9, 2026

Copy link
Copy Markdown

Summary

  • Recursive SFTP directory downloads no longer delete existing local files before the replacement transfer succeeds (failed/cancelled overwrite no longer causes silent local data loss).
  • Incomplete uploads now fail before promoting .termifai-uploading over the remote destination, so a truncated local source cannot wipe a good remote file.
  • sftp_open_remote first-success path on Windows now uses ShellExecuteW (not cmd /c start), and temp directory components from session_id are sanitized against cmd metacharacters.

Impact

  • Data loss: directory download overwrite + incomplete upload promote-before-check.
  • Security: residual Windows command injection via crafted synced host/session ids in the open-remote fast path.

Validation

  • cargo +1.88.0 test --locked -p termifai --lib sftp::tests:: — 22 passed (includes new should_promote_upload / sanitize_temp_path_component tests).

Test plan

  • Download a remote directory into a local tree with an existing nested file; choose overwrite; cancel/fail mid-transfer — existing local file remains.
  • Upload overwrite where the local file shrinks during transfer — remote destination stays intact; error reports incomplete upload.
  • On Windows, Open a remote file from an SFTP session whose host id contains & — opens via ShellExecute without spawning extra commands.
Open in Web View Automation 

Prevent recursive directory download from deleting local files before
the replacement transfer succeeds, and block incomplete uploads from
promoting temp files over the remote destination. Also route the
sftp_open_remote fast path through ShellExecute and sanitize session
ids in temp paths so crafted host ids cannot inject via cmd /c start.

Co-authored-by: Reza Moghaddam <r324.moghaddam@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant