Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Configurable maximum number of events requested by /sync and /messages #2221
Conversation
matrixbot
commented
May 13, 2017
|
Can one of the admins verify this patch? |
matrixbot
commented
May 13, 2017
|
Can one of the admins verify this patch? |
matrixbot
commented
May 13, 2017
|
Can one of the admins verify this patch? |
|
@matrixbot ok to test |
|
Fixing errors. ... |
psaavedra
referenced this pull request
May 15, 2017
Closed
add configurable maximums to the number of events requested by /sync and /messages #2220
| + return # no upper limits | ||
| + if 'room' in filter_json \ | ||
| + and 'timeline' in filter_json['room'] \ | ||
| + and 'limit' in filter_json['room']['timeline']: |
erikjohnston
May 15, 2017
Owner
Style nit: We prefer to never use \ style new line continuations and instead use brackets.
e.g. something like:
if (
'room' in filter_json
and 'timeline' in filter_json['room']
and 'limit' in filter_json['room']['timeline']
):
...(This could also be written as:
timeline = filter_json.get('room', {}).get('timeline', {})
if 'limit' in timeline:
...but I'm not sure if that's actually better in this case)
| @@ -85,6 +86,9 @@ def on_POST(self, request, user_id): | ||
| raise AuthError(403, "Can only create filters for local users") | ||
| content = parse_json_object_from_request(request) | ||
| + set_timeline_upper_limit(content, | ||
| + self.hs.config.filter_timeline_limit) |
erikjohnston
May 15, 2017
Owner
Style nit: For multi line stuff we prefer the following style:
set_timeline_upper_limit(
content,
self.hs.config.filter_timeline_limit,
)|
Other than some style nits this looks good! If you could quickly fix those up then I'm happy to merge this (Note to self: see if we can get pyflakes to complain about those things) |
|
Updated according with the style suggestions.
…
|
|
Thanks for this! Could you just quickly sign off as per CONTRIBUTING.rst please? Just as a comment/email here is fine. (Sorry for not spotting this before) |
|
Signed-off-by: Pablo Saavedra psaavedra@igalia.com |
|
My bad, I should include it in the first comment.
…
|
|
Thanks! |
psaavedra commentedMay 13, 2017
•
edited
Fixes: #2220
Some test done during this Saturday confirmed me a new attact vector for Matrix using the
/sync(API). The vulnerability is on Matrix don't set an upper limit for the max number of events to request for a requested room, this allow the attacker generates huge SQL queries in the server which can degradate the service and lead a DDoS.Set the limit on the returned events in the timeline in the get and sync operations. The default value is -1, means no upper limit.
For example, using
filter_timeline_limit: 5000:The server cuts down the room.timeline.limit.
Signed-off-by: Pablo Saavedra (psaavedra@igalia.com)