element-hq / element-hq/synapse

Handle state pulled in via backfill more robustly

Open
#10,794 0 comments 0 reactions 0 assignees View on GitHub
A-Messages-Endpoint O-Uncommon S-Tolerable T-Enhancement
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#10794](https://github.com/matrix-org/synapse/issues/10794).

---

Synapse goes to great lengths to ensure that malicious servers cannot replace the current state of the room by sending an event `E` that points to all existing forward extremities plus a fake event that the server refuses to divulge. Naively, the server would ask for the state at `E`, which would then become the current state as `E` is the new forward extremity, instead Synapse rejects the event if the server refuses to divulge any of `E`'s prev events. This ensures that the new current state cannot be replaced by malicious servers (without it being resolved against some existing state the server already has).

Currently, this logic only applies to newly received events, rather than events that come in via backfill. However, the same attack could be done via backfill in the same way. Thankfully, Synapse currently does not replace forwards extremities when events come in via backfill so Synapse isn't vulnerable to the attack, but that is very tenuous protection and we should add more explicit checks and protections.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.