Skip to content

[Bug]: SSH_FXP_RENAME overwrites existing file by default #2068

@jsroest

Description

@jsroest

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration issue.
  • This issue is not already reported on Github (I've searched it).

Bug description

If a file is renamed to a filename that already exists, the existing file is overwritten.

Steps to reproduce

  1. upload a file 250919081509_Scans.csv with contents "version1".
  2. upload a file 250919081509_Scans.tmp with contents "version2".
  3. rename 250919081509_Scans.tmp to 250919081509_Scans.csv (with no flags configured)
  4. observe that the contents of 250919081509_Scans.csv is now "version2".

Expected behavior

According the specifications, https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-13:

If flags does not include SSH_FXP_RENAME_OVERWRITE, and there already exists a file with the name specified by newpath, the server MUST respond with SSH_FX_FILE_ALREADY_EXISTS.

I've compared this behaviour with another SFTP server (https://www.rebex.net/tiny-sftp-server/, and that returns "SftpStatusError: Already exists. (code 4).

SFTPGo version

2.6.6 6825db7

Data provider

sqlite

Installation method

Other

Configuration

I've made no customisations ("rename_mode": 0)

Relevant log output

{"level":"info","time":"2025-09-19T08:17:47.236","sender":"Rename","local_addr":"192.168.1.100:2022","remote_addr":"192.168.1.166:59790","username":"aswh","file_path":"/Users/johannesroest/sftpgo/aswh/250919081509_Scans.tmp","target_path":"/Users/johannesroest/sftpgo/aswh/250919081509_Scans.csv","filemode":"","uid":-1,"gid":-1,"access_time":"","modification_time":"","size":-1,"elapsed":0,"ssh_command":"","connection_id":"SFTP_296927a2436c73a94a267088a2b11a51f57757749cd6eaaf46ab1f5487b1bedb_1","protocol":"SFTP"}

What are you using SFTPGo for?

Medium business

Additional info

Installed with 'brew' on macOS. I use SFTPGO for development purposes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions