element-hq / element-hq/synapse

Claiming one-time keys should be rate limited

Open
#3,608 0 comments 0 reactions 0 assignees View on GitHub
A-E2EE O-Uncommon S-Major T-Defect
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#3608](https://github.com/matrix-org/synapse/issues/3608).

---

### Description

According to the spec, a HS should rate limit the number of one-time keys which can be claimed by a user https://matrix.org/docs/spec/client_server/r0.3.0.html#claiming-one-time-keys. It seems like Synapse doesn't.

This is a medium security issue as one can easily prevent a device from receiving any encrypted messages, by preventing other devices to establish an Olm session with it. It may also allow DoS on some low resource devices, where generating one-time keys is costly.

### Steps to reproduce

```
from matrix_client.client import MatrixClient

cli = MatrixClient(server)
cli.login(user, pass)
for _ in range(100):
# This should fail eventually, but doesn't
cli.api.claim_keys({other_user: {device_id: 'signed_curve25519'}})
```

Contributor guide

Open the contributing guide

Research direction

Start with the Matrix client-server specification section on claiming one-time keys and reproduce the behavior through the `cli.api.claim_keys` entry point shown in the report. Done means repeated claims are rate limited and eventually fail as expected, while legitimate key claims continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.