0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-26 00:32:35 +01:00

ircd:Ⓜ️:event::conforms: Add check for room_id host matching sender host for create event.

This commit is contained in:
Jason Volk 2019-02-12 15:22:53 -08:00
parent 1bd9ce0d1e
commit 903a117bf7
2 changed files with 6 additions and 0 deletions

View file

@ -71,6 +71,7 @@ enum ircd::m::event::conforms::code
MISSING_ORIGIN_SIGNATURE, ///< no signature for origin MISSING_ORIGIN_SIGNATURE, ///< no signature for origin
MISMATCH_ORIGIN_SENDER, ///< sender mxid host not from origin MISMATCH_ORIGIN_SENDER, ///< sender mxid host not from origin
MISMATCH_ORIGIN_EVENT_ID, ///< event_id 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_REDACTS, ///< event redacts itself
SELF_PREV_EVENT, ///< event_id self-referenced in prev_events SELF_PREV_EVENT, ///< event_id self-referenced in prev_events
SELF_PREV_STATE, ///< event_id self-referenced in prev_state SELF_PREV_STATE, ///< event_id self-referenced in prev_state

View file

@ -175,6 +175,7 @@ ircd::m::event_conforms_reflects
"MISSING_ORIGIN_SIGNATURE", "MISSING_ORIGIN_SIGNATURE",
"MISMATCH_ORIGIN_SENDER", "MISMATCH_ORIGIN_SENDER",
"MISMATCH_ORIGIN_EVENT_ID", "MISMATCH_ORIGIN_EVENT_ID",
"MISMATCH_CREATE_SENDER",
"SELF_REDACTS", "SELF_REDACTS",
"SELF_PREV_EVENT", "SELF_PREV_EVENT",
"SELF_PREV_STATE", "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()) if(json::get<"origin"_>(e) != m::id::event{json::get<"event_id"_>(e)}.host())
set(MISMATCH_ORIGIN_EVENT_ID); 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(json::get<"type"_>(e) == "m.room.redaction")
if(!valid(m::id::EVENT, json::get<"redacts"_>(e))) if(!valid(m::id::EVENT, json::get<"redacts"_>(e)))
set(INVALID_OR_MISSING_REDACTS_ID); set(INVALID_OR_MISSING_REDACTS_ID);