Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only the initial chunk of events gets decrypted if events are loaded from the event cache store. #4762

Open
poljar opened this issue Mar 6, 2025 · 1 comment · May be fixed by #4794
Open
Assignees

Comments

@poljar
Copy link
Contributor

poljar commented Mar 6, 2025

When using the event cache with storage enabled, events are persisted in the database. Since room keys may not always arrive in the same sync as the event—sometimes arriving later—it is expected that m.room.encrypted events will be stored in the event cache.

Upon reloading and inserting these events into the timeline, the initial chunk of events will get decrypted during timeline construction:

if has_events {
// The events we're injecting might be encrypted events, but we might
// have received the room key to decrypt them while nobody was listening to the
// `m.room_key` event, let's retry now.
timeline.retry_decryption_for_all_events().await;
}

However, when additional events are loaded from the cache, no decryption logic is exists. As a result, undecryptable events (UTDs) will not fix themselves unless the application explicitly requests a redecryption.

@bnjbvr
Copy link
Member

bnjbvr commented Mar 6, 2025

I think the way to fix this would be:

  • make sure that paginations that come from the cache have an Cache event origin. (I think that's not the case, and they're marked as Pagination if coming from network || storage.)
  • then in the timeline, when handling vector diffs which do any kind of insertions, for events originated from the cache, spawn a task trying to decrypt them (or send them via a channel, or whatever is done at the moment to signal that some items must be re-decrypted).

Of course, a better fix would be #3872.

@bnjbvr bnjbvr self-assigned this Mar 6, 2025
@bnjbvr bnjbvr removed their assignment Mar 11, 2025
@Hywan Hywan self-assigned this Mar 12, 2025
Hywan added a commit to Hywan/matrix-rust-sdk that referenced this issue Mar 12, 2025
This patch fixes a bug where events coming from the event cache might be
encrypted, see matrix-org#4762
to learn more.

This patch updates the `room_event_cache_updates_task` to call
`TimelineController::retry_event_decryption` if the origin is `Cache`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants