Skip to content

Matrix adapter: no E2EE support (olm/megolm) — encrypted rooms unreachable #1177

@dancingclaw

Description

@dancingclaw

Description

The bundled Matrix adapter at crates/openfang-channels/src/matrix.rs is plaintext-only — it has no end-to-end encryption support. Most production Matrix deployments use encrypted rooms by default (Element creates DMs and most new rooms encrypted), so the adapter is effectively unusable in those rooms today.

Verified against v0.6.4 (3cce1eb):

$ wc -l crates/openfang-channels/src/matrix.rs
542 crates/openfang-channels/src/matrix.rs
$ grep -c -iE 'encrypted|olm|megolm' crates/openfang-channels/src/matrix.rs
0

Zero matches for encrypted, olm, or megolm — no olm/megolm session management, no m.room.encrypted decryption, no outbound encryption, no key recovery, no cross-signing.

Expected Behavior

When [channels.matrix] is configured against a bot account that lives in encrypted rooms:

  1. Inbound m.room.encrypted events are decrypted using a persisted olm/megolm session store (typical pattern: SQLite store keyed by a stable device_id).
  2. Outbound replies into encrypted rooms are encrypted with the room's megolm session.
  3. A configurable cross-signing / recovery-key option exists so the device can verify itself across restarts and key rotations.
  4. The session/crypto store survives daemon restarts.

For comparison: matrix-rust-sdk (LGPL/MIT in apps that depend on it via the standard Cargo path; the SDK itself is Apache-2.0) provides this out of the box via Client::builder().sqlite_store(..).build() with the e2e-encryption + sqlite features. The Hermes project's gateway/platforms/matrix.py uses the equivalent in mautrix-python (mautrix[encryption]) and serves as a reference for what the surface area looks like.

Steps to Reproduce

  1. Create a Matrix bot account on any homeserver.
  2. Invite the bot into a default-encrypted room (Element-created DM works).
  3. Configure OpenFang v0.6.4 with [channels.matrix] pointing at that account.
  4. From the room, send the bot a message.
  5. Observe the bot either silently drops the event or logs an inability to decrypt; outbound responses are sent unencrypted (and rejected/undecryptable by encrypted-room participants).

OpenFang Version

0.6.4 (commit 3cce1eb3fb19ad590a0937e039a8bf8bc09aba13)

Operating System

macOS (Apple Silicon) and Linux x86_64 — the gap is substrate-independent (it is a missing implementation, not a build issue).

Logs / Screenshots

Indirect evidence — the source itself:

$ grep -c -iE 'encrypted|olm|megolm' crates/openfang-channels/src/matrix.rs
0

When deployed in an encrypted room, downstream symptoms are typically:

  • m.room.encrypted events with empty body and algorithm: "m.megolm.v1.aes-sha2"
  • Outbound messages visible only to non-encrypted observers / not decryptable by room members

Suggested Direction

Two reasonable paths:

  1. Re-host the adapter on matrix-rust-sdk — the Rust-native SDK with first-class olm/megolm + SqliteCryptoStore + cross-signing. Pro: minimal surface to maintain, idiomatic Rust. Con: adds a fairly large dep tree.
  2. Document the gap and recommend a host-side sidecar for E2EE-required deployments, with the bundled adapter explicitly marked plaintext-only in the docs.

Happy to test against a branch and provide a reference deployment if helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-designNeeds architecture discussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions