Skip to content

Commit f1a90a4

Browse files
turt2liverichvdh
authored andcommitted
Merge pull request #2732 from uhoreg/fallback_keys
MSC2732: Olm fallback keys
2 parents 16293c4 + 0841f31 commit f1a90a4

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

proposals/2732-olm-fallback-keys.md

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# MSC2732: Olm fallback keys
2+
3+
Olm uses a set of one-time keys when initializing a session between two
4+
devices: Alice uploads one-time keys to her homeserver, and Bob claims one of
5+
them to perform a Diffie-Hellman to generate a shared key. As implied by the
6+
name, a one-time key is only to be used once. However, if all of Alice's
7+
one-time keys are claimed, Bob will not be able to create a session with Alice.
8+
9+
This can be addressed by Alice uploading a fallback key that is used in place
10+
of a one-time key when no one-time keys are available.
11+
12+
## Proposal
13+
14+
A new request parameter, `fallback_keys`, is added to the body of the
15+
[`/keys/upload` client-server API](https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-upload), which is in the same format as the
16+
`one_time_keys` parameter with the exception that there must be at most one key
17+
per key algorithm. If the user had previously uploaded a fallback key for a
18+
given algorithm, it is replaced -- the server will only keep one fallback key
19+
per algorithm for each user.
20+
21+
When uploading fallback keys for algorithms whose key format is a signed JSON
22+
object, client should include a property named `fallback` with a value of
23+
`true`.
24+
25+
Example:
26+
27+
`POST /keys/upload`
28+
29+
```json
30+
{
31+
"fallback_keys": {
32+
"signed_curve25519:AAAAAA": {
33+
"key": "base64+public+key",
34+
"fallback": true,
35+
"signatures": {
36+
"@alice:example.org": {
37+
"ed25519:DEVICEID": "base64+signature"
38+
}
39+
}
40+
}
41+
}
42+
}
43+
```
44+
45+
When Bob calls `/keys/claim` to claim one of Alice's one-time keys, but Alice
46+
has no one-time keys left, the homeserver will return the fallback key instead,
47+
if Alice had previously uploaded one. Unlike with one-time keys, fallback keys
48+
are not deleted when they are returned by `/keys/claim`. However, the server
49+
marks that they have been used.
50+
51+
A new response parameter, `device_unused_fallback_key_types`, is added to
52+
`/sync`. This is an array listing the key algorithms for which the server has
53+
an unused fallback key for the device. If the client wants the server to have a
54+
fallback key for a given key algorithm, but that algorithm is not listed in
55+
`device_unused_fallback_key_types`, the client will upload a new key as above.
56+
57+
The `device_unused_fallback_key_types` parameter must be present if the server
58+
supports fallback keys. Clients can thus treat this field as an indication
59+
that the server supports fallback keys, and so only upload fallback keys to
60+
servers that support them.
61+
62+
Example:
63+
64+
`GET /sync`
65+
66+
Response:
67+
68+
```jsonc
69+
{
70+
// other fields...
71+
"device_unused_fallback_key_types": ["signed_curve25519"]
72+
}
73+
```
74+
75+
## Security considerations
76+
77+
Using a fallback key rather than a one-time key has security implications. An
78+
attacker can replay a message that was originally sent with a fallback key, and
79+
the receiving client will accept it as a new message if the fallback key is
80+
still active. Also, an attacker that compromises a client may be able to
81+
retrieve the private part of the fallback key to decrypt past messages if the
82+
client has still retained the private part of the fallback key.
83+
84+
For this reason, clients should not store the private part of the fallback key
85+
indefinitely. For example, client should only store at most two fallback keys:
86+
the current fallback key (that it has not yet received any messages for) and
87+
the previous fallback key, and should remove the previous fallback key once it
88+
is reasonably certain that it has received all the messages that use it (for
89+
example, one hour after receiving the first message that used it).
90+
91+
For addressing replay attacks, clients can also keep track of inbound sessions
92+
to detect replays.
93+
94+
## Unstable prefix
95+
96+
The `fallback_keys` request parameter and the `device_unused_fallback_key_types`
97+
response parameter will be prefixed by `org.matrix.msc2732.`.

0 commit comments

Comments
 (0)