element-hq / element-hq/element-web

Reset secure backup does not check existing 4S before deleting key backup

Open
#27,841 6 comments 2 reactions 0 assignees View on GitHub
A-E2EE A-E2EE-Key-Backup O-Uncommon S-Critical T-Defect
Dominant language
TypeScript
Stars
13.5k
Forks
2.8k
PR merge metrics
PR metrics pending

Description

### Steps to reproduce

1. Where are you starting? What can you see?
- Get an account with existing 4S setup
- Open a new web session, enter security key
- Go to security settings and reset the secure storage on this session
- A new key backup is recreated with the version number updated
- There is a possible lost of keys since all keys have not been download. The new key backup will only contain local keys for this session

-> This reset button behavior is different from Android !

### Outcome

#### What did you expect?
Keeping the current key backup if the session already knows the private key of the key backup .
This behavior is the one found on element-android. If 4S is well setup,the key backup is not recreated and the version number not updated. See https://github.com/element-hq/element-android/issues/8814#issuecomment-2196991876

> in fact resets secret storage (which is used to store the backup key), but if backup was working on the client before the reset, the same key backup should continue to work afterwards

In `matrix-js-sdk`, we can see written in the code https://github.com/matrix-org/matrix-js-sdk/blob/6f63ff1711664154359bb1b998a80f4274569468/src/rust-crypto/rust-crypto.ts#L1192 that no check on 4S is done. From the front we always pass the value `setupNewKeyBackup = true` to the method `bootstrapSecretStorage` https://github.com/matrix-org/matrix-js-sdk/blob/6f63ff1711664154359bb1b998a80f4274569468/src/rust-crypto/rust-crypto.ts#L748

This check is important because there are cases where the users can lose their messages. Indeed, since we don't download a full copy of the keys https://github.com/element-hq/element-meta/issues/2446 anymore, we can have a state where the re-creation of the secret backups doesn't contain all the keys.

#### What happened instead?
The key backup is completely reset and recreated, even though there are probably keys from the previous backup have not been fully downloaded.

### Operating system

linux

### Browser information

firefox 128

### URL for webapp

app.element.io

### Application version

1.11.71

### Homeserver

matrix.org

### Will you send logs?

No

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.