mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-30 20:37:36 +00:00
1 parent
84082a6515
commit
347048c35f
2 files changed
+36
-6
No files matched your search
@@ -0,0 +1 @@
|
||||
SEC51 fix. See <https://forgejo.ellis.link/continuwuation/advisories> at a later date for more info. Contributed by @jade.
|
||||
@@ -32,16 +32,36 @@ impl super::Service {
|
||||
{
|
||||
// Skip outlier handling if we already have this event as either a
|
||||
// timeline or outlier PDU.
|
||||
if let Ok(pdu_event) = self.services.timeline.get_pdu(event_id).await {
|
||||
if let Ok(mut db_pdu_json) = self.services.timeline.get_pdu_json(event_id).await {
|
||||
if self.services.pdu_metadata.is_event_rejected(event_id).await {
|
||||
return Err!(Request(Forbidden(debug_warn!(
|
||||
"Outlier event {event_id} was previously rejected"
|
||||
))));
|
||||
}
|
||||
|
||||
db_pdu_json.remove("unsigned");
|
||||
db_pdu_json.insert(
|
||||
"event_id".to_owned(),
|
||||
CanonicalJsonValue::String(event_id.as_str().to_owned()),
|
||||
);
|
||||
let pdu_event =
|
||||
PduEvent::from_id_val(event_id, db_pdu_json.clone()).map_err(|e| {
|
||||
err!(Database("Stored PDU {event_id} is not a valid PduEvent: {e}"))
|
||||
})?;
|
||||
if pdu_event.room_id_or_hash() != room_id {
|
||||
return Err!(Request(Forbidden(debug_warn!(
|
||||
%event_id,
|
||||
pdu_room_id = %pdu_event.room_id_or_hash(),
|
||||
expected_room_id = %room_id,
|
||||
"Stored PDU belongs to a different room"
|
||||
))));
|
||||
}
|
||||
|
||||
debug!(
|
||||
"Database hit for {event_id} (event is either an outlier or already promoted), \
|
||||
skipping outlier handling"
|
||||
);
|
||||
value.insert(
|
||||
"event_id".to_owned(),
|
||||
CanonicalJsonValue::String(event_id.as_str().to_owned()),
|
||||
);
|
||||
return Ok((pdu_event, value));
|
||||
return Ok((pdu_event, db_pdu_json));
|
||||
}
|
||||
|
||||
// 1. Check that the PDU follows the format for the room version
|
||||
@@ -74,6 +94,15 @@ impl super::Service {
|
||||
)
|
||||
.map_err(|e| err!(Request(BadJson(debug_warn!("Event is not a valid PDU: {e}")))))?;
|
||||
|
||||
if pdu_event.room_id_or_hash() != room_id {
|
||||
return Err!(Request(Forbidden(debug_warn!(
|
||||
%event_id,
|
||||
pdu_room_id = %pdu_event.room_id_or_hash(),
|
||||
expected_room_id = %room_id,
|
||||
"Incoming PDU belongs to a different room"
|
||||
))));
|
||||
}
|
||||
|
||||
// TODO(nex): From hereon the event is not dropped, and thus always
|
||||
// added as an outlier. However, we only do that at the end of this
|
||||
// function, which means several duplicated calls to add_pdu_outlier.
|
||||
|
||||
Reference in new issue
Block a user