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

Element R | After a backup is deleted the sdk keeps trying to download keys from it #26535

Closed
BillCarsonFr opened this issue Nov 9, 2023 · 1 comment · Fixed by matrix-org/matrix-js-sdk#3929
Assignees
Labels
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 Z-Labs

Comments

@BillCarsonFr
Copy link
Member

Step to reproduce

  • You must have several backup version
  • Create a new version n , and ensure that the backup private key is cached locally

=> Delete the backup (maybe from another client). Now the current backup is n-1

Actual

The queryKeyBackup() api (called on fail to decrypt) keeps querying to version n

=> This is because the backup key in cache is still (version:n, privKey: xxx)
https://github.com/matrix-org/matrix-js-sdk/blob/5931a5119c9f792a34ec5c1461da2c939b6326d3/src/rust-crypto/rust-crypto.ts#L202

Legacy is a bit different as the version of the backup is not saved in cache, so it has to check what's the current backup version.

Expected

This is a case of desynchronised cache / 4S, the silver bullet fix should ensure that deleting a backup keeps the "recovery" in a valid state.

  • If you delete a backup the 4S should be updated (remove/clear the m.megolm_backup.v1 account data), update the cache
  • If a client detect that a version is deleted => should clear cache and re-request missing secrets + eventually ask user to enter passphrase to sync with 4S (hoping it has the correct secret)
  • What should we do with mulitple backup version? Is there any reason to maintain several versions? given that on change the private key is probably lost anyhow)
@BillCarsonFr BillCarsonFr added the A-Element-R Issues affecting the port of Element's crypto layer to Rust label Nov 9, 2023
@github-actions github-actions bot added the Z-Labs label Nov 9, 2023
@BillCarsonFr BillCarsonFr added Z-Element-R-Blocker A blocker for enabling Element R by default and removed Z-Labs labels Nov 9, 2023
@github-actions github-actions bot added the Z-Labs label Nov 9, 2023
@richvdh
Copy link
Member

richvdh commented Nov 22, 2023

Apparently, once this happens:

  • BackupManager.activeBackupVersion is set to the previous version (n-1). I think this is what is shown in the UI as "Active backup version".
  • IndexedDB backup_keys.recovery_key_v1 holds the decryption key of the deleted version.
  • IndexedDB backup_keys.backup_key_v1, which (I think) stores the version for the decryption key, contrary to the implication of the name, is set to the deleted version (n).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 Z-Labs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants