summary refs log tree commit diff
path: root/synapse/federation/federation_server.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2019-01-31 18:11:00 +0000
committerAndrew Morgan <andrew@amorgan.xyz>2019-01-31 18:11:00 +0000
commitbbb97a35fdaf7193e22ceacb8c155038b66651d2 (patch)
treec166033c625605a56b3301dfdc74791f838a2a92 /synapse/federation/federation_server.py
parentlint (diff)
parentReject large transactions on federation (#4513) (diff)
downloadsynapse-bbb97a35fdaf7193e22ceacb8c155038b66651d2.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into anoa/room_upgrade_federatable
Diffstat (limited to 'synapse/federation/federation_server.py')
-rw-r--r--synapse/federation/federation_server.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/synapse/federation/federation_server.py b/synapse/federation/federation_server.py
index aeadc9c564..3da86d4ba6 100644
--- a/synapse/federation/federation_server.py
+++ b/synapse/federation/federation_server.py
@@ -148,6 +148,22 @@ class FederationServer(FederationBase):
 
         logger.debug("[%s] Transaction is new", transaction.transaction_id)
 
+        # Reject if PDU count > 50 and EDU count > 100
+        if (len(transaction.pdus) > 50
+                or (hasattr(transaction, "edus") and len(transaction.edus) > 100)):
+
+            logger.info(
+                "Transaction PDU or EDU count too large. Returning 400",
+            )
+
+            response = {}
+            yield self.transaction_actions.set_response(
+                origin,
+                transaction,
+                400, response
+            )
+            defer.returnValue((400, response))
+
         received_pdus_counter.inc(len(transaction.pdus))
 
         origin_host, _ = parse_server_name(origin)