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

Use _check_sigs_and_hash_and_fetch to validate backfill requests #8350

Merged
merged 4 commits into from
Sep 18, 2020

Conversation

anoadragon453
Copy link
Member

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 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 using this method 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 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.
@anoadragon453
Copy link
Member Author

Possibly relevant: #2726

@erikjohnston
Copy link
Member

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,
Copy link
Member

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?

@clokep
Copy link
Member

clokep commented Sep 18, 2020

The test failures are due to tests that were added and fixed after v1.19

Talked about in Matrix, but this isn't true. The tests failing are older tests that have existed for a while.

@anoadragon453
Copy link
Member Author

The test failures are due to tests that were added and fixed after v1.19

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 check_db change.

@anoadragon453 anoadragon453 merged commit 27c1abc into release-v1.19.3 Sep 18, 2020
@anoadragon453 anoadragon453 deleted the anoa/backfill branch September 18, 2020 13:51
anoadragon453 added a commit that referenced this pull request Sep 18, 2020
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.
clokep added a commit that referenced this pull request Sep 18, 2020
1.19.3

Synapse 1.19.3 (2020-09-18)
===========================

Bugfixes
--------

- Partially mitigate bug where newly joined servers couldn't get past
events in a room when there is a malformed event.
([\#8350](#8350))
babolivier pushed a commit that referenced this pull request Sep 1, 2021
* commit 'd5f7182ba':
  1.20.0rc5
  1.19.3
  Use _check_sigs_and_hash_and_fetch to validate backfill requests (#8350)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants