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

Element X: Two Olm Machines created in a row with same deviceId but different keys #2998

Closed
BillCarsonFr opened this issue Jan 8, 2024 · 4 comments

Comments

@BillCarsonFr
Copy link
Member

BillCarsonFr commented Jan 8, 2024

Rageshake https://github.com/element-hq/element-x-android-rageshakes/issues/1134

As part of login flow

2023-11-30T18:18:11.343073Z DEBUG matrix_sdk_crypto::machine: Created a new Olm account | crates/matrix-sdk-crypto/src/machine.rs:288 | spans: login{method="identifier and password"} > with_store{user_id="@xuanjun:matrix.org" device_id="KSBNNMTVDE" ed25519_key=yzQQLODIhkZ5v9Tku9fcvodHddLF7+os8SkyFDL1E/8 curve25519_key=y1/IrbHdpFDhdcF5fHI0QVUubNmp5EcGU9WMNL4/pAU}

Then a few seconds after from restore_session

2023-11-30T18:18:15.945739Z DEBUG matrix_sdk_crypto::machine: Created a new Olm account | crates/matrix-sdk-crypto/src/machine.rs:288 | spans: restore_session > restore_session > with_store{user_id="@xuanjun:matrix.org" device_id="KSBNNMTVDE" ed25519_key=VvjbqDo1DCfzvv/H8nHiiJ2P00uH7DscBWEaw8NZA+8 curve25519_key=/ecKBMJ1HSdIXfaTFduL/Y8pnO+oIxRjHMH83QUXlE8}

=> breaking encryption
(also causing the one time key exists problem)

2023-11-30T18:18:17.016058Z DEBUG matrix_sdk::http_client: Error while sending request: Api(Server(ClientApi(Error { status_code: 400, authenticate: None, body: Standard { kind: Unknown, message: "One time key signed_curve25519:AAAAAAAAAA0 already exists.
@stefanceriu
Copy link
Member

@richvdh richvdh changed the title Two Olm Machines created in a row with same deviceId but different keys Element X: Two Olm Machines created in a row with same deviceId but different keys Jan 10, 2024
@richvdh
Copy link
Member

richvdh commented Jan 10, 2024

Note that this is a potential cause of #1415.

@BillCarsonFr
Copy link
Member Author

BillCarsonFr commented Jan 10, 2024

Root cause of element-hq/element-x-ios#2287

During the login flow of EX, a first client is created with an in memory store, then after login a new client is created with a database store (the user_id is needed to create the database path).

The problem is that the first "in memory" client starts to initialize cryptography, i.e upload device keys, create cross-signing keys if needed, create backup if needed.
This will publish deviceKeys, identity keys and backup on the server.

Then the second client will try to do the same, but it will detect that keys/identities/backup are already published and this will impact bootstrap (also all the private keys of the published keys will be lost)

@BillCarsonFr
Copy link
Member Author

There is a hotfix/workaround for it #3115
And a remaining task to properly refactor and not use 2 clients #3029

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 a pull request may close this issue.

3 participants