element-hq / element-hq/synapse
Database stores multiple cross-signing keys of the same type for a given user
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
This issue has been migrated from [#16398](https://github.com/matrix-org/synapse/issues/16398).
---
The Matrix protocol assumes that each user will have at most one cross-signing key of a given type (`master`, `self_signing`, `user_signing`) at a time.
However, it is possible for clients to replace the existing keys with further calls to [`POST /_matrix/client/v3/keys/device_signing/upload`](https://spec.matrix.org/v1.8/client-server-api/#post_matrixclientv3keysdevice_signingupload). When that happens, Synapse appears to just add the new key to `e2e_cross_signing_keys` without deleting the old one. Some `matrix.org` users have accumulated over 2000 keys of each type.
This is redundant data which we have no business keeping (and it sucks up disk space).
There also seems to be a codepath somewhere where we end up with multiple copies of a key for a remote user get stored in the database.
Ideally the `e2e_cross_signing_keys` table should be `UNIQUE` in `(user_id, keytype)`.
Contributor guide
Assessment
This issue has not been assessed yet.