Skip to content

Expected UTDs: Hide UTDs for messages sent while you were not in the room ("Pre-join UTDs") #2317

@BillCarsonFr

Description

@BillCarsonFr

Problem

Sometimes, a client will receive messages that were sent before they were a member of the room. This can happen for a number of reasons:

  • They were invited to the room when the message was sent but not yet a member.
  • The message was sent "at the same time" as they joined (there was a fork in the DAG).
  • The room permissions allow seeing historical messages, so the server sent the message without checking membership.

In this situation, sometimes the receiving client will be unable to decrypt (UTD) the message because it does not have the room key needed (because no-one sent it when they send the message, because they didn't know this user needed it).

We want to make it clear why this UTD happened, because in many circumstances it is expected, and not an error.

(Note: this is different from UTDs where someone was a member, but the message was not encrypted for this device. That is tracked under #2313.)

Solution

To be able to identify this type of message and inform the user appropriately, we need to know whether the user was a member of the room when the message event was created.

The server is well-placed to know this because it has access to the DAG, whereas the client does not.

So we propose to write and implement MSC4115, allowing the server to annotate events with information about their membership of the room at the time the event was created.

Work to do

Spec:

Synapse:

matrix-rust-sdk:

matrix-analytics-events

Element X Android:

Element X iOS:

Element Web/matrix-js-sdk:

(We expect to implement this a little later in Web.)

Notes

Further work

This is a partial solution: there is still a race on the sender side. That has solutions discussed at #2268.

We might also want to consider preventing setting history_visibility: shared on encrypted rooms, which would stop the server sending us the events in the first place.

Previous attempts to hide these UTDs

Element Web attempted to hide these UTDs in the past: matrix-org/matrix-react-sdk#3881 but various problems with this approach have been identified e.g. element-hq/element-web#22671 .

Sharing room history, MSC3061

MSC3061 Share room keys for past messages allows providing keys to people who are allowed to decrypt messages, even if they were not a member when they were created.

If/when this is implemented, it will allow decrypting this type of UTD later. But:

  • It is not implemented in Element Clients (the move to Rust crypto removed it from Element Web), and
  • These UTDs would likely still exist briefly even if the keys were on their way

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions