Skip to content

Commit 926c6ba

Browse files
authored
Deprecate the sender_key and device_id on Megolm events (#1101)
* Deprecate the `sender_key` and `device_id` on Megolm events MSC: matrix-org/matrix-spec-proposals#3700 ([Markdown](https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/3700-deprecate-sender-key.md)) The language around `m.room.encrypted` is a bit awkward because *technically* you can use the event to represent non-Megolm events, however that's considered an edge case at this time. * changelog * Apply wording changes * Remove incorrect example * Add missing sentence
1 parent c4db688 commit 926c6ba

File tree

4 files changed

+85
-8
lines changed

4 files changed

+85
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deprecate the `sender_key` and `device_id` on `m.megolm.v1.aes-sha2` events, and the `sender_key` on `m.room_key_request` to-device messages, as per [MSC3700](https://github.com/matrix-org/matrix-spec-proposals/pull/3700).

content/client-server-api/modules/end_to_end_encryption.md

+46-4
Original file line numberDiff line numberDiff line change
@@ -1531,8 +1531,19 @@ For example, Megolm sessions that were sent using the old session would
15311531
have been lost. The client can attempt to retrieve the lost sessions
15321532
through `m.room_key_request` messages.
15331533

1534+
{{% boxes/note %}}
1535+
Clients should send key requests for unknown sessions to all devices for
1536+
the user which used the session rather than just the `device_id` or
1537+
`sender_key` denoted on the event.
1538+
1539+
This is due to a deprecation of the fields. See
1540+
[`m.megolm.v1.aes-sha2`](#mmegolmv1aes-sha2) for more information.
1541+
{{% /boxes/note %}}
1542+
15341543
##### `m.megolm.v1.aes-sha2`
15351544

1545+
{{% changed-in v="1.3" %}}
1546+
15361547
The name `m.megolm.v1.aes-sha2` corresponds to version 1 of the Megolm
15371548
ratchet, as defined by the [Megolm
15381549
specification](http://matrix.org/docs/spec/megolm.html). This uses:
@@ -1580,10 +1591,36 @@ ratchet index that they have already decrypted. Care should be taken in
15801591
order to avoid false positives, as a client may decrypt the same event
15811592
twice as part of its normal processing.
15821593

1583-
As with Olm events, clients must confirm that the `sender_key` belongs
1584-
to the user who sent the message. The same reasoning applies, but the
1585-
sender ed25519 key has to be inferred from the `keys.ed25519` property
1586-
of the event which established the Megolm session.
1594+
Similar to Olm events, clients should confirm that the user who sent the
1595+
message corresponds to the user the message was expected to come from.
1596+
For room events, this means ensuring the event's `sender`, `room_id`, and
1597+
the recorded `session_id` match a trusted session (eg: the `session_id`
1598+
is already known and validated to the client).
1599+
1600+
{{% boxes/note %}}
1601+
As of `v1.3`, the `sender_key` and `device_id` keys are **deprecated**. They
1602+
SHOULD continue to be sent, however they MUST NOT be used to verify the
1603+
message's source.
1604+
1605+
Clients MUST NOT store or lookup sessions using the `sender_key` or `device_id`.
1606+
1607+
In a future version of the specification the keys can be removed completely,
1608+
including for sending new messages.
1609+
{{% /boxes/note %}}
1610+
1611+
{{% boxes/rationale %}}
1612+
Removing the fields (eventually) improves privacy and security by masking the
1613+
device which sent the encrypted message as well as reducing the client's
1614+
dependence on untrusted data: a malicious server (or similar attacker) could
1615+
change these values, and other devices/users can simply lie about them too.
1616+
1617+
We can remove the fields, particularly the `sender_key`, because the `session_id`
1618+
is already globally unique, therefore making storage and lookup possible without
1619+
the need for added context from the `sender_key` or `device_id`.
1620+
1621+
Removing the dependence on the fields gives a privacy gain while also increasing
1622+
the security of messages transmitted over Matrix.
1623+
{{% /boxes/rationale %}}
15871624

15881625
In order to enable end-to-end encryption in a room, clients can send an
15891626
`m.room.encryption` state event specifying `m.megolm.v1.aes-sha2` as its
@@ -1596,6 +1633,11 @@ that they can decrypt future messages encrypted using this session. An
15961633
`m.room_key` events sent by other devices in order to decrypt their
15971634
messages.
15981635

1636+
When a client is updating a Megolm session (room key) in its store, the client MUST ensure:
1637+
1638+
* that the updated session data comes from a trusted source.
1639+
* that the new session key has a lower message index than the existing session key.
1640+
15991641
#### Protocol definitions
16001642

16011643
##### Events

data/event-schemas/schema/m.room.encrypted.yaml

+27-3
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,42 @@ properties:
4040
Olm event. For more details, see [Messaging Algorithms](/client-server-api/#messaging-algorithms).
4141
sender_key:
4242
type: string
43-
description: The Curve25519 key of the sender.
43+
x-changedInMatrixVersion:
44+
1.3: |-
45+
Previously this field was required, however given it offers no additional
46+
security or privacy benefit it has been deprecated for Megolm messages.
47+
See [`m.megolm.v1.aes-sha2`](#mmegolmv1aes-sha2) for more information.
48+
description: |-
49+
The Curve25519 key of the sender. Required (not deprecated) if not using Megolm.
50+
51+
**Deprecated**: This field provides no additional security or privacy benefit
52+
for Megolm messages and must not be read from if the encrypted event is using
53+
Megolm. It should still be included on outgoing messages, however must not be
54+
used to find the corresponding session. See [`m.megolm.v1.aes-sha2`](#mmegolmv1aes-sha2)
55+
for more information.
4456
device_id:
4557
type: string
46-
description: The ID of the sending device. Required with Megolm.
58+
x-changedInMatrixVersion:
59+
1.3: |-
60+
Previously this field was required for Megolm messages, however given it
61+
offers no additional security or privacy benefit it has been deprecated
62+
for Megolm messages. See [`m.megolm.v1.aes-sha2`](#mmegolmv1aes-sha2) for
63+
more information.
64+
description: |-
65+
The ID of the sending device.
66+
67+
**Deprecated**: This field provides no additional security or privacy benefit
68+
for Megolm messages and must not be read from if the encrypted event is using
69+
Megolm. It should still be included on outgoing messages, however must not be
70+
used to find the corresponding session. See [`m.megolm.v1.aes-sha2`](#mmegolmv1aes-sha2)
71+
for more information.
4772
session_id:
4873
type: string
4974
description: |-
5075
The ID of the session used to encrypt the message. Required with
5176
Megolm.
5277
required:
5378
- algorithm
54-
- sender_key
5579
- ciphertext
5680
type: object
5781
type:

data/event-schemas/schema/m.room_key_request.yaml

+11-1
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,26 @@ properties:
2323
description: The room where the key is used.
2424
sender_key:
2525
type: string
26+
x-changedInMatrixVersion:
27+
1.3: |-
28+
Previously this field was required, however given it offers no additional
29+
security or privacy benefit it has been deprecated. See [`m.megolm.v1.aes-sha2`](#mmegolmv1aes-sha2)
30+
for more information.
2631
description: |-
2732
The Curve25519 key of the device which initiated the session originally.
33+
34+
**Deprecated**: This field provides no additional security or privacy benefit
35+
and must not be read from. It should still be included on outgoing messages
36+
(if the event for which keys are being requested for *also* has a `sender_key`),
37+
however must not be used to find the corresponding session. See [`m.megolm.v1.aes-sha2`](#mmegolmv1aes-sha2)
38+
for more information.
2839
session_id:
2940
type: string
3041
description: The ID of the session that the key is for.
3142
required:
3243
- algorithm
3344
- room_id
3445
- session_id
35-
- sender_key
3646
type: object
3747
title: RequestedKeyInfo
3848
action:

0 commit comments

Comments
 (0)