Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ElementR | Missing validation when migrating the cached backup decryption key from legacy to rust #27324

Closed
BillCarsonFr opened this issue Apr 11, 2024 · 0 comments · Fixed by matrix-org/matrix-js-sdk#4114
Assignees
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

Comments

@BillCarsonFr
Copy link
Member

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:

  • Fetch the latest backup info
  • Check that the cached key matches the backup info
  • Then migrate it
@BillCarsonFr BillCarsonFr added A-Element-R Issues affecting the port of Element's crypto layer to Rust A-E2EE-Key-Backup Z-Element-R-Blocker A blocker for enabling Element R by default labels Apr 11, 2024
@BillCarsonFr BillCarsonFr changed the title ElementR | Missing validation when migrating the backup decryption cache from legacy to rust ElementR | Missing validation when migrating the cached backup decryption key from legacy to rust Apr 11, 2024
@BillCarsonFr BillCarsonFr self-assigned this Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant