Skip to content
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

Don't re-establish sessions with unknown devices #792

Merged
merged 1 commit into from
Nov 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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