Skip to content

Commit b9cdd78

Browse files
hughnsdkasakkegsayturt2liverichvdh
authored
MSC3967: Do not require UIA when first uploading cross signing keys (#3967)
* Placeholder * MSC3967: Do not require UIA when first uploading cross signing keys * Lint length * Apply suggestions from code review Co-authored-by: Denis Kasak <[email protected]> * Suggestion from review * Issue with Synapse compliance is being tracked elsewhere * Line length * Update 3967-device-signing-upload-uia.md * Update proposals/3967-device-signing-upload-uia.md Co-authored-by: Travis Ralston <[email protected]> * Update 3967-device-signing-upload-uia.md * Update 3967-device-signing-upload-uia.md * Update 3967-device-signing-upload-uia.md * Update proposals/3967-device-signing-upload-uia.md Co-authored-by: Travis Ralston <[email protected]> * Update 3967-device-signing-upload-uia.md * Update 3967-device-signing-upload-uia.md * Update proposals/3967-device-signing-upload-uia.md Co-authored-by: Richard van der Hoff <[email protected]> --------- Co-authored-by: Denis Kasak <[email protected]> Co-authored-by: kegsay <[email protected]> Co-authored-by: Travis Ralston <[email protected]> Co-authored-by: Richard van der Hoff <[email protected]>
1 parent 2534644 commit b9cdd78

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# MSC3967: Do not require UIA when first uploading cross signing keys
2+
3+
When a user first sets up end-to-end encryption cross-signing, their client
4+
uploads their cross-signing keys to the server.
5+
6+
This [upload operation](https://spec.matrix.org/v1.6/client-server-api/#post_matrixclientv3keysdevice_signingupload)
7+
requires a higher level of security by applying User-Interactive Auth (UIA) to
8+
the endpoint.
9+
10+
This creates a usability issue at the point of user registration where a client
11+
will typically want to immediately set up cross-signing for a new user.
12+
13+
The issue is that the client will immediately need the user to re-authenticate
14+
even though the user just authenticated.
15+
16+
This usability issue has given rise to workarounds such as a
17+
[configurable grace period](https://matrix-org.github.io/synapse/v1.98/usage/configuration/config_documentation.html#ui_auth)
18+
(`ui_auth`.`session_timeout`) in Synapse whereby UIA will not be required for
19+
uploading cross-signing keys where authentication has taken place recently.
20+
21+
This proposal aims to provide for a standard way to address this UIA usability
22+
issue with respect to setting up cross-signing.
23+
24+
## Proposal
25+
26+
For the `POST /_matrix/client/v3/keys/device_signing/upload` endpoint, the
27+
Homeserver MUST require User-Interactive Authentication (UIA) _unless_:
28+
- there is no existing cross-signing master key uploaded to the Homeserver, OR
29+
- there is an existing cross-signing master key and it exactly matches the
30+
cross-signing master key provided in the request body. If there are any additional
31+
keys provided in the request (self signing key, user signing key) they MUST also
32+
match the existing keys stored on the server. In other words, the request contains
33+
no new keys. If there are new keys, UIA MUST be performed.
34+
35+
In these scenarios, this endpoint is not protected by UIA. This means the client does not
36+
need to send an `auth` JSON object with their request.
37+
38+
This change allows clients to freely upload 1 set of keys, but not modify/overwrite keys if
39+
they already exist. By allowing clients to upload the same set of keys more than once, this
40+
makes this endpoint idempotent in the case where the response is lost over the network, which
41+
would otherwise cause a UIA challenge upon retry.
42+
43+
## Potential issues
44+
45+
See security considerations below.
46+
47+
48+
## Alternatives
49+
50+
There has been some discussion around how to improve the usability of
51+
cross-signing more generally. It may be that an alternative solution is to
52+
provide a way to set up cross-signing in a single request.
53+
54+
## Security considerations
55+
56+
This change could be viewed as a degradation of security at the point of setting
57+
up cross-signing in that it requires less authentication to upload cross-signing
58+
keys on first use.
59+
60+
However, this degradation needs to be weighed against the typical real world
61+
situation where a Homeserver will be applying a grace period and so allow a
62+
malicious actor to bypass UIA for a period of time after each authentication.
63+
64+
### Existing users without E2EE keys
65+
66+
Existing user accounts who do not already have cross-signing keys set up will
67+
now be able to upload keys without UIA. If such a user has their access token
68+
compromised, an attacker will be able to upload a `master_key`, `self_signing_key`
69+
and `user_signing_key`. This is a similar threat model to a malicious server admin
70+
replacing these keys in the homeserver database.
71+
72+
This does not mean:
73+
- the attacker can "take over the account". It does not allow the attacker to
74+
[login](https://spec.matrix.org/v1.10/client-server-api/#login) as they need to
75+
know the password to the account. Likewise, an attacker cannot [logout all devices](https://spec.matrix.org/v1.10/client-server-api/#post_matrixclientv3logoutall)
76+
nor can they [logout specific devices](https://spec.matrix.org/v1.10/client-server-api/#delete_matrixclientv3devicesdeviceid)
77+
as these also go through UIA prompts.
78+
- the device will appear as verified to other users. Other users need to verify the
79+
public key [out-of-band](https://spec.matrix.org/v1.10/client-server-api/#short-authentication-string-sas-verification).
80+
As the true owner of the account is not performing this verification, if an attacker
81+
physically met up with other users it would become obvious that this is not the true owner,
82+
and hence no verification would be performed.
83+
84+
The main usability issue around this endpoint is requiring UIA, so it is critical
85+
that we only require UIA when absolutely necessary for the security of the account.
86+
In practice, this means requiring UIA when keys are _replaced_. There have been
87+
suggestions to reintroduce a grace period (e.g after initial device login) or just
88+
mandate it entirely for these old existing accounts. This would negatively impact
89+
usability because:
90+
- it introduces temporal variability which becomes difficult to debug. Not all users
91+
would be subject to these timers/mandates. As a result, it needs to be possible
92+
to detect in a bug report if the client is one of these special cases, and this is hard to do
93+
reliably, particularly when bug reports from other servers are involved. The kinds of
94+
bugs being debugged are typically around encryption, where there are complex interactions
95+
between different devices and continually changing server-side state. These kinds of bugs
96+
are incredibly time-sensitive as it is, and adding more temporal variability makes it even
97+
harder to debug correctly.
98+
- it introduces configuration variability which becomes difficult to debug. It's not
99+
clear what the grace period should actually be. Anything less than 1 hour risks
100+
catching initial x-signing requests from users who are on particularly awful networks.
101+
However, even increasing this to 1 hour poses the risk that we incorrectly catch the
102+
initial upload (e.g the client logs in on a bad GSM connection, then give up waiting
103+
for it to login and close the app, only reopening it the next day). This becomes
104+
difficult to debug in bug reports, as they just report HTTP 401s and it is unknown what
105+
the HS configuration is for the time delay. This is seen already due to the use (or non-use)
106+
of `ui_auth.session_timeout`. A spec-mandated grace period would mitigate some of these
107+
concerns, which could be further improved by adding special error codes indicating that
108+
the grace period had expired. However, this adds extra API surface that will likely be
109+
poorly tested in clients, as it's unreasonable to wait 1+ hours in a test, hence some
110+
configuration would be likely included for testing purposes anyway.
111+
112+
For these reasons, this MSC does not specify a grace period or treat some user accounts
113+
without existing cross-signing keys as special.
114+
115+
116+
## Unstable prefix
117+
118+
Not applicable as client behaviour need not change.
119+
120+
## Dependencies
121+
122+
None.

0 commit comments

Comments
 (0)