element-hq / element-hq/element-web

Lost OTK, leading to "OneTime key already exists" error and later UTDs

Open
#31,842 9 comments 0 reactions 0 assignees View on GitHub
A-E2EE O-Occasional S-Major T-Defect Team: Crypto
Dominant language
TypeScript
Stars
13.5k
Forks
2.8k
PR merge metrics
PR metrics pending

Description

From time to time, we have reports from users whose clients get stuck uploading one-time-keys. For example:

```
2025-11-19T14:34:14.225Z D FetchHttpApi: --> POST https://matrix-client.matrix.org/_matrix/client/v3/keys/upload
2025-11-19T14:34:14.291Z D FetchHttpApi: <-- POST https://matrix-client.matrix.org/_matrix/client/v3/keys/upload [65ms 400]
2025-11-19T14:34:14.292Z D [Perf]: Make outgoing request 0 took 67ms
2025-11-19T14:34:14.292Z E Failed to process outgoing request 0: M_UNKNOWN: MatrixError: [400] One time key signed_curve25519:AAAAAAAAAEI already exists. Old key: {"key":"PUkTd3MCEG7a3g31uNH9uDfRbge5YHDZNgaHsL3QgwQ","signatures":{"@:matrix.org":{"ed25519:BRVTMXTHXB":"EemfO4mo2DGRqwttOK4WH0gO74RhudsN6/8v+hT0nUf+ZLQiUiku1D2dIYP09UibnN4ccKau4OCS7/FiCrjdDA"}}}; new key: {'key': 't/NppgUETPyrtUo9xprfu7pYoAnUOskwjVhPZ2Wz9xk', 'signatures': {'@:matrix.org': {'ed25519:BRVTMXTHXB': '+pstgfNA9s2I9KNNK+uHxeO/yclsfmPSIHn1jCMsom/pN7+9U/aScyKcS0y7apmUqROSUdh/RpQTkrbpSJRUDQ'}}} (https://matrix-client.matrix.org/_matrix/client/v3/keys/upload)
```

This very strongly suggests that the client has uploaded a one-time-key and then forgotten about it. It then creates a new OTK with the same ID; the client is then unable to upload further OTKs until the forgotten one is claimed by another device; and once it is claimed by another device, the resultant messages will be undecryptable.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the client code responsible for the /_matrix/client/v3/keys/upload request shown in the logs, then inspect how one-time-key state is retained after an upload. Done means the client does not reuse a lost key ID, does not remain blocked from uploading further keys, and does not cause undecryptable messages after a key is claimed.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.