-
-
Notifications
You must be signed in to change notification settings - Fork 606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve setRoomEncryption guard against multiple m.room.encryption st… #700
Conversation
…ate events we were only bailing out when receiving a non JSON-identical m.room.encryption event. When receiving an identical event, the algorithm in _roomEncryptors would be reset, generating a new megolm session every time this happens (there is a LL synapse bug where this happens on every sync). As the _roomList is backed by indexeddb you might already have a config without the algorithm being present though, so we first check for the room encryptor algorithm being present. If so, always bail out as setRoomEncryption was already called for the given room. If no algorithm is present, still check if the config is not being changed. Also setup the roomlist and room encryption synchronously before awaiting the indexeddb operation to store the room encryption config in roomlist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise looks good apart from variable declaration
src/crypto/index.js
Outdated
console.error("Ignoring m.room.encryption event which requests " + | ||
"a change of config in " + roomId); | ||
const existingAlg = this._roomEncryptors[roomId]; | ||
if (existingAlg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be nice to keep the console error in the case that we get an encryption event that's different to what we previously had, since this is a sign something fishy is going on with crypto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasn't it just moved a few lines down? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, no it hasn't. yeah; let's keep this warning in place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 should be ready for another look
…ate events
we were only bailing out when receiving a non JSON-identical m.room.encryption event.
When receiving an identical event, the algorithm in _roomEncryptors would be reset,
generating a new megolm session every time this happens (there is a LL synapse bug
where this happens on every sync).
As the _roomList is backed by indexeddb you might already have a config without the algorithm being present though,
so we first check for the room encryptor algorithm being present. If so, always bail out as setRoomEncryption was
already called for the given room.
If no algorithm is present, still check if the config is not being changed.
Also setup the roomlist and room encryption synchronously before awaiting
the indexeddb operation to store the room encryption config in roomlist.
Fixes element-hq/element-web#7223 / element-hq/element-web#7222