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

Limit which clients are allowed to send read receipts without a body #11156

Closed
callahad opened this issue Oct 21, 2021 · 5 comments · Fixed by #11157
Closed

Limit which clients are allowed to send read receipts without a body #11156

callahad opened this issue Oct 21, 2021 · 5 comments · Fixed by #11157
Labels
good first issue Good for newcomers P3 (OBSOLETE: use S- labels.) Approved backlog: not yet scheduled, will accept patches T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.

Comments

@callahad
Copy link
Contributor

callahad commented Oct 21, 2021

The Matrix Spec requires that requests to POST /rooms/{roomId}/receipt/{receiptType}/{eventId} have a body, even if it's just {}. Unfortunately, older Element Android clients omitted this and sent empty bodies instead.

We worked around this in #10531, but we'd like to eventually remove the workaround per #10534.

To prevent the problem from getting worse, we should limit the scope of the workaround to only apply to known bad clients.

Specifically, instead of unconditionally setting allow_empty_body=True here:

body = parse_json_object_from_request(request, allow_empty_body=True)

We should only set it to True if the result of get_request_user_agent(request) contains Android and satisfies one of the following:

  • Contains Riot (e.g., Old Riot.im, Riot, RiotX, Element (Riot.im))
  • Starts with Element/1.[012].*
  • Starts with SchildiChat/1.[012].*

(This will unnecessarily allow all Element 1.2.x releases to send empty bodies, instead of just versions < 1.2.1, but doing so really simplifies the glob, and we know that 1.2.1 and later are well behaved, so no harm done.)

@callahad callahad added P3 (OBSOLETE: use S- labels.) Approved backlog: not yet scheduled, will accept patches T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks. good first issue Good for newcomers labels Oct 21, 2021
@callahad
Copy link
Contributor Author

Go for it!

@rogersheu
Copy link
Contributor

rogersheu commented Oct 21, 2021

Ah, thanks! I deleted my comment because I was reading through the comments of some other issues and I got confused about how assigning works (or lack thereof) but I'll work on this.

@reivilibre
Copy link
Contributor

I think @callahad omitted to mention that the user agent should contain Android?

At least a few months ago, modern iOS clients still send Riot as the user-agent string.

@rogersheu
Copy link
Contributor

@reivilibre So should the code allow empty body read receipts for any user agent containing Android or should it look for Android and the other keywords callahad mentioned? Thanks for clarifying.

@DMRobertson
Copy link
Contributor

@reivilibre So should the code allow empty body read receipts for any user agent containing Android or should it look for Android and the other keywords callahad mentioned? Thanks for clarifying.

The latter: we only want to target this hack/workaround at old Android clients. I've updated @callahad's description to try to reflect this. Hopefully that's clearer, shout if not!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers P3 (OBSOLETE: use S- labels.) Approved backlog: not yet scheduled, will accept patches T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants