element-hq / element-hq/synapse
Calculation to determine whether a new key should replace an old key in the backup is incorrect
Open
A-E2EE
O-Uncommon
S-Major
T-Defect
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#13704](https://github.com/matrix-org/synapse/issues/13704).
---
https://github.com/matrix-org/synapse/blob/044900af6cc441d700d171098812786b4b312f59/synapse/handlers/e2e_room_keys.py#L300-L310
Specifically, given the above flow, if the new key has a worse (larger) `first_message_index`, and can thus decrypt a smaller number of messages, we will still overwrite the old key if the new key has a lesser `forwarded_count`. This could in some (probably rare) situations lead to data loss.
Contributor guide
Assessment
This issue has not been assessed yet.