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

Remove usages of event ID's domain #4514

Merged
merged 9 commits into from Jan 29, 2019
Merged

Conversation

erikjohnston
Copy link
Member

In future room version event IDs won't have a domain part

Since newer versions of events don't have the same format for event ID.
The event ID is changing, so we can no longer get the domain from it. On
the other hand, the check is unnecessary.
The transaction queue only sends out events that we generate. This was
done by checking domain of event ID, but that can no longer be used.
Instead, we may as well use the sender field.
We only process events sent to us from a server if the event ID matches
the server, to help guard against federation storms. We replace this
with a check against the event origin.
@erikjohnston erikjohnston requested a review from a team January 29, 2019 17:27
@erikjohnston
Copy link
Member Author

erikjohnston commented Jan 29, 2019

I've realised I've messed up Only check event ID domain for signatures for V1 events, fixing now.

In future version events won't have an event ID, so we won't be able to
do this check.
@erikjohnston
Copy link
Member Author

Fixed now

@codecov-io
Copy link

codecov-io commented Jan 29, 2019

Codecov Report

Merging #4514 into develop will increase coverage by <.01%.
The diff coverage is 87.5%.

@@             Coverage Diff             @@
##           develop    #4514      +/-   ##
===========================================
+ Coverage    74.75%   74.75%   +<.01%     
===========================================
  Files          336      336              
  Lines        34219    34266      +47     
  Branches      5570     5583      +13     
===========================================
+ Hits         25580    25617      +37     
- Misses        7060     7065       +5     
- Partials      1579     1584       +5

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks plausible otherwise

# Check the event_id's domain has signed the event
if not event.signatures.get(event_id_domain):
raise AuthError(403, "Event not signed by sending server")
if event.format_version in (RoomVersions.V1, RoomVersions.V2):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surely event.format_version should be an event version, not a room version?

# now let's look for events where the sender's domain is different to the
# event id's domain (normally only the case for joins/leaves), and add additional
# checks. Only do this if the room version has a concept of event ID domain
if room_version in KNOWN_ROOM_VERSIONS:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this not need to be different?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It currently gets done in #4515, I'm not sure why I didn't write it out fully here

@@ -243,32 +245,22 @@ def _check_sigs_on_pdus(keyring, pdus):
#
# let's start by getting the domain for each pdu, and flattening the event back
# to JSON.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you update the comment at line 230 about event_id?

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@erikjohnston erikjohnston merged commit 7740edd into develop Jan 29, 2019
@erikjohnston erikjohnston deleted the erikj/remove_event_id branch March 5, 2019 13:52
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.

None yet

3 participants