Skip to content

Commit

Permalink
Merge pull request matrix-org#792 from matrix-org/dbkr/dont_reestabli…
Browse files Browse the repository at this point in the history
…sh_unknwon_device

Don't re-establish sessions with unknown devices
  • Loading branch information
dbkr committed Nov 28, 2018
2 parents 0fa9484 + 4e66a2d commit bdc1fa4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/crypto/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1453,19 +1453,26 @@ Crypto.prototype._onToDeviceBadEncrypted = async function(event) {
);
return;
}
this._lastNewSessionForced[sender][deviceKey] = Date.now();

// establish a new olm session with this device since we're failing to decrypt messages
// on a current session.
// Note that an undecryptable message from another device could easily be spoofed -
// is there anything we can do to mitigate this?
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 = {};
devicesByUser[sender] = [device];
await olmlib.ensureOlmSessionsForDevices(
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.
// (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
Expand Down

0 comments on commit bdc1fa4

Please sign in to comment.