Skip to content
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9a9ded8
First draft of shared-key-backup-preference
andybalaam May 8, 2025
8309e20
Rename to reflect MSC number
andybalaam May 8, 2025
15f7585
Update MSC number in title
andybalaam May 8, 2025
4b50617
Small fixes and corrections
andybalaam May 8, 2025
e635ab0
Mention the weird unstable prefix
andybalaam May 8, 2025
b7f2324
Note that the security problem is less if clients make the setting vi…
andybalaam May 19, 2025
eb3eebd
Fix wording of 'not perform key backup'
andybalaam May 19, 2025
c6a6ffc
Improve wording around turning on key backups
andybalaam May 19, 2025
3d926bd
Note that clients should notice when key backup is deleted
andybalaam May 19, 2025
d249eb2
Note that servers can delete key backups already
andybalaam May 19, 2025
b43f9c2
Clarify that this only applies to clients that support key backup
andybalaam Jan 22, 2026
5bc4d87
Fix extra JSON in account_data response.
andybalaam Jan 22, 2026
09ce593
Note that clients don't have to monitor account data
andybalaam Jan 22, 2026
bdafd3b
Fix typo
andybalaam Jan 22, 2026
b1c3dd1
Clarify the this only applies to client supporting encryption and key…
andybalaam Mar 3, 2026
f7d8885
Clarify that we are not requiring monitoring of the setting at all ti…
andybalaam Mar 5, 2026
dd14913
Allow clients to consider the setting value as they wish, rather than…
andybalaam Mar 5, 2026
e4de388
Note that m. in the unstable prefix was a mistake
andybalaam Mar 5, 2026
c353530
Link to a specific spec version
andybalaam Mar 12, 2026
7ae226e
Clarify how we can mitigate malicious server control of the setting
andybalaam Mar 12, 2026
76d77b9
Avoid EITHER and OR by using MAY as suggested by @Johennes
andybalaam Mar 23, 2026
395b98a
Make sure we update the property if the client updates it
andybalaam Mar 23, 2026
6f580fd
Revert "Make sure we update the property if the client updates it"
andybalaam Mar 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions proposals/4287-shared-key-backup-preference.md
Comment thread
richvdh marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# MSC4287: Sharing key backup preference between clients

Matrix allows for clients to [store backups of room
keys](https://spec.matrix.org/v1.14/client-server-api/#server-side-key-backups)
(encrypted) on the server.

Some users choose to disable this feature.

Some clients enable key backup by default, meaning that if a user signs in,
their keys may be backed up even though they have chosen not to back them up on
a different client. This is probably not the behaviour the user wants.

We describe a mechanism for remembering the user's preference in this matter,
so that a new client can behave correctly without needing to be told again that
the user does not want key backups.

## Proposal

We propose an event type to be stored in global account data,
`m.key_backup` whose contents consist of a single field `enabled` whose value is
boolean.

For example, if I `GET
/_matrix/client/v3/user/{userId}/account_data/m.key_backup`, the response looks
like:

```
{
"enabled": true
}
```

If `enabled` is `true`, key backup for new sign-ins is on. If `enabled` is
`false`, key backup for new sign-ins is off. Otherwise, the value is
undetermined and the client should either treat it as off, or make a choice and
update the value to reflect it.

### Behaviour on sign-in
Comment thread
richvdh marked this conversation as resolved.

When a user signs in to a client which supports encryption and key backup:

* If this event type exists in account data and contains the specified property
in the correct format, clients which support key backup MUST take account of
its contents in their behaviour. For example, clients may automatically turn
on/off key backup based on the property, or prompt the user, using the
property value as a default. (Because this property is server-controlled,
clients may wish to confirm the user's intention.)

* If this event type does not exist in account data, or if it does not contain
the `enabled` property, or if the value of `enabled` is not a boolean value,
clients MUST ignore the existing value and MAY decide whether or not to
perform key backup, possibly based on user input.

### Behaviour on setting change

If the user turns on key backups, clients MUST set this event type in account
data, to `"enabled": true`.

If the user turns off key backups, clients MUST set this event type in account
data, to `"enabled": false`.

### Not actively monitoring this setting

We do not propose that clients actively monitor the `m.key_backup` account data
and enable or disable key backup based on changes. Clients MAY monitor the
setting but should be aware that changing this setting without user interaction
based on choices made in a different client (or a compromised homeserver) may
cause unforeseen security problems or simply be unexpected by users.

## Potential issues

It is possible that some use cases would involve a user having several clients,
some of which are using key backups, and some of which are not. If we want to
support that use case, we should allow some clients to opt out entirely from
reading or updating this account data.

We are not aware of these use cases, so if any are known it would be helpful to
let us know.

## Alternatives

### When the value is missing or invalid

There are alternative possibilities for the default behaviour (e.g. a
missing/invalid event could simply mean "off") but the described behaviour is
intended to be unambiguous and prevent two clients interpreting the same setting
differently, while also allowing clients to choose default behaviour suitable
for their audience.

### Dynamically reacting to changes

As specified, this only affects client behaviour when a user signs in. We could
specify that clients must watch the value of this account data and dynamically
change their key backup behaviour when it changes. This would increase the
severity of the security issues discussed below. Whether this behaviour would be
more or less surprising for the user is a potential discussion point.
Comment thread
richvdh marked this conversation as resolved.

Note that clients should already notice if a key backup is deleted, because
attempts to upload new keys will start failing.

### A proper unstable prefix

Because an existing implementation exists, the proposed unstable prefix has
different semantics from the final proposal. If this is deemed unacceptable, a
more normal unstable prefix could be used.

## Security considerations

Unencrypted account data is under the control of the server, so a malicious
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads up that I tripped over this fairly badly while reviewing; my thought process was: "autoenabling backup sounds scary; warning users sounds even scarier - what would the warning even say?". @tulir pointed out however that in practice current clients enable backup automatically at login - so in practice this doesn't significantly change the attack surface.

Instead, paranoid clients which let the user opt out of backup should warn the user when they are enabling backup whatever the scenario - including at login.

Unsure if this needs to be written up on the MSC, but am commenting it here so I have something to refer back to in future.

server could:
Comment thread
turt2live marked this conversation as resolved.

* increase the user's attack surface by tricking clients into performing key backups
against the user's will, or

* cause data loss by tricking clients into not performing key backups. (But
servers can delete data from key backups at will, so this seems unimportant.)

This can be mitigated if clients make it visible to users when the
server-provided setting is going to affect their behaviour e.g. by prompting the
user for confirmation.

## Unstable prefix

This is currently partially implemented in Element clients using a
reversed-sense format like:

```
{
"m.org.matrix.custom.backup_disabled" { "disabled": true }
Comment thread
turt2live marked this conversation as resolved.
}
```

so we propose to use this form as an unstable prefix, and reverse the sense of
the boolean when this feature is stabilised.

NOTE: the use of the `m.` prefix for this property name was a mistake since
[identifiers starting with the characters m. are reserved for use by the official Matrix specification](https://spec.matrix.org/v1.17/appendices/#common-namespaced-identifier-grammar).

## Dependencies

None

## Implementations

This is partially implemented (with the reverse-sense boolean) in Element
clients. The part that is currently not implemented is proactively setting the
value on sign-in.
Loading