You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-29 16:43:09 +03:00
Don't re-establish sessions with unknown devices
as it won't work
This commit is contained in:
@@ -1453,19 +1453,26 @@ Crypto.prototype._onToDeviceBadEncrypted = async function(event) {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._lastNewSessionForced[sender][deviceKey] = Date.now();
|
|
||||||
|
|
||||||
// establish a new olm session with this device since we're failing to decrypt messages
|
// establish a new olm session with this device since we're failing to decrypt messages
|
||||||
// on a current session.
|
// on a current session.
|
||||||
// Note that an undecryptable message from another device could easily be spoofed -
|
// Note that an undecryptable message from another device could easily be spoofed -
|
||||||
// is there anything we can do to mitigate this?
|
// is there anything we can do to mitigate this?
|
||||||
const device = this._deviceList.getDeviceByIdentityKey(algorithm, deviceKey);
|
const device = this._deviceList.getDeviceByIdentityKey(algorithm, deviceKey);
|
||||||
|
if (!device) {
|
||||||
|
logger.info(
|
||||||
|
"Couldn't find device for identity key " + deviceKey +
|
||||||
|
": not re-establishing session",
|
||||||
|
);
|
||||||
|
}
|
||||||
const devicesByUser = {};
|
const devicesByUser = {};
|
||||||
devicesByUser[sender] = [device];
|
devicesByUser[sender] = [device];
|
||||||
await olmlib.ensureOlmSessionsForDevices(
|
await olmlib.ensureOlmSessionsForDevices(
|
||||||
this._olmDevice, this._baseApis, devicesByUser, true,
|
this._olmDevice, this._baseApis, devicesByUser, true,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this._lastNewSessionForced[sender][deviceKey] = Date.now();
|
||||||
|
|
||||||
// Now send a blank message on that session so the other side knows about it.
|
// Now send a blank message on that session so the other side knows about it.
|
||||||
// (The keyshare request is sent in the clear so that won't do)
|
// (The keyshare request is sent in the clear so that won't do)
|
||||||
// We send this first such that, as long as the toDevice messages arrive in the
|
// We send this first such that, as long as the toDevice messages arrive in the
|
||||||
|
|||||||
Reference in New Issue
Block a user