Skip to content

On-the-fly encryption support #219

Closed

Description

@TripleEmcoder

I've seen a comment in the thread about ACD support regarding plans for an encryption mechanism in rclone. Could you please elaborate on that? When could this possibly become available?

Activity

  1. ncw commented on Nov 15, 2015

    @ncw
    Member

    I've had a few thoughts about this which I've jotted down in rclone's notes (at the end).

    How would you see it working? Perhaps there would be an rclone config setup for setting the parameters of the encryption.

    Would you want to enter a password each time you ran rclone or would you be happy with the encryption key being in the config file?

  2. TripleEmcoder commented on Nov 15, 2015

    @TripleEmcoder
    Author

    Personally I just don't want the cloud provider to read the contents of my files (backup scenario):

    • filenames do not need to be encrypted
    • encryption can use a symmetric algorithm with a key stored in the config file
  3. ech1965 commented on Nov 15, 2015

    @ech1965

    +1 on TripleEmcoder

    With the recent addition of Hubic backend, a encryption layer would be awsome !

    Maybe usefull ?
    https://godoc.org/golang.org/x/crypto/openpgp

    Would it be possible to store the MD5SUM of both contents ( cleattext and crypted) ?

  4. barsanuphe commented on Nov 22, 2015

    @barsanuphe

    First off, thanks for rclone (especially with hubic support)!

    Regarding this issue, why should rclone have to deal with encryption? Many options are already available to reliably and securely encrypt your files.
    For example, I'm currently making a wrapper around bup and rclone to backup my files, and I was thinking of just using encfs (with --reverse) to encrypt on the go and rclone the encrypted version to the internets.

    I'm not against the idea of adding an encryption layer, but in my mind rclone's job is more about moving files around than about modifying them.

  5. TripleEmcoder commented on Nov 22, 2015

    @TripleEmcoder
    Author

    This does seem like a viable solution. I wasn't aware of encfs and the --reverse mode. It seems very promising.

    For anyone interested I will be testing the following setup over the next weeks:

    encfs --reverse /home /mnt/home-enfs
    rclone /mnt/home-encfs Dropbox:backups/home
    

    If you copy the config file with the generated key ( .encfs6.xml) to a second directory you can also achieve selective restore:

    encfs --reverse /home-restore /mnt/home-restore-enfs
    rclone Dropbox:backups/home/some/directory /mnt/home-restore-encfs
    

    You'll have your file decrypted in /home-restore without touching /home

  6. ech1965 commented on Nov 22, 2015

    @ech1965

    The only issue with encfs in this context, is due to the main concern here[1] in conclusion:

    EncFS is probably safe as long as the adversary only gets one copy of
    the ciphertext and nothing more. EncFS is not safe if the adversary
    has the opportunity to see two or more snapshots of the ciphertext at
    different times. EncFS attempts to protect files from malicious
    modification, but there are serious problems with this feature.

    [1] https://defuse.ca/audits/encfs.htm

  7. barsanuphe commented on Nov 22, 2015

    @barsanuphe

    I guess encfs would be good enough for a lot of situations. Anyway, it was just an example, the point being that you can use whatever encryption mechanism you want already.

  8. ech1965 commented on Nov 22, 2015

    @ech1965

    Encfs is indeed good in a lot of situations. Unfortunately, for crypting data before sending it to a "untrusty" place, it ( IMHO) must not be recommended.

  9. barsanuphe commented on Nov 22, 2015

    @barsanuphe

    Well, you could change the passphrase each time you encfs --reverse your files. Syncing would not be incremental, however. I take your point: not ideal.

  10. klauspost commented on Nov 23, 2015

    @klauspost
    Contributor

    You could also have a look at restic, which has a lot of similar functionality to rclone, except that it only does encrypted content.

    It is not my call if rclone should have encryption or not, but it could seem like something that maybe doesn't belong.

  11. ncw commented on Nov 23, 2015

    @ncw
    Member

    My view is that an encryption layer for rclone would be relatively easy to add (if done right).

    I would use a state of the art block cipher with a random IV for encryption / decryption. The same for filename encryption if required. I wouldn't put any integrity checking in - if you put the wrong password in you'll get random data out.

    I quite like the idea, but then I'm a bit of a crypto geek anyway ;-)

  12. barsanuphe commented on Nov 23, 2015

    @barsanuphe

    So if you sync A (encrypted) to B using the wrong passphrase and then sync B back to A, you lose both sets without knowing it?

  13. barsanuphe commented on Nov 27, 2015

    @barsanuphe

    @klauspost thanks for the tip, restic looks nice. For my purpose, rcloning the local restic repository should be sufficient, and a better alternative than using encfs.

  14. 55 remaining items

  15. fantom-x commented on Aug 20, 2016

    @fantom-x

    How about generating random names (uuid) and have two files for each original one: one file stores a file full path and the the other one is the actual file body. Two different extensions will tell which file is which, and extra padding in the "meta data" file will minimize the file name length leak. This "meta data" file could be used for storing additional attributes, like creation time, permissions, etc.
    This would be more resilient that a single meta data file per a directory: if a meta data file is lost, only one file is affected and it would also hide directory structure info.

    Ideally, you wold want to avoid leaking the file size info either: that can reveal a lot about the files too. But that is a bit more complicated problem...

  16. spiffytech commented on Aug 20, 2016

    @spiffytech
    Contributor

    Needing $NUM_FILES reads to do a directory listing would probably slow rclone down substantially vs reading a single listing file, or using the storage provider's native file listing API call.

    Also, we need to be careful of how many file reads we require, since some cloud providers charge per read (sometimes after some number of free reads) (in addition to their bandwidth charges).

  17. spiffytech commented on Aug 21, 2016

    @spiffytech
    Contributor

    @ncw What scenarios are you thinking could corrupt the file index? Depending on what they are (i.e., if you're worried about random single-files going missing/becoming malformed), you could double-write the index to two locations on the remote.

    As a last-ditch protection, you could also prepend each file's plaintext with a header containing the original filename. It wouldn't be practically usable for to listing the contents of a remote, but the original data could still be recovered during a restore.

  18. ncw commented on Aug 24, 2016

    @ncw
    Member

    @fantom-x good idea about storing the metadata elsewhere. I could store it in the file too (encrypted of course) then that would give you a way of rebuilding the index.

    @spiffytech lots of file reads per directory is undesirable as you pointed out. A single index file is prone to corruption (think two rclones running at the same time), but storing the metadata in the files too would give you a way of rebuilding it which I like.

    I've merged the current crypt implementation to master and will try to push out the 1.33 release tonight.

    I've made another ticket about future directions in #637 please feel free to chip in there.

    I'm going to close this ticket now - please make new issues if you find any problems.

  19. jessepeterson commented on Aug 25, 2016

    @jessepeterson

    Sorry for the late response here. And thanks for adding support for this!

    Would anybody find PKI encryption useful here? I.e. separating the ability to decrypt/download from encrypt/upload using private and public keys (perhaps using X509 certs)? This would allow, say, a backup host to encrypt/upload files but without a private key wouldn't necessarily be able to download and decrypt files.

    The protection afforded here would be protecting the encrypted files from being decrypted by using a compromised rclone.conf file. Granted rclone needs access to the unencrypted data anyway so if the rclone host is compromised such that the rclone.conf is compromised it may be the case that the unencrypted files are also compromised. But still, I could see it useful in certain situations.

  20. ncw commented on Aug 27, 2016

    @ncw
    Member

    @jessepeterson an interesting idea. It would mean having a separate key (for the underlying symmetric cipher) for each message. You'd store the public key encrypted key in the header of each file.

    Yes if rclone.conf was compromised then you'd have access to the public key encrypted data.

    My experience with this sort of thing is that the crypto for PKI is easy, it is all the certificate handling which is a pain. If there was some nice library I could use that would be idea!

    If you'd like me to explore further then please make another issue.

    Thanks Nick

  21. dan-cristian commented on Sep 2, 2016

    @dan-cristian

    This is a great feature. Slightly unrelated question, is there a way to decrypt cloud files on a mobile client, e.g. I have an encrypted document on Amazon Drive and I want to open it from my Android phone?

  22. therealmarv commented on Sep 2, 2016

    @therealmarv

    @dan-cristian
    this is a big feature request. Currently I cannot even open encfs encrypted on ACD with my Android. You should open a new bug but I think it's not rclone's responsibility to create an Android app for that use case.

  23. dsrbecky commented on Sep 6, 2016

    @dsrbecky

    Regarding salt: I am somewhat worried about salt.
    If user is careful enough to add custom memorable salt, then they can achieve the same effect by longer password.
    If the salt is random, and they lose it, they lose all data.
    However, how about using the user's email address as the salt?
    I also like Daniel's idea of just storing on the remote and essentially making it public.

  24. stephenjamieson commented on Sep 12, 2016

    @stephenjamieson

    With the filename_encryption enabled I ran into the "Member must have length less than or equal to 280" on ACD.

  25. DurvalMenezes commented on Oct 13, 2016

    @DurvalMenezes
    Contributor

    Hello,

    Just found this issue when I googled for the "failed to satisfy constraint: Member must have length less than or equal to 280" error which just got here, when I tried copying a large, many-levels-of-subdirectories local dir to my encrypted ACD account with:

    rclone --bwlimit=99M --transfers=32 -v --log-file=LOGFILE.out copy LOCALDIR0000001 ACDE:REMOTEDIR000001
    

    Here is the (hopefully, complete) relevant part of the log:

    2016/10/12 19:47:20 &{AAAAAAAAAAAAAAAA/BBBBBBBB/CCCCCCCC/DDDDDDD/EEEEEEEEEEE/FFFF/GGGGG/HHHHH/IIIIIIIIII/JJJJJJJJJJ/KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0xc4202523c0}: Object not found - waiting (24/24)
    2016/10/12 19:47:25 pacer: Rate limited, sleeping for 1.77546523s (2 consecutive low level retries)
    2016/10/12 19:47:25 pacer: low level retry 1/1 (error HTTP code 400: "400 Bad Request", reponse body: {"logref":"00aaf3b4-90e6-11e6-b555-57c65b0966d4","message":"1 validation error detected: Value \u002730bn9p5192gr11b5hrbvt43npbbl0mkfva61332t6vmo5mn7hno448i8a9ivppqtj2ofrdnbadlsmuh7qa5is74ei8i0r1d9bis695v204748mi6snc48r5rrqgluipv0pv5lisg83hcptdmaaoam3aur039aann6firl1tgk97u7p28b5kk4dbie1fna4dnbn4fk5uhajvobcpuiklkpj654citotpmcdbgk93lp31cmna1md5g0l4m2jvn652eu2ruirfdkpa3s2c9hm0lo86jhdre1dee5g40gejk1usmpvgpgjcikgq5qk80a39aavdhs4rm9gcui\u0027 at \u0027name\u0027 failed to satisfy constraint: Member must have length less than or equal to 280","code":""})
    2016/10/12 19:47:25 AAAAAAAAAAAAAAAA/BBBBBBBB/CCCCCCCC/DDDDDDD/EEEEEEEEEEE/FFFF/GGGGG/HHHHH/IIIIIIIIII/JJJJJJJJJJ/KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK: Failed to copy: HTTP code 400: "400 Bad Request", reponse body: {"logref":"00aaf3b4-90e6-11e6-b555-57c65b0966d4","message":"1 validation error detected: Value \u002730bn9p5192gr11b5hrbvt43npbbl0mkfva61332t6vmo5mn7hno448i8a9ivppqtj2ofrdnbadlsmuh7qa5is74ei8i0r1d9bis695v204748mi6snc48r5rrqgluipv0pv5lisg83hcptdmaaoam3aur039aann6firl1tgk97u7p28b5kk4dbie1fna4dnbn4fk5uhajvobcpuiklkpj654citotpmcdbgk93lp31cmna1md5g0l4m2jvn652eu2ruirfdkpa3s2c9hm0lo86jhdre1dee5g40gejk1usmpvgpgjcikgq5qk80a39aavdhs4rm9gcui\u0027 at \u0027name\u0027 failed to satisfy constraint: Member must have length less than or equal to 280","code":""}
    2016/10/12 19:47:25 Attempt 3/3 failed with 6 errors and: HTTP code 400: "400 Bad Request", reponse body: {"logref":"00aaf3b4-90e6-11e6-b555-57c65b0966d4","message":"1 validation error detected: Value \u002730bn9p5192gr11b5hrbvt43npbbl0mkfva61332t6vmo5mn7hno448i8a9ivppqtj2ofrdnbadlsmuh7qa5is74ei8i0r1d9bis695v204748mi6snc48r5rrqgluipv0pv5lisg83hcptdmaaoam3aur039aann6firl1tgk97u7p28b5kk4dbie1fna4dnbn4fk5uhajvobcpuiklkpj654citotpmcdbgk93lp31cmna1md5g0l4m2jvn652eu2ruirfdkpa3s2c9hm0lo86jhdre1dee5g40gejk1usmpvgpgjcikgq5qk80a39aavdhs4rm9gcui\u0027 at \u0027name\u0027 failed to satisfy constraint: Member must have length less than or equal to 280","code":""}
    2016/10/12 19:47:25 Failed to copy: HTTP code 400: "400 Bad Request", reponse body: {"logref":"00aaf3b4-90e6-11e6-b555-57c65b0966d4","message":"1 validation error detected: Value \u002730bn9p5192gr11b5hrbvt43npbbl0mkfva61332t6vmo5mn7hno448i8a9ivppqtj2ofrdnbadlsmuh7qa5is74ei8i0r1d9bis695v204748mi6snc48r5rrqgluipv0pv5lisg83hcptdmaaoam3aur039aann6firl1tgk97u7p28b5kk4dbie1fna4dnbn4fk5uhajvobcpuiklkpj654citotpmcdbgk93lp31cmna1md5g0l4m2jvn652eu2ruirfdkpa3s2c9hm0lo86jhdre1dee5g40gejk1usmpvgpgjcikgq5qk80a39aavdhs4rm9gcui\u0027 at \u0027name\u0027 failed to satisfy constraint: Member must have length less than or equal to 280","code":""}
    

    How can I help debug that? I think the copy is aborting at that file with this error, so my backup isn't finishing... :-/

    Cheers,

    Durval.

  26. ncw commented on Oct 13, 2016

    @ncw
    Member

    @DurvalMenezes unfortunately ACD has quite a short path length. Looks like your K element which is 194 chars expands to 334 byte encrypted length which exceeds the 256 char limit (though amazon says it is 280 chars in the error message which is unexpected!).

    The copy will just fail to copy that file - everything else should go through OK.

    Can you rename it? That would fix it! Or don't use file name encryption, or wait for #637 to be done.

    BTW did it actually print

    &{AAAAAAAAAAAAAAAA/BBBBBBBB/CCCCCCCC/DDDDDDD/EEEEEEEEEEE/FFFF/GGGGG/HHHHH/IIIIIIIIII/JJJJJJJJJJ/KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK 0xc4202523c0}: Object not found - waiting (24/24)
    

    With &{...}? That is probably a bug! Though maybe I fixed it in 5b91388 - was that from the latest beta?

  27. DurvalMenezes commented on Oct 16, 2016

    @DurvalMenezes
    Contributor

    Hi Nick,

    Sorry for taking so long to respond, and thanks for your reply. More below:

    Looks like your K element which is 194 chars expands to 334 byte encrypted length which exceeds

    Ah! So the limit is per path element, instead of the total pathname. Makes sense.

    One question: is there a formula or something to calculate what would be the encrypted length of a pathname element? Then I could employ it here to "preprocess" the directory tree before uploading it (see below).

    the 256 char limit (though amazon says it is 280 chars in the error message which is unexpected!).

    I have had quite a few more "Member must have length less than or equal to" errors here (not only in AAAAAAAAAAAAAAAA but also on other directory trees I've copied to my ACDE remote) and I can confirm that the number it prints is always 280.

    The copy will just fail to copy that file - everything else should go through OK.

    Thanks for the info, I was under the impression that the transfer aborted when it met the first of those errors. In fact, I just ran some one-liners here to check the number of files missing between the local dirtree and the remote dirtree and in all cases it is exactly the number of files mentioned in the above error messages, so I think we can be pretty sure that all the other files were safely copied.

    Can you rename it? That would fix it!

    Perhaps I can run a script here which detects what files have too large component names, and then I can hardlink them to shornames (say, "0001", "0002" etc) in a specially created directory (say, 00LONG_NAMES_HARDLINKED_HERE) on the top of the dirtree, which would also contain a logfile of the "ln " commands issued by the script.

    Then I upload the whole dirtree (including the directory created above); in the future (when rclone works around this ACD limitation) I can then download just this dir from the remote dirtree, 'revert' the "ln" commands ("regenerating" the affected files with their full pathname, locally) and then "rsync copy" the dir with the files with their "regenerated" pathnames into that same dirtree in the ACD encrypted remote. Finally, it would be just a matter of purging the special directory.

    What do you think?

    Or don't use file name encryption,

    Unfortunately that's not an option... these file names "encode" sensitive metadata information about the file which can't be left "in the open" (the AAAAAAAAAAAAAAAA etc above are actually obfuscations on the original component names).

    or wait for #637 to be done.

    Man, that would be great, and not only for this issue but also for ModTime, useful hashes, etc. I wish I knew Go (or had the time to sit down and study it right now) so I could contribute to implementing this... but if you need any testing or anything, just let me know.

    BTW did it actually print [...]
    With &{...}? That is probably a bug! Though maybe I fixed it in 5b91388 - was that from the latest beta?

    Yes it did, and it's not the beta but just plain v. 1.33. Do you want me to repeat the test using the beta?

    Cheers,

    Durval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions