element-hq / element-hq/dendrite

Cannot decrypt messages on a second client even with cross-signing

Open
#2,471 7 comments 0 reactions 0 assignees View on GitHub
F-E2EE T-Defect
Dominant language
Go
Stars
965
Forks
101
PR merge metrics
No merged PRs in 30d

Description

*This issue was originally created by [**@GregSutcliffe**](https://github.com/GregSutcliffe) at .*

### Background information

- **Dendrite version or git SHA**: 0.8.5
- **Monolith or Polylith?**: Monolith
- **SQLite3 or Postgres?**: PSQL
- **Running in Docker?**: No
- **`go version`**: 1.17.9 linux/arm64
- **Client used (if applicable)**: SchildiChat (client A) & app.element.io (client B)

### Description

- **What** is the problem: Messages from client A are not readable on Client B and vice-versa. Clients are cross-signed and session IDs appear in the session list.
- **Who** is affected: My own user account on my own Dendrite server
- **How** is this bug manifesting: Messages viewed on the other client. return `** Unable to decrypt: The secure channel with the sender was corrupted. Trying to create a new secure channel and re-requesting the keys. **`
- **When** did this first appear: Hard to say - my server has been upgraded over time since first deployed in 0.6.0, and encryption has been improved several times, plus I've been confusing it with #2404. So, this may be a leftover from earlier migrations, or perhaps
related to #2436.

### Steps to reproduce

I'm assuming there is something weird in my account state, so I expect this will not reproduce for others, but this is consistent for me:

- create a room with my Dendrite account
- clear cache on both clients
- post message 1 from client A
- post message 2 from client B
- Client A will fail to decrypt message 2
- Client B will fail to decrypt message 1

### Screenshots:

Sessions on Client A:

Sessions on Client B:
![image](https://user-images.githubusercontent.com/827786/168905170-571f3131-cbac-4d89-9419-0a184fc37c81.png)

So, both are present, and I can confirm the session IDs match. How the chat looks:
![image](https://user-images.githubusercontent.com/827786/168905872-867393e8-80c8-4be7-932e-ee479ab3a408.png)

Looking in the logs, I do see this:
```
time="2022-05-17T20:43:32.701254278Z" level=error msg="failed to query device keys for some users" func="github.com/matrix-org/dendrite/keyserver/internal.(*DeviceListUpdater).processServer" file="github.com/matrix-org/dendrite/keyserver/internal/device_list_update.go:430" context=missing failed=1 server_name=ergaster.org total=1 wait=1h0m0s
```

Contributor guide

Open the contributing guide

Research direction

Start with the logged failure in keyserver/internal/device_list_update.go:430 and trace the device-key query and update path. Reproduce with two cross-signed clients using the listed steps, then inspect how the affected account's device and session keys are handled. Done means messages sent from either client decrypt correctly on the other.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgres
Domain
backend, databases, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.