Skip to content

Matrix: bot device shows as 'untrusted' in Element — no cross-signing or bot-initiated SAS verification path #4841

Description

@orrinwitt

Problem

When nanobot connects to a Matrix homeserver with e2eeEnabled: true and sasVerification: true, the bot device appears as "Untrusted" in Element (Web, Desktop, and Element X Android). There is no clean way to clear this warning.

Root Cause

Modern Element clients use cross-signing to determine device trust. Per-device SAS verification alone no longer clears the "Untrusted" label — Element checks for cross-signing key signatures, not individual device verification.

matrix-nio (the library nanobot uses for Matrix E2EE) does not support cross-signing (tracked at matrix-nio/matrix-nio#229, open since 2020). This means:

  • The bot cannot upload cross-signing keys
  • Even after successful SAS verification, Element still shows "Untrusted"
  • Modern Element versions have also removed the UI for manually verifying another user's individual devices

Additional Gap: Bot-initiated verification

The built-in SAS handler (added in v0.2.2 via sasVerification: true) only handles KeyVerificationStart, KeyVerificationKey, KeyVerificationMac, and KeyVerificationCancel events. It does not handle:

  • m.key.verification.request (sent by Element to initiate verification) — arrives as UnknownToDeviceEvent
  • m.key.verification.ready (Element's response accepting the request) — arrives as UnknownToDeviceEvent
  • m.key.verification.done (final confirmation after MAC exchange) — never sent

Without handling request/ready, the SAS flow never starts when a user initiates verification from Element. The bot can only respond to start events, but Element no longer sends start directly — it sends request first.

The bot also has no mechanism to initiate verification toward a user's devices, which is needed since Element removed the manual device verification UI.

Current Workarounds

  1. Accept the cosmetic warning — encryption works (megolm sessions are shared, messages decrypt), the "Untrusted" label is just Element being strict about cross-signing
  2. Disable E2EE (e2eeEnabled: false) — removes encryption and the warning, acceptable for bots on private homeservers but not ideal

Feature Request

  1. Add cross-signing support (depends on Support cross-signing matrix-nio/matrix-nio#229, or implement directly using Olm)
  2. Handle m.key.verification.request and m.key.verification.ready events in the SAS verification flow so Element-initiated verification completes
  3. Send m.key.verification.done after successful MAC exchange
  4. Add bot-initiated verification — allow the bot to start SAS verification toward a user's devices (e.g., a CLI command or API endpoint)

Environment

  • nanobot v0.2.2
  • matrix-nio 0.25.x
  • Homeserver: Continuwuity (also tested with Synapse)
  • Element Web, Element Desktop, Element X Android — all show "Untrusted"
  • e2eeEnabled: true, sasVerification: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions