You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have a file locally that contains the following text
12345678
and you upload that file with await myRemoteStorage.WriteFileAsync(myRemoteFile, myLocalFile) you will create a file at myRemoteFile and it will be 8 bytes long.
If you now change the file locally to be
0000
and call await myRemoteStorage.WriteFileAsync(myRemoteFile, myLocalFile) then the result file on the server will not change its filesize and it will actually contain the text
00005678
I believe this comes from the WriteAsync method which opens a local and remote stream (see FluentFtpBlobStorage and SshNetSftpBlobStorage) and calls CopyAsync. This does exactly that, copies the stream of data across. But after the rest of the file is not removed.
Using UploadFile from the respective clients should solve this problem, but it prevents being able to append to a file.
I'll try it out and see how it goes, if I find a solution I'll create a PR.
Provider
Impacted (may not be accurate)
FluentStorage
✅
FluentStorage.AWS
❌
FluentStorage.GCP
❌
FluentStorage.Databricks
❌
FluentStorage.FTP
❌
FluentStorage.SFTP
✅
FluentStorage.Azure.Blobs
❌
FluentStorage.Azure.Files
❌
FluentStorage.Azure.EventHub
❓
FluentStorage.Azure.ServiceBus
❓
FluentStorage.Azure.KeyVault
❌
FluentStorage.Azure.ServiceFabric
❌
FluentStorage.Azure.Queues
❓
FluentStorage.Azure.DataLake
✅
Skimming through code to see what is and isn't impacted. May not be 100% accurate. (EDIT: Tested FluentStorage.FTP thismroning and it does not have this problem)
Eyeballing the test here (without actuallying knowing how these tests work), changing the attributes to have something smaller after the longer test should find it? (assuming upload to the same location)
The text was updated successfully, but these errors were encountered:
beeradmoore
changed the title
[Bug] WriteFileAsync will not reduce file size resuling in data leak (tested with FTP and SFTP)
[Bug] WriteFileAsync will not reduce file size resuling in data leak (SFTP)
Jan 30, 2024
Upon testing today I was not able to replicate in FluentStorage.FTP. I guess the underlying FtpDataStream object handles this correctly and the issue may only be with how SftpFileStream handles things.
If you have a file locally that contains the following text
and you upload that file with
await myRemoteStorage.WriteFileAsync(myRemoteFile, myLocalFile)
you will create a file atmyRemoteFile
and it will be 8 bytes long.If you now change the file locally to be
and call
await myRemoteStorage.WriteFileAsync(myRemoteFile, myLocalFile)
then the result file on the server will not change its filesize and it will actually contain the textI believe this comes from the
WriteAsync
method which opens a local and remote stream (see FluentFtpBlobStorage and SshNetSftpBlobStorage) and callsCopyAsync
. This does exactly that, copies the stream of data across. But after the rest of the file is not removed.This is very similar to the behaviour which casued people to be able to uncrop screenshots due to a bug in the image cropper.
Using
UploadFile
from the respective clients should solve this problem, but it prevents being able to append to a file.I'll try it out and see how it goes, if I find a solution I'll create a PR.
Skimming through code to see what is and isn't impacted. May not be 100% accurate. (EDIT: Tested FluentStorage.FTP thismroning and it does not have this problem)
Eyeballing the test here (without actuallying knowing how these tests work), changing the attributes to have something smaller after the longer test should find it? (assuming upload to the same location)
The text was updated successfully, but these errors were encountered: