Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Avoid putting rejected events in room state (#13723)
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Quah <seanq@matrix.org>
  • Loading branch information
squahtx authored Sep 16, 2022
1 parent 6986bcb commit b73cbb8
Show file tree
Hide file tree
Showing 3 changed files with 415 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/13723.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a long-standing bug where previously rejected events could end up in room state because they pass auth checks given the current state of the room.
15 changes: 15 additions & 0 deletions synapse/state/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,21 @@ async def _iterative_auth_checks(
if ev.rejected_reason is None:
auth_events[key] = event_map[ev_id]

if event.rejected_reason is not None:
# Do not admit previously rejected events into state.
# TODO: This isn't spec compliant. Events that were previously rejected due
# to failing auth checks at their state, but pass auth checks during
# state resolution should be accepted. Synapse does not handle the
# change of rejection status well, so we preserve the previous
# rejection status for now.
#
# Note that events rejected for non-state reasons, such as having the
# wrong auth events, should remain rejected.
#
# https://spec.matrix.org/v1.2/rooms/v9/#rejected-events
# https://github.com/matrix-org/synapse/issues/13797
continue

try:
event_auth.check_state_dependent_auth_rules(
event,
Expand Down
Loading

0 comments on commit b73cbb8

Please sign in to comment.