Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
Member

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 a review from matrix-org/synapse-core Oct 2, 2019
@babolivier babolivier added this to In progress in Homeserver Task Board via automation Oct 2, 2019
@babolivier babolivier moved this from In progress to Review in Homeserver Task Board Oct 2, 2019
@babolivier babolivier removed the request for review from matrix-org/synapse-core Oct 2, 2019
@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 added 4 commits Oct 2, 2019
@babolivier babolivier requested a review from matrix-org/synapse-core Oct 3, 2019
synapse/handlers/federation.py Outdated Show resolved Hide resolved
@babolivier babolivier requested a review from matrix-org/synapse-core Oct 4, 2019
@richvdh
richvdh approved these changes Oct 4, 2019
Copy link
Member

richvdh left a comment

lgtm

@babolivier babolivier merged commit ae0b78c into develop Oct 4, 2019
18 checks passed
18 checks passed
buildkite/synapse Build #4791 passed (31 minutes, 42 seconds)
Details
buildkite/synapse/check-sample-config Passed (2 minutes, 58 seconds)
Details
buildkite/synapse/check-style Passed (2 minutes, 54 seconds)
Details
buildkite/synapse/isort Passed (20 seconds)
Details
buildkite/synapse/mypy Passed (3 minutes, 11 seconds)
Details
buildkite/synapse/newspaper-newsfile Passed (2 minutes, 53 seconds)
Details
buildkite/synapse/packaging Passed (21 seconds)
Details
buildkite/synapse/pipeline Passed (2 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-postgres-9-dot-5 Passed (17 minutes, 21 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite Passed (6 minutes, 28 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite-slash-old-deps Passed (8 minutes, 24 seconds)
Details
buildkite/synapse/python-3-dot-6-slash-sqlite Passed (5 minutes, 41 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-11 Passed (20 minutes, 2 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-9-dot-5 Passed (17 minutes, 39 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-sqlite Passed (5 minutes)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-monolith Passed (11 minutes, 43 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-workers Passed (10 minutes, 16 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-sqlite-slash-monolith Passed (11 minutes, 33 seconds)
Details
Homeserver Task Board automation moved this from Review to Done Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
2 participants
You can’t perform that action at this time.