matrix-org / matrix-org/matrix-rust-sdk
Megolm session retrieved from backup incorrectly marked as insecure
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 2.3k
- Forks
- 500
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 106
Description
I gave up trying to reproduce this, either on EX or EW, though I can't see any particular reason it wouldn't happen on either. I think it requires a large enough room that the affected user isn't one of the room heroes, or something.
1. Observe a message for which we lack the keys, and for whose sender we lack device details.
2. Receive a megolm key from key backup. SenderData is marked as `UnknownDevice { legacy_session: true, owner_check_failed: false }`
3. Receive a keys/query update for the sending user. We call `update_sender_data_for_sessions_for_device`, which calls `SenderDataFinder::have_device`, which replaces the SenderData for imported sessions with `SenderData::UnknownDevice { legacy_session: false, owner_check_failed: true }`.
4. Since we now have `legacy_session: false`, the message is hidden when "hide messages from insecure devices" is enabled.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with SenderDataFinder::have_device and its caller update_sender_data_for_sessions_for_device, then trace how key-backup imports set SenderData. Reproduce the sequence described in the issue and verify that a retrieved Megolm session keeps the correct security status after the keys/query update, including when insecure-device hiding is enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100