-
Notifications
You must be signed in to change notification settings - Fork 400
MSC4147: Including device keys with Olm-encrypted events #4147
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
Conversation
proposals/4147-including-device-keys-with-olm-encrypted-events.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation requirements:
- Client sending this information
- Client using this information
- Demonstration of the core problem being solved (likely covered by the above tasks)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been implemented in the Rust matrix-sdk-crypto
crate, both sending and using. Demonstration of the problem being solved: https://youtu.be/b1jJlT2ENT8?feature=shared&t=345
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few links to the implementation.
On the sender side, the field is added here.
On the receiver side, it is deserialized after decryption into a DecryptedOlmV1Event. It is then used in SenderDataFinder whose job it is to construct a SenderData which records our knowledge about the sending device for a given session.
proposals/4147-including-device-keys-with-olm-encrypted-events.md
Outdated
Show resolved
Hide resolved
proposals/4147-including-device-keys-with-olm-encrypted-events.md
Outdated
Show resolved
Hide resolved
proposals/4147-including-device-keys-with-olm-encrypted-events.md
Outdated
Show resolved
Hide resolved
proposals/4147-including-device-keys-with-olm-encrypted-events.md
Outdated
Show resolved
Hide resolved
proposals/4147-including-device-keys-with-olm-encrypted-events.md
Outdated
Show resolved
Hide resolved
This patch implements MSC4147[1]. Signed-off-by: Hubert Chathi <hubertc@matrix.org> [1]: matrix-org/matrix-spec-proposals#4147
proposals/4147-including-device-keys-with-olm-encrypted-events.md
Outdated
Show resolved
Hide resolved
proposals/4147-including-device-keys-with-olm-encrypted-events.md
Outdated
Show resolved
Hide resolved
proposals/4147-including-device-keys-with-olm-encrypted-events.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
I think this is ready for FCP, so: @mscbot fcp merge |
Team member @mscbot has proposed to merge this. The next step is review by the rest of the tagged people: Concerns:
Once at least 75% of reviewers approve (and there are no outstanding concerns), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for information about what commands tagged team members can give me. |
Thanks for answering all my questions @richvdh -- I think this is OK as an incremental improvement, but sounds like we might need to do a bigger improvement at some point in the future. |
The final comment period, with a disposition to merge, as per the review above, is now complete. |
|
||
We propose to solve this by including a copy of the device keys in the | ||
Olm-encrypted message, along with the cross-signing signatures, so that the | ||
recipient does not have to try to query the sender's keys. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the intention to make sender_device_keys
mandatory, and drop to-device messages that do not include it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was very much not part of this MSC. It's something we could do in future, but IMHO it would need another MSC, and careful thought, since it would mean cutting off the significant part of the ecosystem which doesn't yet implement this MSC.
Spec PR: matrix-org/matrix-spec#2122 |
If this property is present, the `keys`.`ed25519` property of the plaintext | ||
payload must be the same as the `sender_device_keys`.`keys`.`ed25519:<DEVICEID>` | ||
property. If they differ, the recipient should discard the event. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't seem to have specified anything here about sender_device_keys
.keys
.curve25519:<DEVICEID>
, which seems like an oversight: if nothing else, it allows inconsistency within the event which is generally a big red flag in encryption stuff.
The sample implementation of this (matrix-rust-sdk) does check that curve25519:<DEVICEID>
matches the olm session used to encrypt the message (https://github.com/matrix-org/matrix-rust-sdk/blob/4d027ec405a20b54c6f9d2e31a20bf2dd1c3854d/crates/matrix-sdk-crypto/src/olm/account.rs#L1539-L1548); I'm inclined to consider it an oversight in the MSC.
cc @uhoreg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm taking silence as consent here. matrix-org/matrix-spec#2122 mandates a match.
Spec PR is now merged 🎉 |
For js-sdk users, this includes the following: - Send stable identifier `sender_device_keys` for MSC4147 (Including device keys with Olm-encrypted events). ([#4964](matrix-org/matrix-rust-sdk#4964)) - Check the `sender_device_keys` field on _all_ incoming Olm-encrypted to-device messages and ignore any to-device messages which include the field but whose data is invalid (as per [MSC4147](matrix-org/matrix-spec-proposals#4147)). ([#4922](matrix-org/matrix-rust-sdk#4922)) - Fix bug which caused room keys to be unnecessarily rotated on every send in the presence of blacklisted/withheld devices in the room. ([#4954](matrix-org/matrix-rust-sdk#4954)) - Fix [matrix-rust-sdk#2729](matrix-org/matrix-rust-sdk#2729) which in rare cases can cause room key oversharing. ([#4975](matrix-org/matrix-rust-sdk#4975))
For js-sdk users, this includes the following: - Send stable identifier `sender_device_keys` for MSC4147 (Including device keys with Olm-encrypted events). ([#4964](matrix-org/matrix-rust-sdk#4964)) - Check the `sender_device_keys` field on _all_ incoming Olm-encrypted to-device messages and ignore any to-device messages which include the field but whose data is invalid (as per [MSC4147](matrix-org/matrix-spec-proposals#4147)). ([#4922](matrix-org/matrix-rust-sdk#4922)) - Fix bug which caused room keys to be unnecessarily rotated on every send in the presence of blacklisted/withheld devices in the room. ([#4954](matrix-org/matrix-rust-sdk#4954)) - Fix [matrix-rust-sdk#2729](matrix-org/matrix-rust-sdk#2729) which in rare cases can cause room key oversharing. ([#4975](matrix-org/matrix-rust-sdk#4975))
For js-sdk users, this includes the following: - Send stable identifier `sender_device_keys` for MSC4147 (Including device keys with Olm-encrypted events). ([#4964](matrix-org/matrix-rust-sdk#4964)) - Check the `sender_device_keys` field on _all_ incoming Olm-encrypted to-device messages and ignore any to-device messages which include the field but whose data is invalid (as per [MSC4147](matrix-org/matrix-spec-proposals#4147)). ([#4922](matrix-org/matrix-rust-sdk#4922)) - Fix bug which caused room keys to be unnecessarily rotated on every send in the presence of blacklisted/withheld devices in the room. ([#4954](matrix-org/matrix-rust-sdk#4954)) - Fix [matrix-rust-sdk#2729](matrix-org/matrix-rust-sdk#2729) which in rare cases can cause room key oversharing. ([#4975](matrix-org/matrix-rust-sdk#4975))
For js-sdk users, this includes the following: - Send stable identifier `sender_device_keys` for MSC4147 (Including device keys with Olm-encrypted events). ([#4964](matrix-org/matrix-rust-sdk#4964)) - Check the `sender_device_keys` field on _all_ incoming Olm-encrypted to-device messages and ignore any to-device messages which include the field but whose data is invalid (as per [MSC4147](matrix-org/matrix-spec-proposals#4147)). ([#4922](matrix-org/matrix-rust-sdk#4922)) - Fix bug which caused room keys to be unnecessarily rotated on every send in the presence of blacklisted/withheld devices in the room. ([#4954](matrix-org/matrix-rust-sdk#4954)) - Fix [matrix-rust-sdk#2729](matrix-org/matrix-rust-sdk#2729) which in rare cases can cause room key oversharing. ([#4975](matrix-org/matrix-rust-sdk#4975))
Rendered
disclosure: I am on the Spec Core Team and employed by Element. This MSC is written as part of my work in the Crypto team at Element
FCP tickyboxes