element-hq / element-hq/synapse
uploaded self_signing signature is silently discarded instead of replacing the existing one
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 600
- Avg merge
- 5d 22h
- Merged PRs (30d)
- 51
Description
### Description
If a device already has a self_signing signature, a new one uploaded via `keys/signatures/upload` is silently ignored. No error is reported and nothing appears in the response `failures` field.
This leaves no way to correct a bad signature, such as one left over from a device that previously had the same device id. AFAICT, it prevents affected devices from being verified at all.
This is currently happening to all new devices that reuse a device id* from a previously verified (and later deleted) device, due to bug #17375.
---
*Note that device id reuse is [explicitly allowed](https://spec.matrix.org/v1.11/client-server-api/#relationship-between-access-tokens-and-devices) by the spec:
> "A client is also free to generate its own device_id or, provided the user remains the same, reuse a device: in either case the client should pass the device_id in the request body."
### Steps to reproduce
- Log in and verify a new device.
- Use another client to forcibly log that device out. (Having the device log itself out might yield the same results; I haven't checked.)
- Log in another new device, passing the old device's device_id to the `login` endpoint.
- Inspect its signatures as reported by the `keys/query` endpoint.
- Note the presence of a self-signing signature, despite this device not having been verified. This signature belonged to the deleted device that previously used the same device id. It's invalid, of course, since the new device keys are not the same as the old ones. This stale signature shouldn't be there (see Synapse bug #17375) but it gives us a convenient way to demonstrate this bug.
- Upload a new signature for this device, generated with the self-signing key via the `keys/signatures/upload` endpoint.
- Note that no errors or failures are reported by the endpoint.
- Inspect the device's signatures again, as reported by the `keys/query` endpoint.
Note that the newly uploaded signature is not there; it was silently discarded. The old, invalid one remains in place.
### Homeserver
matrix.org
### Synapse Version
1.110.0rc1 (b=matrix-org-hotfixes,ddc46e90a8)
### Installation Method
I don't know
### Database
I don't know; It's the matrix.org server.
### Workers
I don't know
### Platform
I don't know; It's the matrix.org server.
### Configuration
_No response_
### Relevant log output
```shell
I don't have access to logs; It's the matrix.org server.
```
### Anything else that would be useful to know?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.