summary refs log tree commit diff
path: root/synapse/federation
diff options
context:
space:
mode:
authorAndrew Morgan <1342360+anoadragon453@users.noreply.github.com>2019-01-31 11:44:04 +0000
committerAmber Brown <hawkowl@atleastfornow.net>2019-01-31 11:44:04 +0000
commit563f6a832b379e2cde6b5618a7c344c2bcd793a1 (patch)
tree4a2510a5ff614ac0db5ffd8c8f9445f38f0cf44b /synapse/federation
parentMerge remote-tracking branch 'origin/release-v0.99.0' into develop (diff)
downloadsynapse-563f6a832b379e2cde6b5618a7c344c2bcd793a1.tar.xz
Reject large transactions on federation (#4513)
* Reject large transactions on federation

* Add changelog

* lint

* Simplify large transaction handling
Diffstat (limited to 'synapse/federation')
-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)