matrix-rust-sdk icon indicating copy to clipboard operation
matrix-rust-sdk copied to clipboard

`OlmMachine::decrypt_room_event` should detect redacted events and return a different error

Open BillCarsonFr opened this issue 2 years ago • 3 comments

Currently if a redacted event is passed to OlmMachine::decrypt_room_event it will fail with error UnsupportedAlgorithm(?). Given that the event is redacted, there won't be an algorithmfield, so it's expected.

Nonetheless this will produce UTDs for redacted events, and sdk clients could falsely display them as UTD (in ER case report false positive UTD metrics).

Could it be possible to special case redacted event and return a successful decryption with an empty content, of type m.room.message? (and unknown alg)?

Redacted event could be detected by checking existence of unsigned.redacted_because

BillCarsonFr avatar Mar 10 '23 09:03 BillCarsonFr

I don't think we should pretend that it's m.room.message, but yeah this is a bug.

jplatte avatar Mar 10 '23 10:03 jplatte

Ah, I initially thought this was (partially) about the timeline used by EX, but it isn't. @poljar wdyt about checking for unsigned.redacted_because in OlmMachine::decrypt_room_event and returning a new error variant MegolmError::EventIsRedacted?

jplatte avatar Mar 29 '23 14:03 jplatte

Yeah, that sounds better than returning an empty m.room.message.

poljar avatar Mar 29 '23 14:03 poljar