Regression: Duplicity will (wrongly) accept a change of encryption password during an incremental backup
I have:
- searched https://gitlab.com/duplicity/duplicity/-/issues for similar issues. If you find a similar issue and the issue is still open, add a comment to the existing issue instead of opening a new one. If you find a Closed issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one.
- searched https://bugs.launchpad.net/duplicity for similar issues. If you find a similar issue, open a new issue on here and include a link to the original issue in the body of your new one.
-
tested that this issue still occurs on the latest stable snap (install instructions: https://snapcraft.io/duplicity), please include the snap version (
snap info duplicity | grep installed
) output:installed: x.xx.xx (xx)
-
ideally, tested that this issue still occurs on the latest edge snap, if you can test without risking your data. Please include the snap version output:
installed: x.xx.xx (xx)
Summary
This is an old bug rearing its head again in at least 0.8.23 and it changed a little further with 1.0.0.
There are two (maybe related) symptoms:
- You can switch the encryption password mid-incremental chain, with no complaint at all from duplicity.
- You can attempt to restore files with the wrong password and duplicity won't complain, it will just say there are no files to restore.
Environment
Ubuntu 22.04, tested on duplicity 0.8.23 and 1.0.0
Bug: allows change of password mid-incremental with cache in 0.8.23
pip install duplicity==0.8.23
rm -rf /tmp/backup ~/.cache/duplicity/
PASSPHRASE=correct duplicity full ~/.profile file:///tmp/backup
PASSPHRASE=wrong duplicity inc ~/.profile file:///tmp/backup
Gives output:
Local and Remote metadata are synchronized, no sync needed.
Last full backup date: Sun Oct 2 10:32:30 2022
Error processing remote manifest (duplicity-full.20221002T143230Z.manifest.gpg): GPG Failed, see log below:
===== Begin GnuPG log =====
gpg: AES256.CFB encrypted data
gpg: encrypted with 1 passphrase
gpg: decryption failed: Bad session key
===== End GnuPG log =====
--------------[ Backup Statistics ]--------------
[snip...]
-------------------------------------------------
This should fail with an error. And it does print one. But then continues anyway. This is a regression of an old bug from 2018, but I don't know when it started regressing (possibly before 0.8.23)
Correct: prevents change of password mid-incremental without cache in 0.8.23
pip install duplicity==0.8.23
rm -rf /tmp/backup ~/.cache/duplicity/
PASSPHRASE=correct duplicity full ~/.profile file:///tmp/backup
rm -r ~/.cache/duplicity/
PASSPHRASE=wrong duplicity inc ~/.profile file:///tmp/backup
Gives output:
Synchronizing remote metadata to local cache...
Copying duplicity-full-signatures.20221002T143708Z.sigtar.gpg to local cache.
GPGError: GPG Failed, see log below:
===== Begin GnuPG log =====
gpg: AES256.CFB encrypted data
gpg: encrypted with 1 passphrase
gpg: decryption failed: Bad session key
===== End GnuPG log =====
Which is correct and expected behavior! Nice.
Correct: tells you it can't restore with wrong password in 0.8.23
pip install duplicity==0.8.23
rm -rf /tmp/backup /tmp/restored ~/.cache/duplicity/
PASSPHRASE=correct duplicity full ~/.profile file:///tmp/backup
PASSPHRASE=wrong duplicity restore file:///tmp/backup /tmp/restored
Gives output:
Local and Remote metadata are synchronized, no sync needed.
Last full backup date: Sun Oct 2 10:47:15 2022
GPGError: GPG Failed, see log below:
===== Begin GnuPG log =====
gpg: AES256.CFB encrypted data
gpg: encrypted with 1 passphrase
gpg: decryption failed: Bad session key
===== End GnuPG log =====
That's what I would expect!
Kind-of-correct: prevents change of password mid-incremental with cache in 1.0.0
pip install duplicity==1.0.0
rm -rf /tmp/backup ~/.cache/duplicity/
PASSPHRASE=correct duplicity full ~/.profile file:///tmp/backup
PASSPHRASE=wrong duplicity inc ~/.profile file:///tmp/backup
Gives output:
Local and Remote metadata are synchronized, no sync needed.
Last full backup date: Sun Oct 2 10:41:55 2022
Manifests not equal because different volume numbers
Fatal Error: Remote manifest does not match local one. Either the remote backup set or the local archive directory has been corrupted.
So this got better in 1.0.0! Duplicity prevents the buggy behavior, though it does not give the correct reason -- it should indicate the password was wrong, so the user knows why they are seeing this issue. (And a downstream app like Deja Dup can know what's happening)
Bug: allows change of password mid-incremental without cache in 1.0.0
pip install duplicity==1.0.0
rm -rf /tmp/backup ~/.cache/duplicity/
PASSPHRASE=correct duplicity full ~/.profile file:///tmp/backup
rm -r ~/.cache/duplicity/
PASSPHRASE=wrong duplicity inc ~/.profile file:///tmp/backup
Gives output:
Synchronizing remote metadata to local cache...
Copying duplicity-full-signatures.20221002T144446Z.sigtar.gpg to local cache.
Copying duplicity-full.20221002T144446Z.manifest.gpg to local cache.
Last full backup date: Sun Oct 2 10:44:46 2022
--------------[ Backup Statistics ]--------------
[snip...]
-------------------------------------------------
Unlike 0.8.23, it doesn't even print a warning anymore. Just makes a new incremental with a different password.
Bug: tells you there are no files in backup when restoring with wrong password in 1.0.0
pip install duplicity==1.0.0
rm -rf /tmp/backup /tmp/restored ~/.cache/duplicity/
PASSPHRASE=correct duplicity full ~/.profile file:///tmp/backup
PASSPHRASE=wrong duplicity restore file:///tmp/backup /tmp/restored
Gives output:
Local and Remote metadata are synchronized, no sync needed.
Last full backup date: Sun Oct 2 10:48:15 2022
No files found in archive - nothing restored.
That's confusing for the user (and harder for a downstream app like Deja Dup to detect what's happening).