summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrew Morgan <1342360+anoadragon453@users.noreply.github.com>2020-10-28 11:58:47 +0000
committerGitHub <noreply@github.com>2020-10-28 11:58:47 +0000
commitd60af9305a07fadcf0270d1887c5b7d063834967 (patch)
tree324a558502b18ad1b6b7e709d1be1b685c0fa2a8
parentMerge remote-tracking branch 'origin/develop' into matrix-org-hotfixes (diff)
downloadsynapse-d60af9305a07fadcf0270d1887c5b7d063834967.tar.xz
Patch to temporarily drop cross-user m.key_share_requests (#8675)
Cross-user `m.key_share_requests` are a relatively new `to_device` message that allows user to re-request session keys for a message from another user if they were otherwise unable to retrieve them.

Unfortunately, these have had performance concerns on matrix.org. This is a temporary patch to disable them while we investigate a better solution.
-rw-r--r--changelog.d/8675.misc1
-rw-r--r--synapse/federation/federation_server.py4
-rw-r--r--synapse/handlers/devicemessage.py4
3 files changed, 9 insertions, 0 deletions
diff --git a/changelog.d/8675.misc b/changelog.d/8675.misc
new file mode 100644
index 0000000000..7ffe38b7d9
--- /dev/null
+++ b/changelog.d/8675.misc
@@ -0,0 +1 @@
+Temporarily drop cross-user m.room_key_request to_device messages over performance concerns.
diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py
index 23278e36b7..b7459a1d87 100644
--- a/synapse/federation/federation_server.py
+++ b/synapse/federation/federation_server.py
@@ -915,6 +915,10 @@ class FederationHandlerRegistry:
         if not self.config.use_presence and edu_type == "m.presence":
             return
 
+        # Temporary patch to drop cross-user key share requests
+        if edu_type == "m.room_key_request":
+            return
+
         # Check if we have a handler on this instance
         handler = self.edu_handlers.get(edu_type)
         if handler:
diff --git a/synapse/handlers/devicemessage.py b/synapse/handlers/devicemessage.py
index 9cac5a8463..5aa56013a4 100644
--- a/synapse/handlers/devicemessage.py
+++ b/synapse/handlers/devicemessage.py
@@ -153,6 +153,10 @@ class DeviceMessageHandler:
         local_messages = {}
         remote_messages = {}  # type: Dict[str, Dict[str, Dict[str, JsonDict]]]
         for user_id, by_device in messages.items():
+            # Temporary patch to disable sending local cross-user key requests.
+            if message_type == "m.room_key_request" and user_id != sender_user_id:
+                continue
+
             # we use UserID.from_string to catch invalid user ids
             if self.is_mine(UserID.from_string(user_id)):
                 messages_by_device = {