Skip to content

Reject OTK uploads if clients exceed 500 server-side keys - #20162

Open
kaylendog wants to merge 8 commits into
element-hq:developfrom
kaylendog:kaylendog/feat/reject-otks
Open

Reject OTK uploads if clients exceed 500 server-side keys#20162
kaylendog wants to merge 8 commits into
element-hq:developfrom
kaylendog:kaylendog/feat/reject-otks

Conversation

@kaylendog

@kaylendog kaylendog commented Aug 28, 2026

Copy link
Copy Markdown

matrix-org/matrix-rust-sdk#6780 fixed a long-standing issue in the Rust SDK where OlmMachine::receive_sync_changes incorrectly treated a missing one_time_keys_counts as "no change", when (for sync v2) this means "no keys". This behaviour made it into the WASM SDK in release v18.5.0, which causes clients written using the JS SDK to endlessly upload OTKs on every sync.

This PR introduces a server-side check to see if a device has uploaded over 500 keys when it tries to upload more, errorring if this is the case. This should help inform client developers that something is wrong with their OTK implementation before it becomes a problem.

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct (run the linters)

Signed-off-by: Skye Elliot <actuallyori@gmail.com>
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
@kaylendog
kaylendog force-pushed the kaylendog/feat/reject-otks branch from 9fe1486 to 9c82f30 Compare August 28, 2026 15:07
@kaylendog
kaylendog marked this pull request as ready for review August 28, 2026 15:15
@kaylendog
kaylendog requested a review from a team as a code owner August 28, 2026 15:15
@kaylendog
kaylendog requested review from anoadragon453 and removed request for a team August 28, 2026 15:15
Comment thread docs/usage/configuration/config_documentation.md Outdated
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
@richvdh

richvdh commented Sep 1, 2026

Copy link
Copy Markdown
Member

For links: the combination of matrix-org/matrix-rust-sdk#6780 and the js-sdk resulted in matrix-org/matrix-js-sdk#5501, which in turn led to people seeing decryption errors, which can't even be fixed by rolling back the client, since the incorrect OTKs have already been uploaded to the server.

The goal here is to provide a backstop against similar client breakage in future by refusing to cooperate with such broken clients. Hopefully this will result in a user-visible "it's all horribly broken" error, which is better than silent breakage that manifests through decryption errors some time later.

In any case, Synapse should have a guard against users uploading absurd numbers of OTKs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants