ElementR | Missing validation when migrating the cached backup decryption key from legacy to rust #27324
Labels
A-E2EE-Key-Backup
A-Element-R
Issues affecting the port of Element's crypto layer to Rust
Z-Element-R-Blocker
A blocker for enabling Element R by default
Problem
In legacy, the backup decryption key was just saved in the local database, whereas in rust a tuple of (version, key) is saved.
This pauses a problem when migrating because we cannot just copy the cached key to rust, we need to first get the backup version:
https://github.com/matrix-org/matrix-js-sdk/blob/82ed7bd86ae4c8c703f886a490573110035cfe34/src/rust-crypto/libolm_migration.ts#L170
The current migration is just fetching the current backup to get the version and use it to migrate to rust.
The problem is that the backup version could have changed since the last time the current session (the one that will do the migration) was last opened.
In that case the current migration code will migrate a deprecated decryption key and associate it to the latest backup version.
The migrated version will then wrongly think it has the correct decryption key, and will fail to decrypt the keys downloaded from backup.
Solution
We should add some validation when doing the migration:
The text was updated successfully, but these errors were encountered: