element-hq / element-hq/element-web

After reloading, my own failed-to-send message is UTD

Open
#27,334 4 comments 2 reactions 0 assignees View on GitHub
A-E2EE A-Element-R O-Occasional S-Major Z-UISI
Dominant language
TypeScript
Stars
13.5k
Forks
2.8k
PR merge metrics
PR metrics pending

Description

See rageshake https://github.com/matrix-org/element-web-rageshakes/issues/25454 (cc @bnjbvr )

It is possible to get a UTD (Unable To Decrypt) for your own message by following these steps.

* Send an encrypted message that fails to send
* Refresh Element Web
* Observe that the message in your timeline is UTD, even if it then successfully sends

Here is what we think is happening:

* JS wants to send an event
* JS asks Rust to encrypt the event, which works and the megolm session is saved by Rust
* JS tries to PUT the event to the homeserver but fails
* User refreshes
* JS has the event pending to send but with no ID because it hasn't sent. It uses a "fake" ID based on the transaction ID it chose for the PUT request
* JS asks Rust to decrypt the event so it can display it
* Rust refuses because the event ID is incorrect.

The Rust returns an error like:

```
DecryptionError[msg: leading sigil is incorrect or missing at line 1 column 63
```

Because the JS is providing event JSON containing an event ID that does not begin with `$`.

Possible fixes:

1. Change the "fake"/temporary ID the JS uses for events that failed to send. We don't know whether this will have impact on other code - maybe some code somewhere uses the lack of a `$` to infer that this event failed to send? Or
2. Check the event ID just before we send the event JSON to rust and add some fixed prefix e.g. `$TRANS-` to make the ID acceptable to the Rust code.
3. Change the Rust to accept non-$-prefixed IDs, but this doesn't seem a good idea, since it is correct to expect event IDs to start with `$`.

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.