Skip to content

Allow resetting cross-signing without MAS approval when the user has no way to verify - #20549

Draft
mxandreas wants to merge 2 commits into
developfrom
mxandreas/cross-signing-reset-without-verification-methods
Draft

mxandreas wants to merge 2 commits into
developfrom
mxandreas/cross-signing-reset-without-verification-methods

Conversation

@mxandreas

@mxandreas mxandreas commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Part of element-hq/element-meta#3372.

When a user resets their cross-signing identity on a homeserver using MAS, Synapse sends them to MAS to approve the reset. If the user has no way to verify their device anyway, that step only adds friction. This adds an option to skip it in that case:

matrix_authentication_service:
  skip_cross_signing_reset_approval_without_verification_methods: true

It is off by default and only applies with MAS.

A user has a way to verify if any of these is true:

  • One of their existing devices is signed by their current self-signing key (MAS-enabled servers don't let clients delete devices through Synapse, so this can't be removed without MAS).
  • Their master key is in secret storage: m.cross_signing.master is encrypted with the key named in m.secret_storage.default_key.
  • Their current master key has been in secret storage. Clients (the Rust SDK and Element Web) wipe secret storage before uploading the new keys, so checking it at upload time isn't enough. Whenever one of those two account data types is changed while the master key is in secret storage, the latest master key row is marked with a new was_in_recovery column. A new master key starts without the mark. This also stops someone with a stolen access token from blanking the account data to skip approval.

Turning recovery off deliberately therefore also keeps approval required for that identity, as today.

Tested locally with MAS, Element Web and Element X: no way to verify → reset completes without MAS; another verified device or recovery set up → MAS approval is still required.

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct (run the linters)

🤖 Generated with Claude Code (Claude Opus 5.5)

mxandreas and others added 2 commits November 21, 2026 22:06
…ay to verify

Add the `matrix_authentication_service.skip_cross_signing_reset_approval_without_verification_methods`
option, off by default. When it is on, replacing the master cross-signing key does not
require approval in MAS if the user has no way to verify their device: none of their
devices is signed by their current self-signing key, and their current identity is not
and has not been in secret storage (recovery).

Clients wipe secret storage before uploading the new keys, so checking it at upload time
is not enough. Instead, whenever `m.secret_storage.default_key` or `m.cross_signing.master`
is changed while the master key is in secret storage, the current master key is marked
with the new `was_in_recovery` column. A new identity starts without the mark.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: mxandreas <andreass@element.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: mxandreas <andreass@element.io>
@github-actions

Copy link
Copy Markdown
Contributor

Schema Diff

Please check that this looks as expected!

common (sqlite)

Unchanged

common (postgres)

Unchanged

main (sqlite)

--- /tmp/schema_diff_wffl_jy1/before/main/full_schemas/9999/full.sql.sqlite	2026-11-21 20:10:23.889975362 +0000
+++ /tmp/schema_diff_wffl_jy1/after/main/full_schemas/9999/full.sql.sqlite	2026-11-21 20:10:09.673961484 +0000
@@ -196,21 +196,21 @@
 );
 CREATE INDEX room_retention_max_lifetime_idx on room_retention(max_lifetime);
 CREATE TABLE e2e_cross_signing_keys (
     user_id TEXT NOT NULL,
     -- the type of cross-signing key (master, user_signing, or self_signing)
     keytype TEXT NOT NULL,
     -- the full key information, as a json-encoded dict
     keydata TEXT NOT NULL,
     -- for keeping the keys in order, so that we can fetch the latest one
     stream_id BIGINT NOT NULL
-, updatable_without_uia_before_ms bigint DEFAULT NULL, instance_name TEXT);
+, updatable_without_uia_before_ms bigint DEFAULT NULL, instance_name TEXT, was_in_recovery BOOLEAN NOT NULL DEFAULT FALSE);
 CREATE UNIQUE INDEX e2e_cross_signing_keys_idx ON e2e_cross_signing_keys(user_id, keytype, stream_id);
 CREATE TABLE e2e_cross_signing_signatures (
     -- user who did the signing
     user_id TEXT NOT NULL,
     -- key used to sign
     key_id TEXT NOT NULL,
     -- user who was signed
     target_user_id TEXT NOT NULL,
     -- device/key that was signed
     target_device_id TEXT NOT NULL,

main (postgres)

--- /tmp/schema_diff_wffl_jy1/before/main/full_schemas/9999/full.sql.postgres	2026-11-21 20:10:24.632976070 +0000
+++ /tmp/schema_diff_wffl_jy1/after/main/full_schemas/9999/full.sql.postgres	2026-11-21 20:10:10.408962525 +0000
@@ -342,21 +342,22 @@
     ip text,
     user_agent text,
     hidden boolean DEFAULT false
 );
 CREATE TABLE e2e_cross_signing_keys (
     user_id text NOT NULL,
     keytype text NOT NULL,
     keydata text NOT NULL,
     stream_id bigint NOT NULL,
     updatable_without_uia_before_ms bigint,
-    instance_name text
+    instance_name text,
+    was_in_recovery boolean DEFAULT false NOT NULL
 );
 CREATE SEQUENCE e2e_cross_signing_keys_sequence
     START WITH 1
     INCREMENT BY 1
     NO MINVALUE
     NO MAXVALUE
     CACHE 1;
 CREATE TABLE e2e_cross_signing_signatures (
     user_id text NOT NULL,
     key_id text NOT NULL,

state (sqlite)

Unchanged

state (postgres)

Unchanged

@richvdh richvdh left a comment

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.

some drive-by comments

if not master_key_updatable_without_uia:
if (
not master_key_updatable_without_uia
and not await self._can_reset_without_approval(user_id)

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.

does this logic need to be specific to MAS? shouldn't it apply equally to the UIA case?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it does not have to be. My main argument was to change as little as possible and the main friction point is currently MAS (duplicate warnings with conflicting severity) whereas non-MAS cases you need to enter account password which is at least not misleading. But indeed from security/consistency perspective it makes sense to change both, MAS and non-MAS.

this natively, but a reverse proxy between Synapse and MAS may not.
default: false

skip_cross_signing_reset_approval_without_verification_methods:

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.

I'm not entirely convinced this should be configurable. If we've decided that this logic makes sense, why do we need to support a config option which people will have to go and turn on, and we'll have to remember that Synapse behaves differently depending on how its configured (and ideally we'll have to test that our clients work correctly against both configurations)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, fine to keep it simple. I was thinking of this more as a rollout feature flag but if we can do without it, it is certainly less complexity now and in the future.

@MadLittleMods MadLittleMods added A-NextGen-Auth OpenID Connect - OAuth 2.0 API - Matrix Authentication Service (MAS) z-cross-signing A-E2EE labels Nov 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-E2EE A-NextGen-Auth OpenID Connect - OAuth 2.0 API - Matrix Authentication Service (MAS) z-cross-signing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants