Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Reject large transactions on federation #4513

Merged
merged 4 commits into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/4513.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reject federation transactions if they include more than 50 PDUs or 100 EDUs.
16 changes: 16 additions & 0 deletions synapse/federation/federation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,22 @@ def _handle_incoming_transaction(self, origin, transaction, request_time):

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)
Expand Down