From 903a117bf71529b2498bb39e230e522eefb380b4 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 12 Feb 2019 15:22:53 -0800 Subject: [PATCH] ircd::m::event::conforms: Add check for room_id host matching sender host for create event. --- include/ircd/m/event/conforms.h | 1 + ircd/m_event.cc | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/ircd/m/event/conforms.h b/include/ircd/m/event/conforms.h index 24f64fdea..dca1b15d8 100644 --- a/include/ircd/m/event/conforms.h +++ b/include/ircd/m/event/conforms.h @@ -71,6 +71,7 @@ enum ircd::m::event::conforms::code MISSING_ORIGIN_SIGNATURE, ///< no signature for origin MISMATCH_ORIGIN_SENDER, ///< sender mxid host not from origin MISMATCH_ORIGIN_EVENT_ID, ///< event_id mxid host not from origin + MISMATCH_CREATE_SENDER, ///< m.room.create room_id host != sender host SELF_REDACTS, ///< event redacts itself SELF_PREV_EVENT, ///< event_id self-referenced in prev_events SELF_PREV_STATE, ///< event_id self-referenced in prev_state diff --git a/ircd/m_event.cc b/ircd/m_event.cc index 3b4ca7380..84d31e61b 100644 --- a/ircd/m_event.cc +++ b/ircd/m_event.cc @@ -175,6 +175,7 @@ ircd::m::event_conforms_reflects "MISSING_ORIGIN_SIGNATURE", "MISMATCH_ORIGIN_SENDER", "MISMATCH_ORIGIN_EVENT_ID", + "MISMATCH_CREATE_SENDER", "SELF_REDACTS", "SELF_PREV_EVENT", "SELF_PREV_STATE", @@ -263,6 +264,10 @@ ircd::m::event::conforms::conforms(const event &e) if(json::get<"origin"_>(e) != m::id::event{json::get<"event_id"_>(e)}.host()) set(MISMATCH_ORIGIN_EVENT_ID); + if(json::get<"type"_>(e) == "m.room.create") + if(m::room::id(json::get<"room_id"_>(e)).host() != m::user::id(json::get<"sender"_>(e)).host()) + set(MISMATCH_CREATE_SENDER); + if(json::get<"type"_>(e) == "m.room.redaction") if(!valid(m::id::EVENT, json::get<"redacts"_>(e))) set(INVALID_OR_MISSING_REDACTS_ID);