element-hq / riot-android

A glossy Matrix collaboration client for Android
Apache License 2.0
1.4k stars 394 forks source link

Unable to decrypt messages after restoring key from backup #3139

Open fearedbliss opened 5 years ago

fearedbliss commented 5 years ago

Hey,

I've been using Riot/Matrix again for a weeks with my girlfriend and basically what I did in the beginning was to first backup the generated keys to the back up server (Set a passphrase and all of that), then I made a room and enabled encryption, and sent a few messages. After that I also tested that if I log out of the mobile and web client, and then log in again and restore the same key from backup, that I was able to re-read/decrypt those messages. All of this worked fine. Fast forward a few weeks, there is a new update (Old Riot.Im 0.8 -> Riot.im 0.9) and I went ahead and did the upgrade, all went well, I opened the app and I restored from backup (There were some messages that came in that were in transit, so these actually got encrypted with the new key that was generated after I opened the new app but while I was going into the settings to restore the backed up key.. So I basically lost these messages after the old key was restored). Anyways, after I restored the backed up key (Which I had originally tested as stated in the beginning of the paragraph), All of my previous messages were unable to be decrypted. I'm not sure how it's possible for that to happen given what I stated of backing up the key right at the beginning when the key was first generated a few weeks ago, and every message sent in the E2E room was using that key from my side). I don't care if the messages would be lost in general but it's frustrating that I did lose them given the testing I did and the expectation that if things are done correctly, the messages would be restored. It's hard to recommend Matrix under these situations (There are a few other issues which I've posted in another bug report related to message notification problems). Regardless, I wanted to post here to let everyone know about this.

fearedbliss commented 5 years ago

I think the problem might have been the workflow and misunderstanding of how Matrix does things. Apparently what might have happened was that when I first set up the keys, I did did it on my desktop client (and then I sent a few messages) and enabled key backup. After that I logged into my mobile phone, which then prompted my desktop for key verification ("and if I wanted to let my mobile device read the messages" - not exactly phrased like that), I said yes to this, and this unlocked my mobile device to view the history of previous encrypted messages that were sent from the desktop. After this I just kept using the phone for a few weeks as normal thinking that the original keys backed up would be the same keys used for all devices, thus there was no need for me to attempt to backup the keys again from my mobile device. The mobile app did complain key backup wasn't enabled, but this was confusing since I had already backed up the keys from the desktop and I assumed they were all the same. Thus, once the riot upgrade kicked in, the I uninstalled which the deleted the mobile device's unsaved keys and then when I logged back in that's I realized that something went wrong.

Some suggestions I would improve is really better clarification I think.

Currently the "Restore from Backup" button is a little misleading and tricky since if a person has already have keys saved and they go on a new device, they might not want to click "restore from backup" because it almost seems as that would replace the current keys that the device has which may lead to data loss. This will make people hesitate and not want to "Restore from Backup". What the button actually seems to be doing is "Restoring the missing keys from backup, and adding your current device's keys to the keychain" as well, so it's more of a Sync operation rather than a "Restore the backup and overwrite local keys".

The second suggestion would be during the initial prompt that comes up where you can authorize a new device to read those messages. Currently a person might think that authorizing a device will automatically mean not only that they can read the history, but that now since they can read the history, that all new messages sent from that device will be re-readable on either that device or others (Which is why the app still complained that my keys for that device weren't backed up even though they actually weren't). A better clarification that authorizing a device only allows read history and that user's should still back up the keys for each device they plan on using permanently should be backed up, would be on the more correct path to clarity.

I felt like I had some other suggestions related to the workflows and messaging for the user to safely understand what is happening with the keys and all of that, but I can't remember at the moment.