element-hq / element-hq/synapse
Claiming one-time keys should be rate limited
- 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
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