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

Not robust against invalid state event

Open bmarty opened this issue 1 year ago • 1 comments

I have a room with this m.room.join_rules state event:

{
  "content": {
    "join_rule": "publictest"
  },
  "origin_server_ts": 1613508609851,
  "sender": "@benoitx:matrix.org",
  "state_key": "",
  "type": "m.room.join_rules",
  "unsigned": {
    "replaces_state": "$FZOkUjJvHm8mTuUkJBDhTOS86xfq17rZuxo0MRKBwH8",
    "age": 83365036681
  }

which is not valid regarding the Matrix specs, but the server did not perform any validation when I sent it, so it's there and the SDK must accept it and ignore any invalid value.

When I send a message to this room, I have got this error in loop:

matrix_sdk_ui::sync_service: Error while processing room list in sync service: SlidingSync failed: the enum variant JoinRule::_Custom cannot be serialized | crates/matrix-sdk-ui/src/sync_service.rs:283.

Then the app becomes unusable, because the sync is restarted automatically in case of error. This is another issue that we will have to handle on the app side.

Rageshake: https://github.com/element-hq/element-x-android-rageshakes/issues/1210

This is how we mitigated this on the Kotlin SDK: https://github.com/element-hq/element-android/pull/3062

bmarty avatar Dec 14 '23 21:12 bmarty

My wild guess would be the "hacky/temporary" caching of the events that's happening in sliding sync, failing because there's an invalid event. We could try to filter out custom events before serializing them, would be fun to see if Ruma allows to do this without going too further into details of the event types.

bnjbvr avatar Dec 18 '23 09:12 bnjbvr