Skip to content
Snippets Groups Projects
Commit 8e3d34e3 authored by Erik Johnston's avatar Erik Johnston
Browse files

Use event origin for filtering incoming events

We only process events sent to us from a server if the event ID matches
the server, to help guard against federation storms. We replace this
with a check against the event origin.
parent 55d90248
No related branches found
No related tags found
No related merge requests found
...@@ -25,7 +25,7 @@ from twisted.internet import defer ...@@ -25,7 +25,7 @@ from twisted.internet import defer
from twisted.internet.abstract import isIPAddress from twisted.internet.abstract import isIPAddress
from twisted.python import failure from twisted.python import failure
from synapse.api.constants import EventTypes from synapse.api.constants import EventTypes, Membership
from synapse.api.errors import ( from synapse.api.errors import (
AuthError, AuthError,
FederationError, FederationError,
...@@ -620,16 +620,19 @@ class FederationServer(FederationBase): ...@@ -620,16 +620,19 @@ class FederationServer(FederationBase):
""" """
# check that it's actually being sent from a valid destination to # check that it's actually being sent from a valid destination to
# workaround bug #1753 in 0.18.5 and 0.18.6 # workaround bug #1753 in 0.18.5 and 0.18.6
if origin != get_domain_from_id(pdu.event_id): if origin != get_domain_from_id(pdu.sender):
# We continue to accept join events from any server; this is # We continue to accept join events from any server; this is
# necessary for the federation join dance to work correctly. # necessary for the federation join dance to work correctly.
# (When we join over federation, the "helper" server is # (When we join over federation, the "helper" server is
# responsible for sending out the join event, rather than the # responsible for sending out the join event, rather than the
# origin. See bug #1893). # origin. See bug #1893. This is also true for some third party
# invites).
if not ( if not (
pdu.type == 'm.room.member' and pdu.type == 'm.room.member' and
pdu.content and pdu.content and
pdu.content.get("membership", None) == 'join' pdu.content.get("membership", None) in (
Membership.JOIN, Membership.INVITE,
)
): ):
logger.info( logger.info(
"Discarding PDU %s from invalid origin %s", "Discarding PDU %s from invalid origin %s",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment