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

Commit

Permalink
Track when the pulled event signature fails
Browse files Browse the repository at this point in the history
Part of #13700
  • Loading branch information
MadLittleMods committed Sep 14, 2022
1 parent 957e3d7 commit 924ae2b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion synapse/federation/federation_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,13 @@ async def _check_sigs_and_hash(
InvalidEventSignatureError if the signature check failed. Nothing
will be logged in this case.
"""
await _check_sigs_on_pdu(self.keyring, room_version, pdu)
try:
await _check_sigs_on_pdu(self.keyring, room_version, pdu)
except Exception as exc:
await self._store.record_event_failed_pull_attempt(
pdu.room_id, pdu.event_id, str(exc)
)
raise exc

if not check_event_content_hash(pdu):
# let's try to distinguish between failures because the event was
Expand Down Expand Up @@ -116,6 +122,9 @@ async def _check_sigs_and_hash(
"event_id": pdu.event_id,
}
)
await self._store.record_event_failed_pull_attempt(
pdu.room_id, pdu.event_id, "Event content has been tampered with"
)
return redacted_event

spam_check = await self.spam_checker.check_event_for_spam(pdu)
Expand Down

0 comments on commit 924ae2b

Please sign in to comment.