mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Reject large transactions on federation (#4513)
* Reject large transactions on federation * Add changelog * lint * Simplify large transaction handling
This commit is contained in:
parent
6fba9fd20c
commit
563f6a832b
1
changelog.d/4513.misc
Normal file
1
changelog.d/4513.misc
Normal file
@ -0,0 +1 @@
|
||||
Reject federation transactions if they include more than 50 PDUs or 100 EDUs.
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user