Reject attempts to join empty rooms over federation (#7859)

We shouldn't allow others to make_join through us if we've left the room;
reject such attempts with a 404.

Fixes #7835. Fixes #6958.
This commit is contained in:
Richard van der Hoff 2020-07-16 15:17:31 +01:00 committed by GitHub
parent f2e38ca867
commit 346476df21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

1
changelog.d/7859.bugfix Normal file
View file

@ -0,0 +1 @@
Fix a bug which allowed empty rooms to be rejoined over federation.

View file

@ -44,6 +44,7 @@ from synapse.api.errors import (
FederationDeniedError, FederationDeniedError,
FederationError, FederationError,
HttpResponseException, HttpResponseException,
NotFoundError,
RequestSendFailed, RequestSendFailed,
SynapseError, SynapseError,
) )
@ -1439,10 +1440,20 @@ class FederationHandler(BaseHandler):
) )
raise SynapseError(403, "User not from origin", Codes.FORBIDDEN) 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) 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( builder = self.event_builder_factory.new(
room_version, room_version,
{ {