Limit the size of the aggregation_key (#12101)

There's no reason to let people use long keys.
This commit is contained in:
Erik Johnston 2022-03-03 10:52:35 +00:00 committed by GitHub
parent 31b125ccec
commit 61fd2a8f59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

1
changelog.d/12101.misc Normal file
View file

@ -0,0 +1 @@
Limit the size of `aggregation_key` on annotations.

View file

@ -1069,6 +1069,9 @@ class EventCreationHandler:
if relation_type == RelationTypes.ANNOTATION:
aggregation_key = relation["key"]
if len(aggregation_key) > 500:
raise SynapseError(400, "Aggregation key is too long")
already_exists = await self.store.has_user_annotated_event(
relates_to, event.type, aggregation_key, event.sender
)