Skip to content

Google Drive (encrypted): "failed to authenticate decrypted block - bad password?" on files during reading #999

Closed

Description

@DurvalMenezes

What is your rclone version (eg output from rclone -V)

rclone 1.35

Which OS you are using and how many bits (eg Windows 7, 64 bit)

Devuan Linux 1.0 (systemd-free fork of Debian Jessie).

Which cloud storage system are you using? (eg Google Drive)

Google Drive, with the built-in rclone encryption.

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone -v --dump-headers --log-file=LOGFILE copy egd:REDACTED/REDACTED/REDACTED/REDACTED.mp4 /tmp/REDACTED.mp4

A log from the command with the -v flag (eg output from rclone -v copy /tmp remote:tmp)

Please find it attached: LOGFILE.txt

Note 1: This is related to #677, which is closed and I cannot reopen.
Note 2: These errors are 100% reproducible.

Cheers,
Durval.

Activity

  1. 4getit commented on Jan 8, 2017

    @4getit

    Same issue here. Very worrying because I have many thousands files and no idea what file is ok and what file isn't.

    With many files on an encrypted Google Drive I get the following errors when trying to copy to local: http://pastebin.com/ySNPSXgi
    I think it goes wrong when writing the file.

    The files were copied from a non encrypted remote (01:) to an encrypted remote (02crypt:) with the copy command.

    I still have 01: so I tried to fix the files on 02crypt by doing a sync 01: 02crypt:. I hoped that the corrupted would be written again because of some failed checks but no. The files from 02crypt: still won't copy back to local.

    Sizes and file counts report ok:

    ~/drive/rclone size 01:
    Total objects: 12847
    Total size: 19918.153 GBytes (21386954189603 Bytes)

    ~/drive/rclone size 02crypt:
    Total objects: 12847
    Total size: 19918.153 GBytes (21386954189603 Bytes)

  2. DurvalMenezes commented on Jan 8, 2017

    @DurvalMenezes
    ContributorAuthor

    @4getit wrote:

    Same issue here. Very worrying because I have many thousands files and no idea what file is ok and what file isn't.

    You'd better check them all, not only right after uploading, but also periodically. For this, I generate MD5 files of all data and store it along the data, both locally and remotely, and then use "md5sum -c" (on a rclone mount for the remote files).

    I've learned from hard, cold experience that my files aren't safe unless I have at least 3 copies stored in different places and verify each and every file of each and every copy periodically. I already work with two physical copies (one local and the other stored in a different place in my city), and my rclone usage is an attempt to try and store a 3rd copy in a really different place (hopefully another continent).

    So I think this recent experience just confirms all that. I posted a "tale of warning" topic on the forum just as a heads-up to everyone: https://forum.rclone.org/t/a-tale-of-warning-silently-corrupted-unreadable-data-on-remote/664

    Cheers,
    Durval.

  3. ncw commented on Jan 8, 2017

    @ncw
    Member

    I'm sorry you are having problems with this. I think this probably isn't related to #677 - practically any error in the crypt data transfer will cause that error message.

    Can you perform a test for me? I'd like you to see if you can download the encrypted version of a file, then try to decrypt it locally.

    To work out which file it is, you'll need to find out what it is called. The easiest way of doing this is to find the directory

    rclone -v ls egd:REDACTED/REDACTED/REDACTED/REDACTED.mp4
    

    This will print a messagae like this

    2017/01/08 12:10:20 Encrypted Google drive root 'h0fgn6vkka25jj9fhu5roml6pg/rv5l12j0nanu5af9ivc97ofdk8/gtu1leijh9rlm05pcjtusqop2g': Modify window is 1ms
    

    That will be the directory that the file is in. You can find exactly which one it is by matching the sizes in the web interface.

    Once you've identified the file, can you try downloading it with rclone copy (using the non encrypted mount). Say to a directory called /tmp/downloaded

    If you then edit your config file with a text editor and duplicate your egd remote calling it elocal say and change the remote line to be remote = /tmp/downloaded, this will let you decrypt things locally.

    You can then use rclone ls elocal: and if you can try rclone copy elocal:REDACTED.mp4 /tmp/redownload and see what happens there.

    This will enable me to see whether

    • the file is corrupted on google drive
    • or rclone is having a problem downloading the file (which would also give that error).

    Can you also try downloading the ecnrypted file with the web intereface and see if it is the same as the file you download with rclone copy.

    Other questions

    • is it only large files you see this problem on?
    • what does rclone check say?

    I note that #854 would be useful here.

  4. ncw commented on Jan 8, 2017

    @ncw
    Member

    If you have the original file, another useful check would be to rclone copy it into the elocal: and then compare that file with the one you downloaded from drive - (size and md5sum).

  5. DurvalMenezes commented on Jan 8, 2017

    @DurvalMenezes
    ContributorAuthor

    Thanks for your long and thoughtful comment, @ncw. It's a pleasure using a program whose developer is so dedicated and responsive.

    More below:

    I'm sorry you are having problems with this.

    No problem -- every piece of software more complex than "helloworld" has issues, and in this case, no one can assert that the error is indeed on rclone: the data could have been corrupted on GDrive itself. About the only thing I can say is that it has not been corrupted in my servers: I use ZFS (which has built-in checksums) for everything, and all the machines involved in the above transfers have ECC RAM (my only 'computers' without ECC RAM are my laptop, my mediacenter and my smartphone -- and I plan on getting an ECC-based laptop ASAP as they are now somewhat available).

    I think this probably isn't related to #677 - practically any error in the crypt data transfer will cause that error message.

    Thanks for the clarification. I mentioned it because it was the issue I found more similar to my current one, and it was one where I had commented before.

    Can you perform a test for me?
    Sure thing, and with pleasure.

    I'd like you to see if you can download the encrypted version of a file, then try to decrypt it locally.

    To work out which file it is, you'll need to find out what it is called. The easiest way of doing this is to find the directory

    rclone -v ls egd:REDACTED/REDACTED/REDACTED/REDACTED.mp4
    This will print a messagae like this

    2017/01/08 12:10:20 Encrypted Google drive root 'h0fgn6vkka25jj9fhu5roml6pg/rv5l12j0nanu5af9ivc97ofdk8/gtu1leijh9rlm05pcjtusqop2g': Modify window is 1ms
    That will be the directory that the file is in. You can find exactly which one it is by matching the sizes in the web interface.

    I tried, but in that particular dir there are a quite a few files with very similar sizes, and not one of them matches the rclone-encrypted size exactly:

    rclone -v ls egd:REDACTED/REDACTED/REDACTED/REDACTED.mp4
        [...]
        2017/01/08 11:00:55 Encrypted Google drive root 'ad9vmobdicfbsr1bbropaghtik/j9t3ij7t2vmucl443rn90hmjbo/jhdir64l56ogdjpqjd71ubgenc0frv2fe8m9v062qlea593jc97g': Modify window is 1ms
        261996813 REDACTED.mp4
    
    rclone lsl gd:ad9vmobdicfbsr1bbropaghtik/j9t3ij7t2vmucl443rn90hmjbo/jhdir64l56ogdjpqjd71ubgenc0frv2fe8m9v062qlea593jc97g
        273431102 2015-07-12 22:21:35.000000000 f9hn2m7fl0pdcovj6h6d5qehn0
        297627326 2015-07-19 22:17:07.000000000 jk0h2ivoe2h72m6srpp9fa0mng
        276411244 2015-07-28 09:43:19.000000000 ehkgqi1kk6mj0qbq6svabks8dc
        262060813 2015-08-02 00:00:00.000000000 4s56ib1p2pjdofn9s4tpveehg8
        270034172 2015-07-13 20:30:37.000000000 kiqb75mi7fdtkn5l2mf0r8kejk
        279349228 2015-07-05 00:00:00.000000000 i8n4frjl7ckvandpk3la02brrg
    

    Correct me if I'm wrong, but I think none of the sizes match because rclone crypt does some "padding". If I had to guess, I would have bet on the file with the closest size (ie. 262060813), but I don't like to bet :-) so I think it's best to ask you how to proceed.

    OTOH, is there any particular reason for the rclone -v output not including each file's encrypted full path+filename? If not please let me know and I will open an issue for it, as I think it would make these kinds of determinations much easier.

    Once you've identified the file, can you try downloading it with rclone copy (using the non encrypted mount). Say to a directory called /tmp/downloaded

    If you then edit your config file with a text editor and duplicate your egd remote calling it elocal say and change the remote line to be remote = /tmp/downloaded, this will let you decrypt things locally.

    You can then use rclone ls elocal: and if you can try rclone copy elocal:REDACTED.mp4 /tmp/redownload and see what happens there.

    This will enable me to see whether

    the file is corrupted on google drive
    or rclone is having a problem downloading the file (which would also give that error).
    Can you also try downloading the ecnrypted file with the web intereface and see if it is the same as the file you download with rclone copy.

    Please let me know how to determine the exact file as I asked above so I can proceed in answering these questions.

    Other questions

    is it only large files you see this problem on?

    What is "large"? ;-) To try and anwer that, I just checked and the smallest of the 73 files that show this problem has exactly 22067174 bytes (~22MB), unencrypted of course.

    what does rclone check say?

    Last two lines state:

    [...] 0 differences found
    [...] 16 hashes could not be checked
    
    

    Please find the entire "-v" output here: rclone_check_output_20170109Z141923.txt

    I note that #854 would be useful here.
    I see what you mean. Even better would be an rclone-equivalent of a "md5sum -c" (perhaps a "-c" option to "rclone md5sum"?), where I supply a remote path and a local .md5 file (eg, one generated using "md5sum * >file.md5" or equivalent), and then rclone calculates the MD5SUM for every remote file mentioned in the .md5 file and checks against the MD5SUM contained in that file and prints the appropriate message just like a local "md5sum -c" (or one run against a "rclone mount" on the remote) would.

    Cheers,
    Durval.

  6. DurvalMenezes commented on Jan 8, 2017

    @DurvalMenezes
    ContributorAuthor

    @ncw said:

    If you have the original file, another useful check would be to rclone copy it into the elocal: and then compare that file with the one you downloaded from drive - (size and md5sum).

    Of course I do have it; in fact, I have all of them, and in duplicate. It will be a cold day in Hell when I get caught with my pants down regarding not having redundant copies of all my data ;-)

    I will wait for your guidance re: my question above (on how to identify the exact encrypted file between many with approximately the same size).

    Cheers,
    Durval.

  7. ncw commented on Jan 8, 2017

    @ncw
    Member

    Ach, I forgot about the padding... Yes your guess of the file of size 262060813 is correct

    Calculation using python

    >>> divmod(262060813-32,(65536+16))
    (3997, 49437)
    >>> 3997*65536+49437-16
    261996813
    

    No problem -- every piece of software more complex than "helloworld" has issues, and in this case, no one can assert that the error is indeed on rclone: the data could have been corrupted on GDrive itself.

    Yes that is the first thing we need to do - work out where the corruption is happening.

    About the only thing I can say is that it has not been corrupted in my servers: I use ZFS (which has built-in checksums) for everything, and all the machines involved in the above transfers have ECC RAM (my only 'computers' without ECC RAM are my laptop, my mediacenter and my smartphone -- and I plan on getting an ECC-based laptop ASAP as they are now somewhat available).

    We have similar levels of paranoia about data loss! You'd probably enjoy one of my other programs stressdisk if you haven't seen it already.

    OTOH, is there any particular reason for the rclone -v output not including each file's encrypted full path+filename? If not please let me know and I will open an issue for it, as I think it would make these kinds of determinations much easier.

    I agree that would be useful. Probably what I'd so is make the name mappings show if you do an ls -v - how does that sound? If you wanted to make an issue about it that would be great.

    16 hashes could not be checked

    Can you try it over the whole remote? I'm concerned as to whether rclone check will notice those missing files you reported.

    I see what you mean. Even better would be an rclone-equivalent of a "md5sum -c" (perhaps a "-c" option to "rclone md5sum"?), where I supply a remote path and a local .md5 file (eg, one generated using "md5sum * >file.md5" or equivalent), and then rclone calculates the MD5SUM for every remote file mentioned in the .md5 file and checks against the MD5SUM contained in that file and prints the appropriate message just like a local "md5sum -c" (or one run against a "rclone mount" on the remote) would.

    That is effectively what rclone check does at the moment - however crypt doesn't support hashes. With the addition of #854 it would work for crypted remotes too

    A -c option to rclone md5sum is a good idea too.

  8. DurvalMenezes commented on Jan 8, 2017

    @DurvalMenezes
    ContributorAuthor

    Hello @ncw,

    Again thanks for your response. So let's move ahead:

    Ach, I forgot about the padding... Yes your guess of the file of size 262060813 is correct

    Great! So here's what you asked for:

    Once you've identified the file, can you try downloading it with rclone copy (using the non encrypted mount). Say to a directory called /tmp/downloaded

    Done:

    mkdir /tmp/rclone_issue_999_test_20170108Z191002
    cd !$
    rclone copy -v gd:ad9vmobdicfbsr1bbropaghtik/j9t3ij7t2vmucl443rn90hmjbo/jhdir64l56ogdjpqjd71ubgenc0frv2fe8m9v062qlea593jc97g/4s56ib1p2pjdofn9s4tpveehg8 .
    
    

    It produced the following output:

    2017/01/08 17:12:35 rclone: Version "v1.35" starting with parameters ["rclone" "copy" "-v" "gd:ad9vmobdicfbsr1bbropaghtik/j9t3ij7t2vmucl443rn90hmjbo/jhdir64l56ogdjpqjd71ubgenc0frv2fe8m9v062qlea593jc97g/4s56ib1p2pjdofn9s4tpveehg8" "."]
    2017/01/08 17:12:38 Local file system at /tmp/rclone_issue_999_test_20170108Z191002: Modify window is 1s
    2017/01/08 17:12:39 Local file system at /tmp/rclone_issue_999_test_20170108Z191002: Waiting for checks to finish
    2017/01/08 17:12:39 Local file system at /tmp/rclone_issue_999_test_20170108Z191002: Waiting for transfers to finish
    2017/01/08 17:13:38 
    Transferred:   4.375 MBytes (70.504 kBytes/s)
    Errors:                 0
    Checks:                 0
    Transferred:            0
    Elapsed time:      1m3.5s
    Transferring:
     *                    4s56ib1p2pjdofn9s4tpveehg8:  1% done, 76.660 kBytes/s, ETA: 54m39s
    [...]
    2017/01/08 18:13:56 4s56ib1p2pjdofn9s4tpveehg8: Copied (new)
    2017/01/08 18:13:56
    Transferred:   249.921 MBytes (69.512 kBytes/s)
    Errors:                 0
    Checks:                 0
    Transferred:            1
    Elapsed time:   1h1m21.6s
    2017/01/08 18:13:56 Go routines at exit 6
    

    If you then edit your config file with a text editor and duplicate your egd remote calling it elocal say and change the remote line to be remote = /tmp/downloaded, this will let you decrypt things locally.

    Here's a diff of my edit:

    --- .rclone.conf.orig-20170108Z191002      2017-01-08 16:57:52.000000000 -0200
    +++ .rclone.conf   2017-01-08 18:43:10.000000000 -0200
    @@ -31,3 +31,9 @@
       password = REDACTED
       password2 = REDACTED
    
       +[elo]
       +type = crypt
       +remote = /tmp/rclone_issue_999_test_20170108Z191002
       +filename_encryption = standard
       +password = REDACTED
       +password2 = REDACTED
    

    You can then use rclone ls elocal: and if you can try rclone copy elocal:REDACTED.mp4 /tmp/redownload and see what happens there.

    Here are the commands I ran, and their output:

    rclone ls elo:
        261996813 REDACTED.mp4
    
    rclone -v copy elo:REDACTED.mp4 /tmp/test.mp4
        2017/01/08 18:45:40 rclone: Version "v1.35" starting with parameters ["rclone" "-v" "copy" "elo:REDACTED.mp4" "/tmp/test.mp4"]
        2017/01/08 18:45:40 Local file system at /tmp/test.mp4: Modify window is 1s
        2017/01/08 18:45:40 Local file system at /tmp/test.mp4: Waiting for checks to finish
        2017/01/08 18:45:40 Local file system at /tmp/test.mp4: Waiting for transfers to finish
        2017/01/08 18:45:40 REDACTED.mp4: Removing partially written file on error: failed to authenticate decrypted block - bad password?
        2017/01/08 18:45:40 REDACTED: Failed to copy: failed to authenticate decrypted block - bad password?
        2017/01/08 18:45:40 Attempt 1/3 failed with 1 errors and: failed to authenticate decrypted block - bad password?
        2017/01/08 18:45:40 Local file system at /tmp/test.mp4: Waiting for checks to finish
        2017/01/08 18:45:40 Local file system at /tmp/test.mp4: Waiting for transfers to finish
        2017/01/08 18:45:40 REDACTED.mp4: Removing partially written file on error: failed to authenticate decrypted block - bad password?
        2017/01/08 18:45:40 REDACTED.mp4: Failed to copy: failed to authenticate decrypted block - bad password?
        2017/01/08 18:45:40 Attempt 2/3 failed with 1 errors and: failed to authenticate decrypted block - bad password?
        2017/01/08 18:45:40 Local file system at /tmp/test.mp4: Waiting for checks to finish
        2017/01/08 18:45:40 Local file system at /tmp/test.mp4: Waiting for transfers to finish
        2017/01/08 18:45:40 REDACTED.mp4: Removing partially written file on error: failed to authenticate decrypted block - bad password?
        2017/01/08 18:45:40 REDACTED.mp4: Failed to copy: failed to authenticate decrypted block - bad password?
        2017/01/08 18:45:40 Attempt 3/3 failed with 1 errors and: failed to authenticate decrypted block - bad password?
        2017/01/08 18:45:40 Failed to copy: failed to authenticate decrypted block - bad password?
    

    This will enable me to see whether
    the file is corrupted on google drive
    or rclone is having a problem downloading the file (which would also give that error).

    If I'm following your reasoning correctly (and please correct me if I don't), I think the above tests show that the file is already corrupted on GDrive (ie, the corruption is not happening during rclone's "download" of it). But, do they show anything regarding how it got corrupted there in the first place (ie, during rclone's "upload", or by some issue on GDrive itself, independently of rclone)?

    If my thinking is correct, this is where an independent rclone-calculated md5sum stored along with the file's metadata (a la #637) would have helped us a lot... :-/

    Can you also try downloading the ecnrypted file with the web intereface and see if it is the same as the file you download with rclone copy.

    Just did (saved it as /tmp/encrypted_REDACTED_downloaded_via_WebUI), and it's exactly the same file downloaded by the above "rclone copy gd:" command.

    md5sum  /tmp/rclone_issue_999_test_20170108Z191002/4s56ib1p2pjdofn9s4tpveehg8 /tmp/encrypted_REDACTED_downloaded_via_WebUI 
        81fed713aed1ba6b3f7b2408bb912f4a  4s56ib1p2pjdofn9s4tpveehg8/4s56ib1p2pjdofn9s4tpveehg8
        81fed713aed1ba6b3f7b2408bb912f4a  /home/durval/Downloads/4s56ib1p2pjdofn9s4tpveehg8
    

    I think that this corroborates the above: the encrypted file that is now stored on GDrive is already corrupted (ie, in a state where rclone can't decrypt it), it is not being somehow modified by rclone during "download".

    But does this gets us any closer to finding out whether that file was (a) corrupted after being stored in GDrive by the rclone "upload" (ie, by GDrive itself, or at least something that happened on GDrive outside of rclone's "jurisdiction"), or (b) was it corrupted during the original rclone "upload"?

    I will reply to your further comments next.

    Cheers,
    Durval.

  9. DurvalMenezes commented on Jan 8, 2017

    @DurvalMenezes
    ContributorAuthor

    @ncw said:

    We have similar levels of paranoia about data loss! You'd probably enjoy one of my other programs stressdisk if you haven't seen it already.

    "Perfect paranoia is perfect awareness" ;-) I will have a look at your stressdisk program; I actually have one I wrote myself (for sequential-access stressing), which I run in parallel with the venerable dledford's memtest (which, despite its name, is also a great random-access disk stressing program), plus mprime on "torture" mode, on all my machines for at least 24 continuous hours before getting them to production. It has saved me from flaky hardware (from intermittent motherboards to weak power supplies) more times than I can count....

    OTOH, is there any particular reason for the rclone -v output not including each file's encrypted full path+filename? If not please let me know and I will open an issue for it, as I think it would make these kinds of determinations much easier.

    I agree that would be useful. Probably what I'd so is make the name mappings show if you do an ls -v - how does that sound?

    It sounds just about perfect ;-)

    If you wanted to make an issue about it that would be great.

    I've just created it, see: #1004.

    Can you try it over the whole remote? I'm concerned as to whether rclone check will notice those missing files you reported.

    I need to reallocate the relevant disks to my machine with good internet bandwidth (which is offsite), right now it's with other disks whose contents are being copied to GDrive. It will be at least a few weeks before I can do that :-( Sorry...

    A -c option to rclone md5sum is a good idea too.

    That would be great, and allow me to do that checking you asked for immediately. I just opened an issue for it too, see #1005.

    If you have the original file, another useful check would be to rclone copy it into the elocal: and then compare that file with the one you downloaded from drive - (size and md5sum).

    Will do, and let you know (also have to reallocate these pesky disks, but at least it can be done on a local machine, so it will take just a few hours).

    Cheers,
    Durval.

  10. DurvalMenezes commented on Jan 9, 2017

    @DurvalMenezes
    ContributorAuthor

    If you have the original file, another useful check would be to rclone copy it into the elocal: and then compare that file with the one you downloaded from drive - (size and md5sum).

    Will do, and let you know (also have to reallocate these pesky disks, but at least it can be done on a local machine, so it will take just a few hours).

    Here it is:

    rclone mkdir elo:local_copy_into_encrypted_local_volume
    
    rclone -v copy /mnt2/REDACTED/REDACTED/REDACTED.mp4 elo:local_copy_into_encrypted_local_volume
        2017/01/08 22:57:36 rclone: Version "v1.35" starting with parameters ["rclone" "-v" "copy" "/mnt2//mnt2/REDACTED/REDACTED/REDACTED.mp4" "elo:local_copy_into_encrypted_local_volume"]
        2017/01/08 22:57:36 Encrypted Local file system at /tmp/rclone_issue_999_test_20170108Z191002/dn8l3qcrroa7isplg99uj24v5sff6eb89qqokdchr189qtgn6dik7hjg25g1oerca0fci93005rbc: Modify window is 1s
        2017/01/08 22:57:36 Encrypted Local file system at /tmp/rclone_issue_999_test_20170108Z191002/dn8l3qcrroa7isplg99uj24v5sff6eb89qqokdchr189qtgn6dik7hjg25g1oerca0fci93005rbc: Waiting for checks to finish
        2017/01/08 22:57:36 Encrypted Local file system at /tmp/rclone_issue_999_test_20170108Z191002/dn8l3qcrroa7isplg99uj24v5sff6eb89qqokdchr189qtgn    6dik7hjg25g1oerca0fci93005rbc: Waiting for transfers to finish
        2017/01/08 22:57:39 S01E08.mp4: Copied (new)
        2017/01/08 22:57:39 
        Transferred:   249.860 MBytes (73.119 MBytes/s)
        Errors:                 0
        Checks:                 0
        Transferred:            1
        Elapsed time:        3.4s
    
    find /tmp/rclone_issue_999_test_20170108Z191002 -type f -ls
        1999866 256170 -rw-rw-r--   1 durval   durval   262060813 Aug  2  2015 /tmp/rclone_issue_999_test_20170108Z191002/dn8l3qcrroa7isplg99uj24v5sff6eb89qqokdchr189qtgn6dik7hjg25g1oerca0fci93005rbc/4s56ib1p2pjdofn9s4tpveehg8
        652927 256170 -rw-rw-r--   1 durval   durval   262060813 Aug  2  2015 /tmp/rclone_issue_999_test_20170108Z191002/4s56ib1p2pjdofn9s4tpveehg8
    
    md5sum /tmp/rclone_issue_999_test_20170108Z191002/4s56ib1p2pjdofn9s4tpveehg8 /tmp/rclone_issue_999_test_20170108Z191002/dn8l3qcrroa7isplg99uj24v5sff6eb89qqokdchr189qtgn6dik7hjg25g1oerca0fci93005rbc/4s56ib1p2pjdofn9s4tpveehg8
        81fed713aed1ba6b3f7b2408bb912f4a  /tmp/rclone_issue_999_test_20170108Z191002/4s56ib1p2pjdofn9s4tpveehg8
        586c4d7cfdde6ac10594fb0a937960f7  /tmp/rclone_issue_999_test_20170108Z191002/dn8l3qcrroa7isplg99uj24v5sff6eb89qqokdchr189qtgn6dik7hjg25g1oerca0fci93005rbc/4s56ib1p2pjdofn9s4tpveehg8
    

    So it seems that the files have the same size and encrypted filename, but distinct MD5SUMs.

    I hexdumped the start of each file to see how much they differed, and here's what I found:

    hexdump -C /tmp/rclone_issue_999_test_20170108Z191002/4s56ib1p2pjdofn9s4tpveehg8 | head
        00000000  52 43 4c 4f 4e 45 00 00  b2 90 a7 7a 22 ab 99 09  |RCLONE.....z"...|
        00000010  08 53 2d 17 24 c2 9b 5d  8d aa 4c 93 d0 87 13 fa  |.S-.$..]..L.....|
        00000020  8a 90 9e f5 29 5f ac d9  9c 99 3b 18 d6 99 4b b0  |....)_....;...K.|
        00000030  3e f9 fc 59 53 e5 23 41  1a 64 bf 91 cb f4 0b 60  |>..YS.#A.d.....`|
        00000040  d2 9a cb 42 28 53 99 18  2a 75 31 31 64 8d 11 08  |...B(S..*u11d...|
        00000050  5c 28 57 4f c7 c4 33 d7  fa 33 cc 12 f3 a1 98 39  |\(WO..3..3.....9|
        00000060  8a 7b ab 9d 7c fb 45 71  58 8a 91 15 7f 82 73 19  |.{..|.EqX.....s.|
        00000070  c1 70 41 e5 5b ca 26 14  3b 48 36 3b 38 b3 e3 b7  |.pA.[.&.;H6;8...|
        00000080  2c 25 d8 48 03 33 59 e5  a3 d9 66 3f d8 93 30 76  |,%.H.3Y...f?..0v|
        00000090  31 1b 1b 2a 8a 5d dc 21  41 53 23 cd 86 37 52 9a  |1..*.].!AS#..7R.|
    
    hexdump -C /tmp/rclone_issue_999_test_20170108Z191002/dn8l3qcrroa7isplg99uj24v5sff6eb89qqokdchr189qtgn6dik7hjg25g1oerca0fci93005rbc/4s56ib1p2pjdofn9s4tpveehg8 | head
        00000000  52 43 4c 4f 4e 45 00 00  bd cb 88 a1 60 c9 89 6a  |RCLONE......`..j|
        00000010  51 59 6f 53 1f 32 44 f8  52 f5 e4 17 3c 4b f7 69  |QYoS.2D.R...<K.i|
        00000020  28 21 1c af b2 91 08 65  9d 91 db 05 f5 ac 18 e1  |(!.....e........|
        00000030  1e be 52 64 13 38 22 c7  4e 2b 1a f7 58 8c b9 fd  |..Rd.8".N+..X...|
        00000040  cc 6b a4 e9 9a dd 1b 71  d3 7c 50 de 58 37 a3 22  |.k.....q.|P.X7."|
        00000050  bd 07 9e 13 67 ea 7f 7a  47 27 b6 6b 5c 23 e6 bf  |....g..zG'.k\#..|
        00000060  73 38 bc 33 e1 96 f7 3f  c1 b0 b0 ea ae ba 21 40  |s8.3...?......!@|
        00000070  82 c8 be 7b 54 ca 06 1c  b0 a6 b8 e4 03 a7 53 23  |...{T.........S#|
        00000080  9f 86 10 50 3b 46 3f 71  e2 f5 a0 b2 37 f7 83 41  |...P;F?q....7..A|
        00000090  83 9d 5c a8 9a 68 ba 59  1a 09 f2 f5 8b 9b 78 6d  |..\..h.Y......xm|
    

    So it seems that, after the "RCLONE\000\000" header, the files are utterly different. if it was a single byte, or even a sequence of bytes, I would be able to understand that GDrive might have corrupted it... but the entire file?! Only if GDrive managed to somehow replace the entire file content with trash... but it seems it skipped exactly the first 8 bytes of the above header!?

    @ncw, I hope the above is helpful for you (and if it isn't, please feel free to request anything else you'd need).

    Cheers,
    Durval.

  11. 4getit commented on Jan 9, 2017

    @4getit

    I'm pretty sure it happens during the upload.
    Once a file is corrupted, a download always fails at the same point on different hosts.

    I have 1 Google remote with originals and 3 remotes with encrypted copies.
    All encrypted remotes have different (single) passwords and it happens with random files. I haven't spotted any issues with non-encrypted files.

    Maybe it has to do with 403's because of rate limiting or other retries. I'm using --drive-chunk-size 262144 and --transfers 16 to keep things going.

    I'm pretty convinced that the original files are ok and all encrypted copies contain different corrupted files. However, I have no way to determine which ones are corrupted.

    In addition to fixing it, I think it would be great to somehow (optional?) calculate the encrypted md5 from the non encrypted file before a sync (and I guess copy as well). That way Rclone can properly detect if an upload was successful and, in case of sync, corrupted files will be replaced. (Because right now, sync skips them and doesn't do anything.)

  12. ncw commented on Jan 9, 2017

    @ncw
    Member

    @DurvalMenezes - thanks for all your testing and for making the issues

    I think that this corroborates the above: the encrypted file that is now stored on GDrive is already corrupted (ie, in a state where rclone can't decrypt it), it is not being somehow modified by rclone during "download".

    Yes that is my reading of it.

    So it seems that, after the "RCLONE\000\000" header, the files are utterly different.

    Thinking about it further, that is what I'd expect as they have different randomly generated nonces - so that wasn't a particularly useful test, sorry :-(

    I thought of another test which might shed some light...

    If you could rclone cat egd:REDACTED/REDACTED/REDACTED/REDACTED.mp4 > tmp.mp4 or rclone cat elo:REDACTED.mp4 > tmp.mp4 if you prefer and see how big the resulting output is that would be very useful.

    That will tell us which block to look at to see the corrupted data in the encrypted file you downloaded.

    The output file will be some multiple of 65536 long. So take the file size and divide it by 65536 call it N.

    This corresponds to a block at offset 32+N*(65536+16). It would be interesting to see what the data in the encrypted version of the file for the next 64k looks like. If it doesn't look like random data then there will be a clue there.

    If we see a problem at a --drive-chunk-size boundary it is something to do with the multipart uploading.

  13. DurvalMenezes commented on Jan 9, 2017

    @DurvalMenezes
    ContributorAuthor

    Hi @ncw,

    @DurvalMenezes - thanks for all your testing and for making the issues

    You are welcome, it's my pleasure to collaborate.

    Thinking about it further, that is what I'd expect as they have different randomly generated nonces - so that wasn't a particularly useful test, sorry :-(

    No problem, and I'm actually relieved to hear rclone encryption use nonces -- otherwise files with the same content would always encrypt to the same thing, which cryptographically is Not a Good Thing(tm).

    I thought of another test which might shed some light...
    [...]

    Here it is, using the elo: "pseudo" remote (as I have already deleted and re-uploaded the errored files on the real GDrive encrypted remote):

    rclone -v cat elo:REDACTED.mp4 | wc -c
        2017/01/09 15:10:45 REDACTED.mp4: Failed to send to output: failed to authenticate decrypted block - bad password?
        5177609
    

    So, the decryption failed after exactly 5177609 bytes.

    The output file will be some multiple of 65536 long. So take the file size and divide it by 65536 call it N.

    Humrmrmr... presuming you meant N to be an integer: it's close but no cigar, not even minus/plus 1 byte:

    dc
        6 k
    
        5177609 65536 / p
            79.004043
    
        5177609 1 + 65536 / p
            79.004058
    
        5177609 1 - 65536 / p
            79.004028
    

    This corresponds to a block at offset 32+N*(65536+16).

    If I follow you correctly, this doesn't check either:

    5177609 32 - 65536 16 + / p
        78.984272
    
    

    It would be interesting to see what the data in the encrypted version of the file for the next 64k looks like. If it doesn't look like random data then there will be a clue there.

    I'm not sure that this applies, given that none of the offsets above checks out.

    Again if I'm following you correctly, it seems the error occurs at a totally random place, so the rclone decryption called by "rclone cat" on the encrypted remote isn't outputting full blocks(?!)

    How can that be?

    Cheers,
    Durval.

  14. ncw commented on Jan 9, 2017

    @ncw
    Member

    Try that with the -q flag - -v writes to stdout by default

    rclone -q cat elo:REDACTED.mp4 | wc -c
    
  15. DurvalMenezes commented on Jan 9, 2017

    @DurvalMenezes
    ContributorAuthor

    Try that with the -q flag - -v writes to stdout by default

    Doesn't seem like a good idea with a subcommand like "cat"... :-) Also, I faintly remember discussing something about rclone in general (not only cat) actually writing error messages and the like to stderr instead of stdout -- guess it hasn't made it into the code yet.

    Anyway, without further ado, here it is:

    rclone -q cat elo:REDACTED.mp4 | wc -c
        2017/01/09 16:08:54 REDACTED.mp4: Failed to send to output: failed to authenticate decrypted block - bad password?
        5177344
    

    And of course now the numbers check out:

    dc
        6 k
    
        5177344 65536 / p
            79.000000
    
        65536 16 + * 32 + p
            5178640.000000
    

    So, if I follow your thinking, the encrypted file was corrupted after exactly 79 blocks, and the interesting block for us will begin at offset 5178640.

    Having an initial look at it:

    dd bs=1 skip=5178640 <4s56ib1p2pjdofn9s4tpveehg8 | hexdump -C | head
        00000000  a7 b2 29 18 cb 9a e4 9f  bd 72 3f 97 20 1c c4 45  |..)......r?. ..E|
        00000010  8b 42 13 68 05 bb b4 6e  6f c0 32 5e ba 93 86 45  |.B.h...no.2^...E|
        00000020  4a db 4d b4 97 10 9e 67  91 fd 26 b5 4c 10 59 8a  |J.M....g..&.L.Y.|
        00000030  57 89 3f a9 d4 9d 9c e7  fe be ce 51 15 22 6f 99  |W.?........Q."o.|
        00000040  6a ff 87 f1 d5 17 d9 5c  55 d1 35 52 7b 11 de c1  |j......\U.5R{...|
        00000050  4a 3a cf 07 53 97 c4 84  36 75 b7 ba 86 9d 87 7d  |J:..S...6u.....}|
        00000060  5b 1c 7a 21 2c 51 eb 7c  b2 76 bd dd d1 ff 1a 13  |[.z!,Q.|.v......|
        00000070  8e 81 7e f7 1e 7e 45 15  ba 3f 25 13 12 a1 e9 16  |..~..~E..?%.....|
        00000080  ca 8d 42 2d 32 be 34 74  29 1e 1b e8 94 f1 c8 95  |..B-2.4t).......|
        00000090  60 be ac 03 a9 1a a5 0b  93 60 de 2b 82 11 84 88  |`........`.+....|    
    

    This looks pretty random to me...

    Checking whether it is really random (ie, the probable result of rclone encryption), by testing the entire 64K block with the venerable ent program:

    dd bs=1 skip=5178640 count=65536 <4s56ib1p2pjdofn9s4tpveehg8 | ent
        65536+0 records in
        65536+0 records out
        65536 bytes (66 kB) copied, 0.0578989 s, 1.1 MB/s
    
    [ent output follows]:
        Entropy = 7.997738 bits per byte.
    
        Optimum compression would reduce the size
        of this 65536 byte file by 0 percent.
    
        Chi square distribution for 65536 samples is 205.09, and randomly
        would exceed this value 99.04 percent of the times.
    
        Arithmetic mean value of data bytes is 127.6990 (127.5 = random).
        Monte Carlo value for Pi is 3.149972533 (error 0.27 percent).
        Serial correlation coefficient is -0.000010 (totally uncorrelated = 0.0).
    

    So it seems to be really random.

    Waiting for your further thoughts/instructions...

    Cheers,
    Durval.

  16. 80 remaining items

  17. ncw commented on Feb 12, 2017

    @ncw
    Member

    I've implemented rclone cryptcheck (see #1102) in this beta which gives an alternative way of checking that a crypt remote is intact.

    http://beta.rclone.org/v1.35-91-g01c747e-cryptcheck/ (uploaded in 15-30 mins)

    Here are the docs


    rclone cryptcheck checks a remote against a crypted remote. This is
    the equivalent of running rclone check, but able to check the
    checksums of the crypted remote.

    For it to work the underlying remote of the cryptedremote must support
    some kind of checksum.

    It works by reading the nonce from each file on the cryptedremote: and
    using that to encrypt each file on the remote:. It then checks the
    checksum of the underlying file on the cryptedremote: against the
    checksum of the file it has just encrypted.

    Use it like this

    rclone cryptcheck /path/to/files encryptedremote:path
    

    You can use it like this also, but that will involve downloading all
    the files in remote:path.

    rclone cryptcheck remote:path encryptedremote:path
    

    After it has run it will log the status of the encryptedremote:.

    Usage:
    rclone cryptcheck remote:path cryptedremote:path [flags]

  18. ncw commented on Feb 14, 2017

    @ncw
    Member

    I'm going to close this now as the underlying issue was fixed by 2abfae2

  19. DurvalMenezes commented on Feb 18, 2017

    @DurvalMenezes
    ContributorAuthor

    Great news, @ncw! Is that fix in the latest beta? I will use it to continue my copying and then will do the md5sum -c on the rclone mount` directory tree and let you know how it goes.

  20. ncw commented on Feb 20, 2017

    @ncw
    Member

    @DurvalMenezes yes that fix is in. Are you copying over the network from a crypted drive? If so that will be the fix.

  21. DurvalMenezes commented on Feb 26, 2017

    @DurvalMenezes
    ContributorAuthor

    Hello @ncw,

    Are you copying over the network from a crypted drive? If so that will be the fix.

    Humrmrmr... right now (and for the last two months), I'm copying from a local filesystem to my encrypted GDrive. But previously I was copying from an encrypted Amazon Cloud Drive to the encrypted Google Drive, and these errors may very well be from that time.

    I will pay attention and report back if I get any errors from files that definitely were copied from the local filesystem instead of from a encrypted remote.

  22. ncw commented on Feb 27, 2017

    @ncw
    Member

    @DurvalMenezes thanks for the confirmation and let me know if you do see any errors that were definitely copied from the local filesystem.

  23. DurvalMenezes commented on Mar 3, 2017

    @DurvalMenezes
    ContributorAuthor

    For what it's worth (I suspect not much right now that @ncw reported fixing the original cause), I just noticed that the latest rclone cat --tail 1 --discard I left running here (with --checkers 4 to avoid being banned) finished (after 18 and a half days -- ouch). The final stats block from the log file was:

    Transferred:   6.261 MBytes (4 Bytes/s)
    Errors:               914
    Checks:                 0
    Transferred:      6797191
    Elapsed time:  422h41m39.3s
    2017/03/01 03:18:19 Go routines at exit 24
    

    So 914 errors in ~6.8M files... too much to check by hand, and as I mentioned above, probably not worth the trouble right now. Also, I suspect quite a few files are missing above (my numbers indicate something more like ~8M files on that remote).

    What I will do is to run a rclone cryptcheck on the largest directory on this remote, and then a recursive md5sum -c and report back here. Please stay tuned ;-)

    If @ncw or anyone wants details on the above rclone cat --tail 1 --discard run, please contact me in the next few days (before I delete the 300MB log file).

    Cheers,
    Durval.

  24. ncw commented on Mar 3, 2017

    @ncw
    Member

    @DurvalMenezes I'd be tempted to grep out the failing files from the log and put them in a form I could pass to --files-from. You could then use the -I flag to unconditionally upload them.

  25. calisro commented on Apr 12, 2017

    @calisro
    Member

    For what it is worth, I just ran this on my google drive remote that I created as a clone of another google drive remote and I had zero errors:

    rclone -v cat --tail 1 --stats 1m --discard zonegd-cryptp:

    no ban either. I'll also run this on the source I created. The source was created with copy/sync from a local share.

    Both remotes are crypted.

    EDIT: oh its marked fixed. :( Thats what I get for reading on my phone!!!

  26. DurvalMenezes commented on Apr 12, 2017

    @DurvalMenezes
    ContributorAuthor

    Folks, I'm sorry for my lack of participation on this issue; I simply haven't had the time, as RL is taking a real toll here in the last few weeks.

    @calisro: can you tell us how many files and GBs were on those remotes?

    Cheers,
    Durval.

  27. calisro commented on Apr 12, 2017

    @calisro
    Member

    Smaller than yours. 3TB with 96,000 files.

  28. calisro commented on Apr 12, 2017

    @calisro
    Member

    Also I use my own client id so I can track my quotas in the API dashboard.

  29. DurvalMenezes commented on Apr 19, 2017

    @DurvalMenezes
    ContributorAuthor

    Hello everyone,

    I've managed to finish (in principle, as "rclone sync" has run to the end and reported no errors both on the last "Errors: " log line, and in its final process exit status (ie, "echo $?" prints a 0) copying an entire, very large local filesystem (my largest so far, with ~8M files totaling ~3.8TB) to Encrypted GDrive.

    Now that rclone sync has finished, I'm doing a "md5sum -c" on an rclone mount of the resulting directory on the encrypted GDrive; it's about 10% done, and so far I've got no errors; this is AFAIK excellent news, as previously (with older versions of rclone, I'm using v1.36 now) it started reporting all sorts of errors way before that point.

    In particular, no "failed to authenticate" errors mean, if I understand things correctly, that either @ncw's original diagnosis (that the errors were caused by remote-to-remote copying) was correct, or that his fix really corrected the root cause of this issue (or possibly both). But anyway, seeing no errors so far makes me a very happy camper! ;-)

    On a side note, I'm seeing output from rclone mount along these lines:
    2017/04/19 03:03:34 REDACTED/REDACTED/REDACTED/REDACTED/REDACTED/REDACTED.mp4: ReadFileHandle.Read error: low level retry 1/100: unexpected EOF

    At this point (a few hundreds of thousands of files checked), I got exactly 16 of these errors; and, none of these errors has resulted in any issues being reported by the "md5sum -c" which is reading these files . So, I think the low level retries on these errors are now actually working (they weren't previously: md5sum reported errors when those things happened).

    So, it seems we have only good news so far; when this md5sum -c has finished (which I estimate will take a couple of days more), I will post an updated report.

    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

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions