Fix history in depth bombed rooms - #20157
Open
catfromplan9 wants to merge 1 commit into
Open
Conversation
In depth bombed rooms (GHSA-v56r-hwv5-mxg6) on room version 6 and above, the server returned everything sent since the attack in the order it received it, not the order it was sent. Federation lag and backfill made those two orders differ, so pagination could jump back months mid-scroll. Rooms on versions 1 to 5, which element-hq#18447 skipped, were worse off. There the attack-era events permanently sorted as the newest in the room, and everything sent since sorted as older than them. The cause in both cases was `topological_ordering`. Every event created since the attack carried a depth capped at `MAX_DEPTH`, so the affected stretch of the room collapsed onto one ordering value, and on old room versions it also sat below the uncapped attack events. This adds a background update that re-spreads all events at or above `MAX_DEPTH` across the unused ordering range above the room's highest real depth, ranked by `origin_server_ts`. Event persistence now stores a new at-cap event just above the room's current maximum, which keeps a repaired room repaired. `topological_ordering` is local to each server, so nothing changes over federation. Signed-off-by: cat <cat@plan9.rocks>
catfromplan9
requested review from
erikjohnston
and removed request for
a team
August 27, 2026 14:36
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In depth bombed rooms (GHSA-v56r-hwv5-mxg6) on room version 6 and above, the server returned everything sent since the attack in the order it received it, not the order it was sent. Federation lag and backfill made those two orders differ, so pagination could jump back months mid-scroll. Rooms on versions 1 to 5, which #18447 skipped, were worse off. There the attack-era events permanently sorted as the newest in the room, and everything sent since sorted as older than them.
The cause in both cases was
topological_ordering. Every event created since the attack carried a depth capped atMAX_DEPTH, so the affected stretch of the room collapsed onto one ordering value, and on old room versions it also sat below the uncapped attack events. This PR adds a background update that re-spreads all events at or aboveMAX_DEPTHacross the unused ordering range above the room's highest real depth, ranked byorigin_server_ts. Event persistence now stores a new at-cap event just above the room's current maximum, which keeps a repaired room repaired.topological_orderingis local to each server, so nothing changes over federation.Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.