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

Commit

Permalink
Limit the size of the aggregation_key (#12101)
Browse files Browse the repository at this point in the history
There's no reason to let people use long keys.
  • Loading branch information
erikjohnston committed Mar 3, 2022
1 parent 31b125c commit 61fd2a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.d/12101.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Limit the size of `aggregation_key` on annotations.
3 changes: 3 additions & 0 deletions synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,9 @@ async def _validate_event_relation(self, event: EventBase) -> None:
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
)
Expand Down

0 comments on commit 61fd2a8

Please sign in to comment.