matrix-org / matrix-org/matrix-rust-sdk

Olm sessions are vulnerable to wedging on OS crash or power failure, leading to UTDs

Open
#3,354 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.3k
Forks
500
Avg merge
1d 16h
Merged PRs (30d)
106

Description

Consider:

- Alice and Bob have an active Olm session.
- Alice is using a client which uses the indexeddb backend of matrix-crypto-sdk. She wants to send a new Olm message, so she generates a new Olm ratchet key and updates the session. She can then encrypt the new message, and stores the updated session in the database
- Alice sends the message.
- Alice's computer crashes.
- Alice reboots
- If the updated session was not correctly persisted before the crash, this Olm session is now wedged: Alice cannot decrypt any replies from Bob, and, because Alice will use the wrong ratchet key in the next sender chain, Bob will be unable to decrypt any further messages from Alice.

Currently, we use the "default" durability mode of IndexedDB, which [can lead to data loss](https://developer.chrome.com/blog/indexeddb-durability-mode-now-defaults-to-relaxed). We should instead use "strict", at least for transactions which update Olm sessions.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the IndexedDB backend in matrix-crypto-sdk and the transactions that update Olm sessions. Trace how durability is configured, then verify that the relevant session-update transactions use strict durability and test the persistence behavior across an interrupted write.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cryptography, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.