@@ -263,8 +263,12 @@ async def on_receive_pdu(
263263
264264 state = None
265265
266- # Get missing pdus if necessary.
267- # We don't need to worry about outliers because TODO!
266+ # Check that the event passes auth based on the state at the event. This is
267+ # done for events that are to be added to the timeline (non-outliers).
268+ #
269+ # Get missing pdus if necessary:
270+ # - Fetching any missing prev events to fill in gaps in the graph
271+ # - Fetching state if we have a hole in the graph
268272 if not pdu .internal_metadata .is_outlier ():
269273 # We only backfill backwards to the min depth.
270274 min_depth = await self .get_min_depth_for_context (pdu .room_id )
@@ -434,6 +438,13 @@ async def on_receive_pdu(
434438 affected = event_id ,
435439 )
436440
441+ # A second round of checks for all events. Check that the event passes auth
442+ # based on `auth_events`, this allows us to assert that the event would
443+ # have been allowed at some point. If an event passes this check its OK
444+ # for it to be used as part of a returned `/state` request, as either
445+ # a) we received the event as part of the original join and so trust it, or
446+ # b) we'll do a state resolution with existing state before it becomes
447+ # part of the "current state", which adds more protection.
437448 await self ._process_received_pdu (origin , pdu , state = state )
438449
439450 async def _get_missing_events_for_pdu (
0 commit comments