|
|
Subscribe / Log in / New account

Matrix: a new specification for federated realtime chat

Matrix: a new specification for federated realtime chat

Posted Feb 15, 2015 17:49 UTC (Sun) by deepfire (guest, #26138)
Parent article: Matrix: a new specification for federated realtime chat

How does Matrix relate/compare to TextSecure?

Some context: in the modern world, it seems that a protocol not grounded in security is.. counterproductive, I'd say.


to post comments

Matrix: a new specification for federated realtime chat

Posted Feb 20, 2015 1:15 UTC (Fri) by Arathorn (guest, #101018) [Link] (2 responses)

To say that Matrix isn't grounded in security is a bit unfair. We've designed it with the intention of supporting E2E crypto from day 1 - but we just haven't finished implementing it yet.

The bits where crypto is fundamental to the robustness of the implementation are already in place. All server maintain keypairs. Message history integrity is all signed (like git). All replication transactions are all signed to protect against server identity spoofing. All federated traffic is TLSed.

As regards E2E, we actually (finally) started implementing it last week.

TextSecure is really nice - it uses Axolotl for a PFS key ratchet, and for group chat I believe each message is encrypted once with a ephemeral symmetric key, and the key are then sent 1:1 to all recipients using the 1:1 ratchet. The code seems good, and Moxie clearly knows his stuff.

However, if we deployed the TextSecure architecture to Matrix, we have a major problem: Matrix is all about storing history on a bunch of servers and synchronising it on demand to multiple clients. How can this ever work with PFS? New clients would never be able to replay past history by definition, as the keys to decode the old messages were ephemeral and have been lost. Moreover, existing clients could never expire history and re-lazy-load it in from the server, as the keys again will have been lost.

So our strategy in the E2E implementation for Matrix is to actually support a spectrum of PFS-ness, configurable per room. At one end of the spectrum, each room has a single symmetric key throughout its lifetime, which is shared securely 1:1 between the participants when they are invited into the room. This allows all past & future history to be decrypted. At the other end of the spectrum, you have pure PFS - each message has its own ephemeral key, and once the message has been pulled off the server, you might as well delete it from the server as you'll never be able to decode it again (unless the client keeps all the keys for all the messages it ever receives... at which point it might as well just be storing the decrypted messages).

In the middle of the spectrum it gets more interesting: you have the ability to specify encrypted subsets of data within the room, each with encrypted with its own symmetric key. In the simplest case, you could split the timeline of the room up into epochs. Only participants who have the key for that epoch can ever decrypt it. This lets you invite new participants in without leaking past history by rekeying the room when you invite someone - or lets you kick people out and rekey the room to avoid them decrypting it in future. The clients store non-ephemeral keys for as long as they care about decrypting the contents of the room on the server, and the usefulness of the matrix synchronised history is preserved.

In practice, we expect that this will be the common case. Rooms get created with a symmetric key; when users invite or kick people from the room they have the option to rekey the room to segregate history. Alternatively, the seriously tin-foil-hatted of us can enable PFS when creating the room, which will hopefully provide compatibility with TextSecure, and ensure that a single compromised key can never compromise any other history. However, this will obviously stop history synchronisation from being meaningful - your history will be stored on your clients, and only on your clients. (Don't to check for keyloggers!)

We expect to have the E2E implementation finished in the next 1-2 months. Getting the core state replication subsystem stable and performant is alas going to have to take priority in the interim.

Matrix: a new specification for federated realtime chat

Posted Feb 21, 2015 7:58 UTC (Sat) by eternaleye (guest, #67051) [Link] (1 responses)

I'd argue that even with PFS, history sync is meaningful for a few reasons:
  1. Storage - if the client is only storing fixed-size keys, rather than variable-sized records, small clients (like phones) will be able to keep more history
  2. Reliability - fixed-size keys can trivially be saved as a packed array, either of keys or of {timestamp, key} tuples (for searching efficiency), while variably-length messages require more complex (and failure-prone) storage
  3. Verification - if the messages are encrypted using AEAD (and they should be!), keeping the key allows you to revalidate that yes, this _is_ the same message that was originally sent.
  4. Simplicity - keeping the behavior of history sync the same even with PFS reduces the number of corner cases to handle in the code (and possibly the protocol).
  5. Sharing - you want to show someone a past message, and you want them to trust that it actually happened when you say it did (and possibly the context, which are just more messages). If the server still has it, this is trivial: Send them the message identifier and the key, and let them fetch it themselves. This allows treating keys as read-capabilities for historic messages, which is a useful tool indeed.

Matrix: a new specification for federated realtime chat

Posted Feb 22, 2015 23:46 UTC (Sun) by Arathorn (guest, #101018) [Link]

Agreed on all scores. I guess we had been obsessing about throwing away PFS keys as rapidly as possible, but if we deliberately keep a cache around for these use cases it certainly make matrix's history more useful. So we'll define a configurable limit per-room for the amount of keys the user wants to cache. Thanks for the feedback :)


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds