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

Reject attempts to join empty rooms over federation #7859

Merged
merged 1 commit into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/7859.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug which allowed empty rooms to be rejoined over federation.
15 changes: 13 additions & 2 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
FederationDeniedError,
FederationError,
HttpResponseException,
NotFoundError,
RequestSendFailed,
SynapseError,
)
Expand Down Expand Up @@ -1439,10 +1440,20 @@ async def on_make_join_request(
)
raise SynapseError(403, "User not from origin", Codes.FORBIDDEN)

event_content = {"membership": Membership.JOIN}

# checking the room version will check that we've actually heard of the room
# (and return a 404 otherwise)
room_version = await self.store.get_room_version_id(room_id)

# now check that we are *still* in the room
is_in_room = await self.auth.check_host_in_room(room_id, self.server_name)
if not is_in_room:
logger.info(
"Got /make_join request for room %s we are no longer in", room_id,
)
raise NotFoundError("Not an active room on this server")

event_content = {"membership": Membership.JOIN}

builder = self.event_builder_factory.new(
room_version,
{
Expand Down