-
Notifications
You must be signed in to change notification settings - Fork 17
Description
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:
-
Write MSC4115 - https://github.com/element-hq/crypto-internal/issues/223
- https://github.com/element-hq/crypto-internal/issues/280
- https://github.com/element-hq/crypto-internal/issues/205
Synapse:
matrix-rust-sdk:
- https://github.com/element-hq/crypto-internal/issues/224:
- Parse the
membershipinfo from withinunsigned - Write logic to understand the type of UTD we are dealing with based on #201
- Expose the type of UTD via FFI
- Provide the same information through the reporting hook for UTDs
- Parse the
matrix-analytics-events
- Update schema to account for the new reporting code Add a new Expected UTD cause for membership matrix-org/matrix-analytics-events#102
Element X Android:
- Change the wording of a UTD based on the type provided by rust https://github.com/element-hq/crypto-internal/issues/220
- Provide the type of UTD in reporting to Posthog https://github.com/element-hq/crypto-internal/issues/222
Element X iOS:
- Change the wording of a UTD based on the type provided by rust https://github.com/element-hq/crypto-internal/issues/219
- Provide the type of UTD in reporting to Posthog https://github.com/element-hq/crypto-internal/issues/221
Element Web/matrix-js-sdk:
(We expect to implement this a little later in Web.)
- Parse the
membershipinfo from withinunsigned: https://github.com/element-hq/crypto-internal/issues/201 - Write logic to understand the type of UTD: https://github.com/element-hq/crypto-internal/issues/201
- Change the wording of a UTD based on the type found: https://github.com/element-hq/crypto-internal/issues/202
- Provide the type of UTD in reporting to Posthog: https://github.com/element-hq/crypto-internal/issues/202
- https://github.com/element-hq/crypto-internal/issues/203
- https://github.com/element-hq/crypto-internal/issues/204
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