anonymousland-synapse/synapse
Sean Quah 4f4f27e57f
Mitigate a race where /make_join could 403 for restricted rooms (#15080)
Previously, when creating a join event in /make_join, we would decide
whether to include additional fields to satisfy restricted room checks
based on the current state of the room. Then, when building the event,
we would capture the forward extremities of the room to use as prev
events.

This is subject to race conditions. For example, when leaving and
rejoining a room, the following sequence of events leads to a misleading
403 response:
1. /make_join reads the current state of the room and sees that the user
   is still in the room. It decides to omit the field required for
   restricted room joins.
2. The leave event is persisted and the room's forward extremities are
   updated.
3. /make_join builds the event, using the post-leave forward extremities.
   The event then fails the restricted room checks.

To mitigate the race, we move the read of the forward extremities closer
to the read of the current state. Ideally, we would compute the state
based off the chosen prev events, but that can involve state resolution,
which is expensive.

Signed-off-by: Sean Quah <seanq@matrix.org>
2023-02-17 09:40:32 +00:00
..
_scripts Always notify replication when a stream advances (#14877) 2023-01-20 18:02:18 +00:00
api Update the error code for duplicate annotation (#15075) 2023-02-15 11:47:57 +00:00
app Return read-only collections from @cached methods (#13755) 2023-02-10 23:29:00 +00:00
appservice Type hints for tests.appservice (#14990) 2023-02-06 12:49:06 +00:00
config Update intentional mentions (MSC3952) to depend on exact_event_match (MSC3758). (#15037) 2023-02-16 09:51:22 -05:00
crypto Add some clarifying comments and refactor a portion of the Keyring class for readability (#14804) 2023-01-13 12:37:28 +00:00
events Change collection[str] to StrCollection in event_auth code (#14929) 2023-02-14 09:37:08 +00:00
federation Fix federated joins when the first server in the list is not in the room (#15074) 2023-02-15 13:59:06 +00:00
handlers Mitigate a race where /make_join could 403 for restricted rooms (#15080) 2023-02-17 09:40:32 +00:00
http Use mypy 1.0 (#15052) 2023-02-16 16:09:11 +00:00
logging Use mypy 1.0 (#15052) 2023-02-16 16:09:11 +00:00
metrics Fix logging context warnings due to common usage metrics setup (#14574) 2022-11-28 15:25:18 +00:00
module_api Fix a bug in the send_local_online_presence_to module API (#14880) 2023-01-25 21:34:37 +00:00
push Update intentional mentions (MSC3952) to depend on exact_event_match (MSC3758). (#15037) 2023-02-16 09:51:22 -05:00
replication Fix bug in replication where response is cached (#15024) 2023-02-08 16:41:55 +00:00
res Fix #11308 : Remove dependency on jquery on reCAPTCHA page (#14672) 2022-12-14 12:02:28 +00:00
rest Use mypy 1.0 (#15052) 2023-02-16 16:09:11 +00:00
server_notices Remove redundant types from comments. (#14412) 2022-11-16 15:25:24 +00:00
spam_checker_api Fix import in module_api module and docs on the new check_event_for_spam signature (#12918) 2022-05-31 12:04:53 +02:00
state Return read-only collections from @cached methods (#13755) 2023-02-10 23:29:00 +00:00
static Add viewport directive to HTML templates to optimise for mobile (#13493) 2022-08-11 14:04:20 +01:00
storage Use mypy 1.0 (#15052) 2023-02-16 16:09:11 +00:00
streams Use mypy 1.0 (#15052) 2023-02-16 16:09:11 +00:00
types Implement MSC3966: Add a push rule condition to search for a value in an array. (#15045) 2023-02-14 14:02:19 -05:00
util Remove unnecessary reactor reference from _PerHostRatelimiter (#14842) 2023-01-16 13:16:19 +00:00
__init__.py Parse SYNAPSE_ASYNC_IO_REACTOR env variable & log the reactor on startup (#14092) 2022-10-07 15:19:59 +01:00
event_auth.py Change collection[str] to StrCollection in event_auth code (#14929) 2023-02-14 09:37:08 +00:00
notifier.py Fix a bug in the send_local_online_presence_to module API (#14880) 2023-01-25 21:34:37 +00:00
py.typed Mark Module API error imports as re-exported and mark Synapse as containing type annotations (#11054) 2021-10-13 08:42:41 +01:00
server.py Support for selecting the Redis logical database. (#15034) 2023-02-15 07:39:31 -05:00
visibility.py Move StateFilter to synapse.types (#14668) 2022-12-12 16:19:30 +00:00