cryptee / web-client

Cryptee's web client source code for all platforms.
https://crypt.ee
Other
449 stars 23 forks source link

[Change] Include details when offline doc fails to decrypt #75

Closed dhda closed 3 years ago

dhda commented 4 years ago

Is your feature request related to a problem? Please describe. I just got the "Offline doc failed to decrypt. Removing for safety." message. I assume this is safe but only in the case where the server version of the document matches the offline version. As a user, it scares me that Cryptee could potentially delete modifications that only exist offline without any input from me.

Describe the solution you'd like I'd like the error message to, at a minimum, include the names of the documents that failed to decrypt and were deleted. I'd also like to understand the reasons that the decryption failed (especially when everything else in my account decrypted fine). If it's stale local state that's one thing, but if the offline encrypted data got corrupted somehow that's something I'd like to know about.

Additional context My best guess is that the failure is related to the fact that I hadn't reloaded the Cryptee tab for a long time.

johnozbay commented 4 years ago

Thanks a lot for filing this!

Your guess is actually fantastically correct. If you leave your tab open for a long time, this message could be triggered accidentally while sync'ing offline documents. I'll make sure we build in better messaging for this, so that it's clear what's going on.

To further elaborate : Your guesses are spot on. It could happen in multiple scenarios:

1) It can happen with stale offline documents while sync'ing

2) It can happen if you change your key on one device (but left the other device on for a long period of time, and next time you open it, the new key won't work with your offline docs which haven't sync'ed since the key change etc) – to address this the system actually decrypts & re-encrypts offline docs whenever it can. (i.e. when network allows it to)

3) It could also theoretically happen if you haven't reloaded Cryptee's tab for a long periods of time, didn't put your computer to sleep either, but left Cryptee as-is. At some point, the key-timeout would wipe your key from memory. By this point all your offline docs are already sync'ed and safe. – At some point in the future device loses network – re-gains network, loses network again. Cryptee tries to sync things up/down, but since there's still no network. It saves the error into our offline errors storage (we have an offline error storage, where it stores some issues, and tries to address them when network comes back again) – then when you reload the tab / open Cryptee again with network, Cryptee pulls up the offline errors, and displays this outdated error. (It's technically no longer relevant anymore, but since it happened while the device was offline, it gets displayed when you go back online)

4) It could also theoretically happen on iOS devices, depending on whether if Cryptee's installed as a PWA or not, after data-eviction. In short, starting iOS 13 – Apple started wiping all data in localStorage & indexedDB after 7 days to prevent tracking, with no prompts or warnings. This doesn't apply to PWAs [thankfully].

But because of this, say for example if you had some docs saved offline, and use Cryptee only in your browser (as some folks may do on their iPads the same way they use Google Docs) then depending on how iOS evicts the data, it may wipe an offline doc - and it could result in this error. I've just checked with the helpdesk folks, and we haven't heard from anyone who had this issue yet, but there's a non-zero chance & possibility it may happen.


We'll update this error message so that if something fails while sync'ing offline docs : – If it errors out due to an outdated network loss after a long timeout – this error won't be displayed, – similarly, we'll make sure it won't be displayed if it's due to a stale doc – but will only be displayed in case of key-related issues, like changing key on one device etc. and will be a more specific error with a list of what worked and what failed.

I can at least confidently say that, in the before times – when humans could still fly around, and covid wasn't a thing ✨ – I flew around quite often, and depended on the offline mode rather heavily on various different devices, and even after 3 years of using offline-mode intensely flying around, so far I never had any issues where the system wiped something it wasn't supposed to causing data loss.

My best guess is the same as yours, and we'll update the messaging to make it less scary and clear what actually happens there.

Thanks again for filing this! Deeply appreciated! ✌🏻

johnozbay commented 3 years ago

Hi there!

Today we've released Cryptee v3.0 ( 01edfe4 ) and it's a complete re-write of the application. It has an entirely new way of dealing with your documents catalog (i.e. all document / folder names are always available even while you're offline) and offline documents handling is now a lot more reliable with more specific errors.

Give it a try and let me know what you think! But for now I'll close this issue since we've completely rewritten the application and I think managed to fix this.

Thanks again for this! ✌🏻