Skip to content

Commit d2acce1

Browse files
authored
Remove manual device verification which is not supported by the new cryptography stack (element-hq#28588)
* Remove call of `MatrixClient.setDeviceVerified` * Replace usage of deprecated crypto events * Replace deprecated imports * Remove legacy button in `UntrustedDeviceDialog` * Review fixes * Add tests * Fix doc
1 parent b72c053 commit d2acce1

15 files changed

+237
-527
lines changed

src/SecurityManager.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Please see LICENSE files in the repository root for full details.
77
*/
88

99
import { lazy } from "react";
10-
import { ICryptoCallbacks, SecretStorage } from "matrix-js-sdk/src/matrix";
11-
import { deriveRecoveryKeyFromPassphrase, decodeRecoveryKey } from "matrix-js-sdk/src/crypto-api";
10+
import { SecretStorage } from "matrix-js-sdk/src/matrix";
11+
import { deriveRecoveryKeyFromPassphrase, decodeRecoveryKey, CryptoCallbacks } from "matrix-js-sdk/src/crypto-api";
1212
import { logger } from "matrix-js-sdk/src/logger";
1313

1414
import Modal from "./Modal";
@@ -159,7 +159,7 @@ function cacheSecretStorageKey(
159159
}
160160
}
161161

162-
export const crossSigningCallbacks: ICryptoCallbacks = {
162+
export const crossSigningCallbacks: CryptoCallbacks = {
163163
getSecretStorageKey,
164164
cacheSecretStorageKey,
165165
};

src/SlashCommands.tsx

-64
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import VoipUserMapper from "./VoipUserMapper";
4949
import { htmlSerializeFromMdIfNeeded } from "./editor/serialize";
5050
import { leaveRoomBehaviour } from "./utils/leave-behaviour";
5151
import { MatrixClientPeg } from "./MatrixClientPeg";
52-
import { getDeviceCryptoInfo } from "./utils/crypto/deviceInfo";
5352
import { isCurrentLocalRoom, reject, singleMxcUpload, success, successSync } from "./slash-commands/utils";
5453
import { deop, op } from "./slash-commands/op";
5554
import { CommandCategories } from "./slash-commands/interface";
@@ -658,69 +657,6 @@ export const Commands = [
658657
category: CommandCategories.admin,
659658
renderingTypes: [TimelineRenderingType.Room],
660659
}),
661-
new Command({
662-
command: "verify",
663-
args: "<user-id> <device-id> <device-signing-key>",
664-
description: _td("slash_command|verify"),
665-
runFn: function (cli, roomId, threadId, args) {
666-
if (args) {
667-
const matches = args.match(/^(\S+) +(\S+) +(\S+)$/);
668-
if (matches) {
669-
const userId = matches[1];
670-
const deviceId = matches[2];
671-
const fingerprint = matches[3];
672-
673-
return success(
674-
(async (): Promise<void> => {
675-
const device = await getDeviceCryptoInfo(cli, userId, deviceId);
676-
if (!device) {
677-
throw new UserFriendlyError("slash_command|verify_unknown_pair", {
678-
userId,
679-
deviceId,
680-
cause: undefined,
681-
});
682-
}
683-
const deviceTrust = await cli.getCrypto()?.getDeviceVerificationStatus(userId, deviceId);
684-
685-
if (deviceTrust?.isVerified()) {
686-
if (device.getFingerprint() === fingerprint) {
687-
throw new UserFriendlyError("slash_command|verify_nop");
688-
} else {
689-
throw new UserFriendlyError("slash_command|verify_nop_warning_mismatch");
690-
}
691-
}
692-
693-
if (device.getFingerprint() !== fingerprint) {
694-
const fprint = device.getFingerprint();
695-
throw new UserFriendlyError("slash_command|verify_mismatch", {
696-
fprint,
697-
userId,
698-
deviceId,
699-
fingerprint,
700-
cause: undefined,
701-
});
702-
}
703-
704-
await cli.setDeviceVerified(userId, deviceId, true);
705-
706-
// Tell the user we verified everything
707-
Modal.createDialog(InfoDialog, {
708-
title: _t("slash_command|verify_success_title"),
709-
description: (
710-
<div>
711-
<p>{_t("slash_command|verify_success_description", { userId, deviceId })}</p>
712-
</div>
713-
),
714-
});
715-
})(),
716-
);
717-
}
718-
}
719-
return reject(this.getUsage());
720-
},
721-
category: CommandCategories.advanced,
722-
renderingTypes: [TimelineRenderingType.Room],
723-
}),
724660
new Command({
725661
command: "discardsession",
726662
description: _td("slash_command|discardsession"),

src/components/views/dialogs/ManualDeviceKeyVerificationDialog.tsx

-90
This file was deleted.

src/components/views/dialogs/UntrustedDeviceDialog.tsx

+13-5
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,20 @@ import BaseDialog from "./BaseDialog";
1717
import { IDevice } from "../right_panel/UserInfo";
1818

1919
interface IProps {
20+
/**
21+
* The user whose device is untrusted.
22+
*/
2023
user: User;
24+
/**
25+
* The device that is untrusted.
26+
*/
2127
device: IDevice;
22-
onFinished(mode?: "legacy" | "sas" | false): void;
28+
/**
29+
* Callback for when the dialog is dismissed.
30+
* If mode is "sas", the user wants to verify the device with SAS. Otherwise, the dialog was dismissed normally.
31+
* @param mode The mode of dismissal.
32+
*/
33+
onFinished(mode?: "sas"): void;
2334
}
2435

2536
const UntrustedDeviceDialog: React.FC<IProps> = ({ device, user, onFinished }) => {
@@ -56,13 +67,10 @@ const UntrustedDeviceDialog: React.FC<IProps> = ({ device, user, onFinished }) =
5667
<p>{askToVerifyText}</p>
5768
</div>
5869
<div className="mx_Dialog_buttons">
59-
<AccessibleButton kind="primary_outline" onClick={() => onFinished("legacy")}>
60-
{_t("encryption|udd|manual_verification_button")}
61-
</AccessibleButton>
6270
<AccessibleButton kind="primary_outline" onClick={() => onFinished("sas")}>
6371
{_t("encryption|udd|interactive_verification_button")}
6472
</AccessibleButton>
65-
<AccessibleButton kind="primary" onClick={() => onFinished(false)}>
73+
<AccessibleButton kind="primary" onClick={() => onFinished()}>
6674
{_t("action|done")}
6775
</AccessibleButton>
6876
</div>

src/hooks/useEncryptionStatus.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
66
Please see LICENSE files in the repository root for full details.
77
*/
88

9-
import { CryptoEvent, MatrixClient, Room, RoomStateEvent } from "matrix-js-sdk/src/matrix";
9+
import { MatrixClient, Room, RoomStateEvent } from "matrix-js-sdk/src/matrix";
1010
import { useEffect, useMemo, useState } from "react";
1111
import { throttle } from "lodash";
12+
import { CryptoEvent } from "matrix-js-sdk/src/crypto-api";
1213

1314
import { E2EStatus, shieldStatusForRoom } from "../utils/ShieldUtils";
1415
import { useTypedEventEmitter } from "./useEventEmitter";

src/i18n/strings/en_EN.json

-14
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,6 @@
922922
},
923923
"udd": {
924924
"interactive_verification_button": "Interactively verify by emoji",
925-
"manual_verification_button": "Manually verify by text",
926925
"other_ask_verify_text": "Ask this user to verify their session, or manually verify it below.",
927926
"other_new_session_text": "%(name)s (%(userId)s) signed in to a new session without verifying it:",
928927
"own_ask_verify_text": "Verify your other session using one of the options below.",
@@ -957,12 +956,6 @@
957956
"incoming_sas_dialog_waiting": "Waiting for partner to confirm…",
958957
"incoming_sas_user_dialog_text_1": "Verify this user to mark them as trusted. Trusting users gives you extra peace of mind when using end-to-end encrypted messages.",
959958
"incoming_sas_user_dialog_text_2": "Verifying this user will mark their session as trusted, and also mark your session as trusted to them.",
960-
"manual_device_verification_device_id_label": "Session ID",
961-
"manual_device_verification_device_key_label": "Session key",
962-
"manual_device_verification_device_name_label": "Session name",
963-
"manual_device_verification_footer": "If they don't match, the security of your communication may be compromised.",
964-
"manual_device_verification_self_text": "Confirm by comparing the following with the User Settings in your other session:",
965-
"manual_device_verification_user_text": "Confirm this user's session by comparing the following with their User Settings:",
966959
"no_key_or_device": "It looks like you don't have a Security Key or any other devices you can verify against. This device will not be able to access old encrypted messages. In order to verify your identity on this device, you'll need to reset your verification keys.",
967960
"no_support_qr_emoji": "The device you are trying to verify doesn't support scanning a QR code or emoji verification, which is what %(brand)s supports. Try with a different client.",
968961
"other_party_cancelled": "The other party cancelled the verification.",
@@ -3036,13 +3029,6 @@
30363029
"upgraderoom": "Upgrades a room to a new version",
30373030
"upgraderoom_permission_error": "You do not have the required permissions to use this command.",
30383031
"usage": "Usage",
3039-
"verify": "Verifies a user, session, and pubkey tuple",
3040-
"verify_mismatch": "WARNING: KEY VERIFICATION FAILED! The signing key for %(userId)s and session %(deviceId)s is \"%(fprint)s\" which does not match the provided key \"%(fingerprint)s\". This could mean your communications are being intercepted!",
3041-
"verify_nop": "Session already verified!",
3042-
"verify_nop_warning_mismatch": "WARNING: session already verified, but keys do NOT MATCH!",
3043-
"verify_success_description": "The signing key you provided matches the signing key you received from %(userId)s's session %(deviceId)s. Session marked as verified.",
3044-
"verify_success_title": "Verified key",
3045-
"verify_unknown_pair": "Unknown (user, session) pair: (%(userId)s, %(deviceId)s)",
30463032
"view": "Views room with given address",
30473033
"whois": "Displays information about a user"
30483034
},

src/rageshake/submit-rageshake.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ Please see LICENSE files in the repository root for full details.
99
*/
1010

1111
import { logger } from "matrix-js-sdk/src/logger";
12-
import { Method, MatrixClient, Crypto } from "matrix-js-sdk/src/matrix";
12+
import { Method, MatrixClient } from "matrix-js-sdk/src/matrix";
13+
import { CryptoApi } from "matrix-js-sdk/src/crypto-api";
1314

1415
import type * as Pako from "pako";
1516
import { MatrixClientPeg } from "../MatrixClientPeg";
@@ -169,7 +170,7 @@ async function collectSynapseSpecific(client: MatrixClient, body: FormData): Pro
169170
/**
170171
* Collects crypto related information.
171172
*/
172-
async function collectCryptoInfo(cryptoApi: Crypto.CryptoApi, body: FormData): Promise<void> {
173+
async function collectCryptoInfo(cryptoApi: CryptoApi, body: FormData): Promise<void> {
173174
body.append("crypto_version", cryptoApi.getVersion());
174175

175176
const ownDeviceKeys = await cryptoApi.getOwnDeviceKeys();
@@ -198,7 +199,7 @@ async function collectCryptoInfo(cryptoApi: Crypto.CryptoApi, body: FormData): P
198199
/**
199200
* Collects information about secret storage and backup.
200201
*/
201-
async function collectRecoveryInfo(client: MatrixClient, cryptoApi: Crypto.CryptoApi, body: FormData): Promise<void> {
202+
async function collectRecoveryInfo(client: MatrixClient, cryptoApi: CryptoApi, body: FormData): Promise<void> {
202203
const secretStorage = client.secretStorage;
203204
body.append("secret_storage_ready", String(await cryptoApi.isSecretStorageReady()));
204205
body.append("secret_storage_key_in_account", String(await secretStorage.hasKey()));

src/utils/device/dehydration.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
77
*/
88

99
import { logger } from "matrix-js-sdk/src/logger";
10-
import { Crypto } from "matrix-js-sdk/src/matrix";
10+
import { CryptoApi } from "matrix-js-sdk/src/crypto-api";
1111

1212
import { MatrixClientPeg } from "../../MatrixClientPeg";
1313

@@ -21,7 +21,7 @@ import { MatrixClientPeg } from "../../MatrixClientPeg";
2121
*
2222
* Dehydration can currently only be enabled by setting a flag in the .well-known file.
2323
*/
24-
async function deviceDehydrationEnabled(crypto: Crypto.CryptoApi | undefined): Promise<boolean> {
24+
async function deviceDehydrationEnabled(crypto: CryptoApi | undefined): Promise<boolean> {
2525
if (!crypto) {
2626
return false;
2727
}

src/verification.ts

-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { RightPanelPhases } from "./stores/right-panel/RightPanelStorePhases";
1515
import { accessSecretStorage } from "./SecurityManager";
1616
import UntrustedDeviceDialog from "./components/views/dialogs/UntrustedDeviceDialog";
1717
import { IDevice } from "./components/views/right_panel/UserInfo";
18-
import { ManualDeviceKeyVerificationDialog } from "./components/views/dialogs/ManualDeviceKeyVerificationDialog";
1918
import RightPanelStore from "./stores/right-panel/RightPanelStore";
2019
import { IRightPanelCardState } from "./stores/right-panel/RightPanelStoreIPanelState";
2120
import { findDMForUser } from "./utils/dm/findDMForUser";
@@ -53,11 +52,6 @@ export async function verifyDevice(matrixClient: MatrixClient, user: User, devic
5352
.getCrypto()
5453
?.requestDeviceVerification(user.userId, device.deviceId);
5554
setRightPanel({ member: user, verificationRequestPromise });
56-
} else if (action === "legacy") {
57-
Modal.createDialog(ManualDeviceKeyVerificationDialog, {
58-
userId: user.userId,
59-
device,
60-
});
6155
}
6256
},
6357
});

0 commit comments

Comments
 (0)