From 52562c42275dc1152feeb853b6ff295b2b10faad Mon Sep 17 00:00:00 2001 From: timedout Date: Mon, 9 Nov 2026 16:13:51 +0000 Subject: [PATCH] fix: SEC15 Reviewed-By: Jade Ellis Reviewed-By: Ginger --- src/service/rooms/state_accessor/user_can.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/service/rooms/state_accessor/user_can.rs b/src/service/rooms/state_accessor/user_can.rs index 4754935ee..7e7340bc6 100644 --- a/src/service/rooms/state_accessor/user_can.rs +++ b/src/service/rooms/state_accessor/user_can.rs @@ -77,12 +77,20 @@ impl super::Service { room_id: &RoomId, event_id: &EventId, ) -> bool { - let Ok(shortstatehash) = self.pdu_shortstatehash(event_id).await else { - return true; - }; - let currently_member = self.services.state_cache.is_joined(user_id, room_id).await; + let Ok(shortstatehash) = self.pdu_shortstatehash(event_id).await else { + // We haven't calculated the state at this event, so we can't + // properly history visibility check it. This happens for outliers + // and backfilled events. Since continuwuity is primarily targeting + // single-user/trusted deployments, an acceptable compromise for now + // is to ensure that the user is currently joined to the room. + // Federation fails closed here, but if that was replicated for the + // check used for client-server, nobody would be allowed to see + // events before their server started participating in the room. + return currently_member; + }; + let history_visibility = self .state_get_content(shortstatehash, &StateEventType::RoomHistoryVisibility, "") .await