jstaf / onedriver

A native Linux filesystem for Microsoft OneDrive
GNU General Public License v3.0
1.92k stars 96 forks source link

KeepassXC files corrupted on save #217

Open wilkolazki opened 2 years ago

wilkolazki commented 2 years ago

I am using keepassxc to store some passowords. Recently I have moved my password file to onedrive using onedriver. I noticed two problems:

  1. The time to save password database is much longer when using onedriver mounted directory. That is minor inconvinience.
  2. The password file sometimes gets corrupted and the corrupted version is actually uploaded to cloud. That is a major problem, as the last changes are lost. So let's say I have created a new random password to some service and was pretty sure that it was safely saved in my onedrive account. I get back to work next day and the password database is corrupted. Keepass says the database internal header size is incorrect. The good news is that there is usually backup passwords.old.kbdx file, the bad news is that the .old never contains the last change made to the password database.

This issue never occurred to me before moving the password file to onedriver mounted directory, so I assume it is on onedriver's side. It just happened second time after migration, and I am using onedriver for just two weeks.

What should I provide to help resolve the issue?

jstaf commented 2 years ago

For 1 - yes that's expected. You have to wait for the file to be fully uploaded over the network.

For 2, what version of onedriver are you using? And what does the corrupted file look like? Is it 0 bytes/an empty file? This sounds like a problem that was present in a very old build of onedriver but has since been fixed.

wpoely86 commented 2 years ago

I'm using the https://github.com/abraunegg/onedrive/ client for onedrive and storing a Keepass DB on onedrive is weird.

I've also seen corruption happen at random. Pretty sure it's not the client that is to blame here.

wilkolazki commented 2 years ago

For 2, what version of onedriver are you using?

$ onedriver --version
onedriver v0.12.0 73d93207

And what does the corrupted file look like? Is it 0 bytes/an empty file?

$ ls -al working-backup.kdbx broken.kdbx 
-rw-rw-r-- 1 sw sw 16355 gru  2 11:37 broken.kdbx
-rw-rw-r-- 1 sw sw 16599 gru 16 14:26 working-backup.kdbx
$ file broken.kdbx 
broken.kdbx: Keepass password database 2.x KDBX

The file is a binary file. KeepassXC tries to open it and complains only after correct password is entered to unlock it. I have tried to compare the binary content of the broken file with older working backup (which is missing one or two password entries). They differ but not much. Especially first few hundred bytes are excalty the same, then there is some differences, followed by some more sequences of dientical and differing bytes. The last 1/3 of the files differs totally and the working backup is actually 244 bytes longer, while definitely missing one or two entries I have stored in keepass file before got broken.

This sounds like a problem that was present in a very old build of onedriver but has since been fixed. I have installed onedriver via software.opensuse.org, choosing Ubuntu and add repository and install manually option. When I try to update onedriver using apt, I get following info:

$ sudo apt install onedriver
[...]
onedriver is already the newest version (0.12.0-1).
jstaf commented 2 years ago

Ok, that's the latest version. Different corruption (if onedriver is causing it) than what was happening before - I'll take a look.

joeldeteves commented 1 year ago

Honestly storing Keepass databases on OneDrive is 1) dangerous (we're talking about your passwords here) and 2) super janky (syncing the databses between devices?)

You should try Bitwarden which is a FOSS password storage solution that will work on any device.

pmoris commented 1 year ago

I just ran into the same error. For what it's worth, in my case the online version of the file on OneDrive was still fine, only the local onedriver copy became corrupted.

After removing the account from onedriver and re-adding it (to a new mount point, if that matters), the file was working properly again.

Anything I can check or try out to help troubleshoot this issue?

Additionally, when does onedriver push local changes back to the cloud? The readme states that files are only downloaded when you try to open them, but I assume there is also a process that monitors when new online files appear + when local changes are made?


You should try Bitwarden which is a FOSS password storage solution that will work on any device.

In my case, I'm not too keen on trusting an external party to host my passwords, especially considering all the leaks that have occurred for many of those all-in-one commercial solutions in the past. I much prefer using a locally managed open-source tool like keepass that I can sync myself if need be. For personal use, I rely on SyncThing (direct network sync, not cloud), but for my work machine running Windows, I'm tied to OneDrive.