Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MXCrypto: Reset OTKs when some IDs are already used #922

Merged
merged 6 commits into from
Oct 8, 2020

Conversation

manuroe
Copy link
Contributor

@manuroe manuroe commented Oct 8, 2020

This is a mitigation for element-hq/element-ios#3721.
But it does not fix the root issue.

This is how this PR behaves on the steps to reproduce:

2020-10-08 09:16:22.890670+0200 Riot[31404:1330203] [MXHTTPClient] #12 - POST _matrix/client/r0/keys/upload/SYNBAYVHFQ completed in 196ms
2020-10-08 09:16:22.891049+0200 Riot[31404:1330203] [MXHTTPClient] Request 0x6000002a2ec0 failed for path: _matrix/client/r0/keys/upload/SYNBAYVHFQ - HTTP code: 400. Error: Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: bad request (400)" UserInfo={NSLocalizedDescription=Request failed: bad request (400), NSErrorFailingURLKey=https://matrix-client.matrix.org/_matrix/client/r0/keys/upload/SYNBAYVHFQ, com.alamofire.serialization.response.error.data={length = 531, bytes = 0x7b226572 72636f64 65223a22 4d5f554e ... 4167277d 7d7d227d }, com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x600001d17e40> { URL: https://matrix-client.matrix.org/_matrix/client/r0/keys/upload/SYNBAYVHFQ } { Status Code: 400, Headers {
2020-10-08 09:16:22.891735+0200 Riot[31404:1330449] [MXCrypto] uploadOneTimeKeys fails.
2020-10-08 09:16:22.891984+0200 Riot[31404:1330449] [MXCrypto] generateAndUploadOneTimeKeys: Failed to publish one-time keys. Error: Error Domain=org.matrix.sdk Code=6 "One time key signed_curve25519:AAAAAQ already exists. Old key: {"key":"mbMSl5/v4ZUOYa4K3WjIdpB/vCEh/gjB4FhSWOq3IAA","signatures":{"@superman:matrix.org":{"ed25519:SYNBAYVHFQ":"CteVb3rbYFQ4qxAqg3YsU7EaUN6tSmZK+OssNU8At0UCD/vQuLuxh21jalNGpn9HvtTNz10Qsw/X5gTYmXVbDQ"}}}; new key: {'key': 'XiwFps8Lz/+VWflVk/1O7P6gz/2q2Z118drmjnzjrTA', 'signatures': {'@superman:matrix.org': {'ed25519:SYNBAYVHFQ': 'BRYhdAJRlE3luwP//29pyuX3DxhJw8WxextbPY6Wg8eL+NMaDQnYixSpLLxuj5AdmnzZhgKxERs3SxsMV+NtAg'}}}" UserInfo={errcode=M_UNKNOWN, httpResponse=<NSHTTPURLResponse: 0x600001d17e40> { URL: https://matrix-client.matrix.org/_matrix/client/r0/keys/upload/SYNBAYVHFQ } { Status Code: 400, Headers {
2020-10-08 09:16:22.896053+0200 Riot[31404:1330449] [MXCrypto] uploadOneTimeKeys: Reset local OTKs because the server does not like them
2020-10-08 09:16:22.896735+0200 Riot[31404:1330449] [MXCrypto] uploadOneTimeKeys: Upload 1 keys
2020-10-08 09:16:22.896911+0200 Riot[31404:1330449] [MXHTTPClient] #13 - POST _matrix/client/r0/keys/upload/SYNBAYVHFQ
2020-10-08 09:16:23.101934+0200 Riot[31404:1330203] [MXHTTPClient] #13 - POST _matrix/client/r0/keys/upload/SYNBAYVHFQ completed in 205ms
2020-10-08 09:16:23.669519+0200 Riot[31404:1330203] [MXHTTPClient] #5 - POST _matrix/client/r0/keys/upload/SYNBAYVHFQ completed in 1992ms
2020-10-08 09:16:23.669972+0200 Riot[31404:1330449] [MXCrypto] uploadDeviceKeys done for @superman:matrix.org:

We detect the problem and we retry with new OTKs

@manuroe
Copy link
Contributor Author

manuroe commented Oct 8, 2020

I double checked code from android and web. We store the OLM account in the same way as other SDKs. I cannot understand how a rotation of OTKs and a reuse of existing IDs can happen.

@manuroe manuroe merged commit 7946fad into develop Oct 8, 2020
@manuroe manuroe deleted the duplicate_otk_ids branch October 8, 2020 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants