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

Don't 500 when trying to exchange a revoked 3PID invite #6147

Merged
merged 9 commits into from
Oct 4, 2019

Conversation

babolivier
Copy link
Contributor

@babolivier babolivier commented Oct 2, 2019

While this is not documented in the spec (but should be), Riot (and other clients) revoke 3PID invites by sending a m.room.third_party_invite event with an empty ({}) content to the room's state.
When the invited 3PID gets associated with a MXID, the identity server (which doesn't know about revocations) sends down to the MXID's homeserver all of the undelivered invites it has for this 3PID. The receiving homeserver then tries to talk to the inviting homeserver in order to exchange these invite for m.room.member events.

When one of the invites is revoked, the inviting homeserver responds with a 500 error because it tries to extract a display_name property from the content, which is empty. This might cause the invited server to consider that the server is down and not try to exchange other, valid invites (or at least delay it).

This fix handles the case of revoked invites by avoiding trying to fetch a display_name from the original invite's content, and letting the m.room.member event fail the auth rules (because, since the original invite's content is empty, it doesn't have public keys), which results in sending a 403 with the correct error message to the invited server.

While this is not documented in the spec (but should be), Riot (and other clients) revoke 3PID invites by sending a m.room.third_party_invite event with an empty ({}) content to the room's state.
When the invited 3PID gets associated with a MXID, the identity server (which doesn't know about revocations) sends down to the MXID's homeserver all of the undelivered invites it has for this 3PID. The homeserver then tries to talk to the inviting homeserver in order to exchange these invite for m.room.member events.
When one of the invite is revoked, the inviting homeserver responds with a 500 error because it tries to extract a 'display_name' property from the content, which is empty. This might cause the invited server to consider that the server is down and not try to exchange other, valid invites (or at least delay it).

This fix handles the case of revoked invites by avoiding trying to fetch a 'display_name' from the original invite's content, and letting the m.room.member event fail the auth rules (because, since the original invite's content is empty, it doesn't have public keys), which results in sending a 403 with the correct error message to the invited server.
@babolivier babolivier requested review from a team and removed request for a team October 2, 2019 10:22
@babolivier babolivier changed the title Don't 500 code when trying to exchange a revoked 3PID invite Don't 500 when trying to exchange a revoked 3PID invite Oct 2, 2019
@babolivier babolivier requested a review from a team October 3, 2019 10:39
@babolivier babolivier requested a review from a team October 4, 2019 10:17
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

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.

2 participants