Skip to content

Commit 1dcb7a6

Browse files
committed
Remove insecure MatrixClient.sendSharedHistoryKeys method
This method is impossible to use securely, and so is being removed. (It also didn't work under Rust cryptography.) In future, this functionality may be re-introduced in a safer way, but doing so will probably require updates to the MSC.
1 parent 823316b commit 1dcb7a6

File tree

1 file changed

+0
-37
lines changed

1 file changed

+0
-37
lines changed

src/client.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4087,43 +4087,6 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
40874087
await this.http.authedRequest(Method.Delete, path.path, path.queryData, undefined, { prefix: ClientPrefix.V3 });
40884088
}
40894089

4090-
/**
4091-
* Share shared-history decryption keys with the given users.
4092-
*
4093-
* @param roomId - the room for which keys should be shared.
4094-
* @param userIds - a list of users to share with. The keys will be sent to
4095-
* all of the user's current devices.
4096-
*
4097-
* @deprecated Do not use this method. It does not work with the Rust crypto stack, and even with the legacy
4098-
* stack it introduces a security vulnerability.
4099-
*/
4100-
public async sendSharedHistoryKeys(roomId: string, userIds: string[]): Promise<void> {
4101-
if (!this.crypto) {
4102-
throw new Error("End-to-end encryption disabled");
4103-
}
4104-
4105-
const roomEncryption = this.crypto?.getRoomEncryption(roomId);
4106-
if (!roomEncryption) {
4107-
// unknown room, or unencrypted room
4108-
this.logger.error("Unknown room. Not sharing decryption keys");
4109-
return;
4110-
}
4111-
4112-
const deviceInfos = await this.crypto.downloadKeys(userIds);
4113-
const devicesByUser: Map<string, DeviceInfo[]> = new Map();
4114-
for (const [userId, devices] of deviceInfos) {
4115-
devicesByUser.set(userId, Array.from(devices.values()));
4116-
}
4117-
4118-
// XXX: Private member access
4119-
const alg = this.crypto.getRoomDecryptor(roomId, roomEncryption.algorithm);
4120-
if (alg.sendSharedHistoryInboundSessions) {
4121-
await alg.sendSharedHistoryInboundSessions(devicesByUser);
4122-
} else {
4123-
this.logger.warn("Algorithm does not support sharing previous keys", roomEncryption.algorithm);
4124-
}
4125-
}
4126-
41274090
/**
41284091
* Get the config for the media repository.
41294092
* @returns Promise which resolves with an object containing the config.

0 commit comments

Comments
 (0)