-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Use _check_sigs_and_hash_and_fetch to validate backfill requests #8350
Conversation
This is a bit of a hack, as `_check_sigs_and_hash_and_fetch` is intended for attempting to pull an event from the database/(re)pull it from the server that originally sent the event if checking the signature of the event fails. During backfill we *know* that we won't have the event in our database, however it is still useful to be able to query the original sending server as the server we're backfilling from may be acting maliciously. The main benefit and reason for this change however is that `_check_sigs_and_hash_and_fetch` will drop an event during backfill if it cannot be successfully validated, whereas the current code will simply fail the backfill request - resulting in the client's /messages request silently being dropped. This is a quick patch to fix backfilling rooms that contain malformed events. A better implementation in planned in future.
Possibly relevant: #2726 |
The test failures are due to tests that were added and fixed after v1.19 |
@@ -350,6 +348,7 @@ async def _check_sigs_and_hash_and_fetch( | |||
room_version: RoomVersion, | |||
outlier: bool = False, | |||
include_none: bool = False, | |||
check_db: bool = True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you want to use this somewhere?
Talked about in Matrix, but this isn't true. The tests failing are older tests that have existed for a while. |
However it seems that the branch we're merging into fails these tests as well, which isn't great, but at least it doesn't seem like it's due to this code. I'm going to revert the |
This reverts commit 8552287.
This is a bit of a hack, as `_check_sigs_and_hash_and_fetch` is intended for attempting to pull an event from the database/(re)pull it from the server that originally sent the event if checking the signature of the event fails. During backfill we *know* that we won't have the event in our database, however it is still useful to be able to query the original sending server as the server we're backfilling from may be acting maliciously. The main benefit and reason for this change however is that `_check_sigs_and_hash_and_fetch` will drop an event during backfill if it cannot be successfully validated, whereas the current code will simply fail the backfill request - resulting in the client's /messages request silently being dropped. This is a quick patch to fix backfilling rooms that contain malformed events. A better implementation in planned in future.
* commit 'd5f7182ba': 1.20.0rc5 1.19.3 Use _check_sigs_and_hash_and_fetch to validate backfill requests (#8350)
This PR is a partial fix to backfilling rooms with malformed events. It will
allow for backfilling a partial set of events in the room, but will not fix your
backfill eventually running out.
This could be cleaner, as
_check_sigs_and_hash_and_fetch
is intendedfor attempting to pull an event from the database/(re)pull it from the
server that originally sent the event if checking the signature of the
event fails.
During backfill we know that we won't have the event in our database,
however it is still useful to be able to query the original sending
server as the server we're backfilling from may be acting maliciously.
The main benefit and reason for using this method however is that
_check_sigs_and_hash_and_fetch
will drop an event during backfill ifit cannot be successfully validated, whereas the current code will
simply fail the backfill request - resulting in the client's /messages
request silently being dropped.