summary refs log tree commit diff
path: root/synapse/events/third_party_rules.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2020-10-13 22:02:41 +0100
committerRichard van der Hoff <richard@matrix.org>2020-10-13 23:24:50 +0100
commit898196f1cca419c0d2b60529c86ddff3cea83072 (patch)
tree83685785d64861d6d227e0e5b6db6ef1e20f0332 /synapse/events/third_party_rules.py
parentAllow ThirdPartyRules modules to replace event content (diff)
downloadsynapse-898196f1cca419c0d2b60529c86ddff3cea83072.tar.xz
guard against accidental modification
Diffstat (limited to 'synapse/events/third_party_rules.py')
-rw-r--r--synapse/events/third_party_rules.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/synapse/events/third_party_rules.py b/synapse/events/third_party_rules.py
index a9aabe00df..77fbd3f68a 100644
--- a/synapse/events/third_party_rules.py
+++ b/synapse/events/third_party_rules.py
@@ -69,9 +69,10 @@ class ThirdPartyEventRules:
         events = await self.store.get_events(prev_state_ids.values())
         state_events = {(ev.type, ev.state_key): ev for ev in events.values()}
 
-        # The module can modify the event slightly if it wants, but caution should be
-        # exercised, and it's likely to go very wrong if applied to events received over
-        # federation.
+        # Ensure that the event is frozen, to make sure that the module is not tempted
+        # to try to modify it. Any attempt to modify it at this point will invalidate
+        # the hashes and signatures.
+        event.freeze()
 
         return await self.third_party_rules.check_event_allowed(event, state_events)