Skip to content

MSC4268: Sharing room keys for past messages#4268

Open
richvdh wants to merge 14 commits intomainfrom
rav/proposal/encrypted_history_sharing
Open

MSC4268: Sharing room keys for past messages#4268
richvdh wants to merge 14 commits intomainfrom
rav/proposal/encrypted_history_sharing

Conversation

@richvdh
Copy link
Copy Markdown
Member

@richvdh richvdh commented Feb 24, 2025

A proposal for sharing the keys to existing room messages when inviting someone to a room.

This reintroduces the functionality previously proposed in MSC3061.

Conflict of Interest declaration: I am employed by Element. This MSC was written as part of my work on the Element Cryptography team.

The functionality discussed here is implemented in current versions of Element Web and Element X.

Rendered

MSC checklist
FCP tickyboxes

@turt2live turt2live added e2e proposal A matrix spec change proposal client-server Client-Server API kind:core MSC which is critical to the protocol's success needs-implementation This MSC does not have a qualifying implementation for the SCT to review. The MSC cannot enter FCP. labels Feb 24, 2025
@richvdh

This comment was marked as resolved.

poljar added a commit to ruma/ruma that referenced this pull request Jun 27, 2025
poljar added a commit to ruma/ruma that referenced this pull request Jun 27, 2025
zecakeh pushed a commit to ruma/ruma that referenced this pull request Jun 27, 2025
zecakeh pushed a commit to ruma/ruma that referenced this pull request Jul 3, 2025
kaylendog added a commit to matrix-org/matrix-rust-sdk that referenced this pull request Dec 19, 2025
…cryption-info

feat: Add `forwarder: ForwarderInfo` to `EncryptionInfo`.

Introduces `ForwarderInfo` which which exposes information about the forwarder of the  keys with which an event was encrypted if they were shared as part of an [MSC4268](matrix-org/matrix-spec-proposals#4268) room key bundle.
kaylendog added a commit to matrix-org/matrix-sdk-crypto-wasm that referenced this pull request Jan 6, 2026
Expose information about the forwarder for events that were decrypted using a key from an [MSC4268](matrix-org/matrix-spec-proposals#4268) key bundle.

Signed-off-by: Skye Elliot <actuallyori@gmail.com>
@richvdh richvdh changed the title WIP: MSC4268: Sharing room keys for past messages MSC4268: Sharing room keys for past messages Jan 15, 2026
@richvdh richvdh marked this pull request as ready for review January 15, 2026 17:14
@turt2live turt2live self-requested a review January 15, 2026 17:36
@richvdh richvdh force-pushed the rav/proposal/encrypted_history_sharing branch from 2abbf2b to b7056c2 Compare March 10, 2026 12:40
however, that this process must be resilient to Bob's client being restarted
before the download/import completes.

The definition of "recently" is left up to clients. (They should consider
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 think this is a mistake. This value determines how long the key bundle must be stored on the server (e.g. in the case of a partial download before the client was closed). By leaving "recently" undefined, we lose any ability to set reasonable TTLs on this data.

As a general design goal, I do not think we should be writing APIs which allow unbounded data to accumulate. This is what this is doing.

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.

Imposing a limit in the spec feels like we'd also be limiting use cases. Instead, because clients with slightly obscure requirements (such as availability) are typically attached to servers which are aware of those requirements, we can likely move this timeout in part to the server.

The client should still make its own decisions about what to request, but the server should also decide how long it keeps bundles around for. These two values may not be the same, and can lead to download failures: this is acceptable, in my opinion. A future MSC can introduce a re-request mechanism if it becomes a high enough priority issue.

(this is non-blocking for FCP in my opinion: I'm fine with the text as-written, but would appreciate a note that the server might delete things before the client can request it)

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.

@turt2live I basically agree with you, but it's worth noting that a server has no means of distinguishing a key bundle from any other piece of encrypted media (other than via side-channels), so it might be hard for a server to apply a sensible timeout.

We could find some way to decorate it, if we considered it important.

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.

Yea, I'd expect it to be decorated by some timeout or ephemeral flag that could theoretically be used by other media (but won't be)

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.

Ok, so I guess that would mean:

I guess this might also help solve the incompatibility with MSC3911?

We (Element crypto team) are keen to release this feature soon, rather than get it too bogged down in spec hell, so I'd appreciate a temperature reading on this from SCT members (and @kegsay, as the OP on this thread): maybe you could use the apache voting scale to express your feelings on shipping without a way for clients to indicate that a specific media upload is actually a key bundle.

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 personally think it would be beneficial to flag to the server that this is a key bundle. However, we know that MSC3911 is something that we'll (eventually) do and so we'll need to annotate these bundles in some way anyway, so I don't really care if we punt that question until then.

I think we should note in the MSC that servers may delete media based on last usage, and so clients cannot assume that the bundle will be around forever (and downloading may fail).

@richvdh richvdh removed the needs-implementation This MSC does not have a qualifying implementation for the SCT to review. The MSC cannot enter FCP. label Mar 11, 2026
@richvdh
Copy link
Copy Markdown
Member Author

richvdh commented Mar 11, 2026

MSC Checklist

This document contains a list of final checks to perform on an MSC before it
is accepted. The purpose is to prevent small clarifications needing to be
made to the MSC after it has already been accepted.

Spec Core Team (SCT) members, please ensure that all of the following checks
pass before accepting a given Matrix Spec Change (MSC).

MSC authors, feel free to ask in a thread on your PR or in the
#matrix-spec:matrix.org room for
clarification of any of these points.

  • Are appropriate implementation(s)
    specified in the MSC’s PR description?
  • [n/a] Are all MSCs that this MSC depends on already accepted?
  • [n/a] For each new endpoint that is introduced:
    • [n/a] Have authentication requirements been specified?
    • [n/a] Have rate-limiting requirements been specified?
    • [n/a] Have guest access requirements been specified?
    • [n/a] Are error responses specified?
      • [n/a] Does each error case have a specified errcode (e.g. M_FORBIDDEN) and HTTP status code?
        • [n/a] If a new errcode is introduced, is it clear that it is new?
  • [no] Will the MSC require a new room version, and if so, has that been made clear?
    • [n/a] Is the reason for a new room version clearly stated? For example,
      modifying the set of redacted fields changes how event IDs are calculated,
      thus requiring a new room version.
  • Are backwards-compatibility concerns appropriately addressed?
  • [n/a] Are the endpoint conventions honoured?
    • [n/a] Do HTTP endpoints use_underscores_like_this?
    • [n/a] Will the endpoint return unbounded data? If so, has pagination been considered?
    • [n/a] If the endpoint utilises pagination, is it consistent with
      the appendices?
  • An introduction exists and clearly outlines the problem being solved.
    Ideally, the first paragraph should be understandable by a non-technical audience.
  • All outstanding threads are resolved
    • All feedback is incorporated into the proposal text itself, either as a fix or noted as an alternative
  • While the exact sections do not need to be present,
    the details implied by the proposal template are covered. Namely:
    • Introduction
    • Proposal text
    • Potential issues
    • Alternatives
    • Dependencies
  • Stable identifiers are used throughout the proposal, except for the unstable prefix section
    • Unstable prefixes consider the awkward accepted-but-not-merged state
    • Chosen unstable prefixes do not pollute any global namespace (use “org.matrix.mscXXXX”, not “org.matrix”).
  • Changes have applicable Sign Off from all authors/editors/contributors
  • There is a dedicated "Security Considerations" section which detail
    any possible attacks/vulnerabilities this proposal may introduce, even if this is "None.".
    See RFC3552 for things to think about,
    but in particular pay attention to the OWASP Top Ten.

@richvdh
Copy link
Copy Markdown
Member Author

richvdh commented Mar 11, 2026

I think this is ready for FCP.

@mscbot fcp merge

@mscbot
Copy link
Copy Markdown
Collaborator

mscbot commented Mar 11, 2026

Team member @richvdh has proposed to merge this. The next step is review by the rest of the tagged people:

Once at least 75% of reviewers approve (and there are no outstanding concerns), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for information about what commands tagged team members can give me.

@mscbot mscbot added proposed-final-comment-period Currently awaiting signoff of a majority of team members in order to enter the final comment period. disposition-merge labels Mar 11, 2026
@github-project-automation github-project-automation bot moved this to Tracking for review in Spec Core Team Workflow Mar 11, 2026
@richvdh richvdh moved this from Tracking for review to Ready for FCP ticks in Spec Core Team Workflow Mar 11, 2026
@turt2live turt2live added the 00-weekly-pings Tracking for weekly pings in the SCT office. 00 to make it first in the labels list. label Mar 11, 2026
Copy link
Copy Markdown
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

no blocking concerns - thank you!

however, that this process must be resilient to Bob's client being restarted
before the download/import completes.

The definition of "recently" is left up to clients. (They should consider
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.

Imposing a limit in the spec feels like we'd also be limiting use cases. Instead, because clients with slightly obscure requirements (such as availability) are typically attached to servers which are aware of those requirements, we can likely move this timeout in part to the server.

The client should still make its own decisions about what to request, but the server should also decide how long it keeps bundles around for. These two values may not be the same, and can lead to download failures: this is acceptable, in my opinion. A future MSC can introduce a re-request mechanism if it becomes a high enough priority issue.

(this is non-blocking for FCP in my opinion: I'm fine with the text as-written, but would appreciate a note that the server might delete things before the client can request it)

Co-authored-by: Hubert Chathi <hubert@uhoreg.ca>
until we have authenticated backups (MSC4048). This is tracked at
https://github.com/matrix-org/matrix-rust-sdk/issues/5110.

## Potential issues
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.

How big can this bundle get? Will (de)serializing it cause potential memory issues with clients? Do we need to allow for multiple?

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.

It's limited only by the size limits on the media store (e.g. 50MB by default for Synapse, 10MB for matrix.org's free tier). Some discussion about this here.

We're basically assuming that clients can safely decrypt and hold in memory anything that the media store can send them, so I'm not too worried about us blowing out memory limits.

At the other end, it has to be said that matrix.org's paid tiers have been introduced since we started this project, and it's not inconceivable that people will hit the 10MB limit if they invite someone to a massive encrypted room. That said (a) that sounds like the level of usage where they should be either paying or going elsewhere, and (b) even if we want to support multiple bundles in future, I'd much rather leave that until we're sure we need it.

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.

Thanks, I'm not sure if any of this is worth adding to the MSC? Maybe just a "clients may generate a file too large to upload, in which case they should do X"? Not sure it is worth it as a callout.

* Ideally, the bundle would be deleted once the recipient has successfully
downloaded it. An implementation is left for a future MSC, such as
[MSC4425](https://github.com/matrix-org/matrix-spec-proposals/pull/4425). This
is tracked at https://github.com/matrix-org/matrix-rust-sdk/issues/5113.
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.

Deleting the bundles being out of scope feels very not nice, but I guess it's not the end of the world since it's encrypted with AES-256 which isn't expected to be cracked by quantum computers

@@ -0,0 +1,468 @@
# MSC4268: Sharing room keys for past messages
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.

My two main concerns on this MSC are:

  • Without the ability to delete key bundles once they've been consumed by the invited user, we accumulate encrypted key material in a way which is tantamount to harvest-now-decrypt-later attacks. However, given MSC4425 (or other ephemeral MSCs) are on the radar, I'm (just about) happy to for this to progress on the understanding that we follow up afterwards rapidly with MSC4425 or similar.

  • In terms of use experience, it's really not obvious to me that the common case should be to share all possible keys with an invited user. Sometimes this will be important (e.g. knowledge transfer to a new user joining a team/org) - but sometimes it will be very undesirable even if the room has shared history viz, particularly if the history viz been changed back and forth over time. I suspect that an approach similar to the WhatsApp idiom of "how much history do you want to share with the new user? nothing? 1 msg? 100 msgs? everything?" might help with this. However: this is a client UX question and is already supported by the MSC.

So, neither of these points end up being blocking, although both make me quite uncomfortable with the proposal. I'll checkbox it to proceed, but please can we track these concerns on the Element crypto-team agenda so they're not lost.

@mscbot
Copy link
Copy Markdown
Collaborator

mscbot commented Apr 2, 2026

🔔 This is now entering its final comment period, as per the review above. 🔔

@mscbot mscbot added final-comment-period This MSC has entered a final comment period in interest to approval, postpone, or delete in 5 days. and removed proposed-final-comment-period Currently awaiting signoff of a majority of team members in order to enter the final comment period. labels Apr 2, 2026
@turt2live turt2live removed the 00-weekly-pings Tracking for weekly pings in the SCT office. 00 to make it first in the labels list. label Apr 2, 2026
@turt2live turt2live moved this from Ready for FCP ticks to In FCP in Spec Core Team Workflow Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client-server Client-Server API disposition-merge e2e final-comment-period This MSC has entered a final comment period in interest to approval, postpone, or delete in 5 days. kind:core MSC which is critical to the protocol's success proposal A matrix spec change proposal

Projects

Status: In FCP

Development

Successfully merging this pull request may close these issues.