JackGruber / joplin-plugin-backup

A plugin to extend Joplin with a manual and automatic backup function.
MIT License
209 stars 19 forks source link

Encrypted backups can't be decrypted, when password contains certain special characters #53

Open kevinbbbb opened 1 year ago

kevinbbbb commented 1 year ago

Edit: I am currently using Version 1.20 of the extension. I am currently not able to update so can't confirm whether this was fixed.

I am doing encrypted backups with your extension. Unfortunately, when I tried to access a backup file (.7z archive, which is password-protected) I was not able to although the password was 100% correct. I tried unpacking with WinRAR and 7-Zip. Both failed for the 5 backups I had from the last five days. If I understand the errors of WinRAR and 7-Zip correctly, either the password is not correct or the file is damaged.

I don't know if the files are damaged. If they are, then this must be inflicted by a password containing certain symbols (see later). I definitely used the correct password (I checked it in the Joplin settings, where you can configure the password for the backups).

The password I used for the encryption was: VCe`,=/P<_+.7]~;Ys("

When I changed my password to a 'simpler' one, it worked. I tried the following: AAAA

With AAAA, 7-Zip had no problem decrypting the backup file. So in conclusion, I suspect that the special characters (or at least some of them) hinder the process at some point. Maybe it damages the file or certain characters are simply not allowed in passwords for .7z files (but I am not an expert on that).

Side note: luckily I could restore my notes from the 'trash can' of my cloud.

For completeness:

WinRAR told me: ! C:\Users\hp\AppData\Roaming\Joplin\Backup\202306291517\all_notebooks.jex.7z: Prüfsummenfehler der verschlüsselten Datei C:\Users\hp\AppData\Roaming\Joplin\Backup\202306291517\all_notebooks.jex.7z. Beschädigte Datei oder falsches Passwort.

7-Zip told me: C:\Users\hp\AppData\Roaming\Joplin\Backup\202306251526\all_notebooks.jex.7z Das verschlüsselte Archiv "" kann nicht geöffnet werden. Falsches Passwort? Headers-Fehler

JackGruber commented 1 year ago

I'm currently away on holiday, but will have a look at this over the next few weeks.

JackGruber commented 1 year ago

Problem is the " in the password, but only on direct Joplin calls in the integration test " is working.

JackGruber commented 1 year ago

Tested password VCe`,=/P<_+.7]~;Ys("

Zip With Open With Status
Joplin 7z Gui Error
Joplin 7z cli *1 OK
Joplin 7z cli *2 Error
integration test integration test OK
integration test 7z cli *1 OK
integration test 7z cli *2 Error
integration test 7z Gui Error
7z Gui 7z Gui OK
7z Gui 7z cli *1 Error
7z Gui 7z cli *2 OK

7z cli 1: 7za.exe l "file.7z" "-pVCe`,=/P<_+.7]~;Ys(\"" -y -bb3 7z cli 2: 7za.exe l "file.7z" -y -bb3 (password prompt)

The problem seems to be the escaping of " from the module node-7z. Executed CLI from node-7z is 7za.exe a file.7z file.txt -mx0 -mhe "-pVCe`,=/P<_+.7]~;Ys(\"" -y -bb3

JackGruber commented 1 year ago

Opened https://github.com/quentinrossetti/node-7z/issues/132

JackGruber commented 1 year ago

Add workaround e9e361d (Passwords with " are not use for encryption)

gshiba commented 8 months ago

Thanks for this plugin -- saved me from a corrupt sync that wiped all tags.

I also couldn't unarchive using the built-in "/System/Library/CoreServices/Applications/Archive Utility.app". My password contained an asterisk (*), something like MyPassword*123. MacOS 13.5.2, Simple Backup 1.0.5.

I was able to unarchive with:

$ brew install p7zip
$ 7zz x path/to/backup.jex.7z '-pMyPassword*123'
JackGruber commented 8 months ago

I cannot reproduce this under windows. The * in passwords works fine there and I can open the file with the 7-zip gui and cli.