From e5da81b6ba3ed6ba9274504f66ca6aed06b7fcb4 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 6 May 2020 14:42:03 -0600 Subject: [PATCH] Ensure key backup gets dealt with correctly during secret storage reset Fixes https://github.com/vector-im/riot-web/issues/13562 We only initialize a new key backup if the user requested one. If they've requested new keys but have not asked for keys to be backed up, we simply delete the now-invalid backup. This also adds some logging to identify in rageshakes when someone resets their cross-signing, and when their key backup is being deleted. --- .../dialogs/secretstorage/CreateSecretStorageDialog.js | 10 +++++++++- src/components/views/settings/CrossSigningPanel.js | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js b/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js index 2c05f231e7..9d07628093 100644 --- a/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js +++ b/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js @@ -236,12 +236,20 @@ export default class CreateSecretStorageDialog extends React.PureComponent { try { if (force) { + console.log("Forcing secret storage reset"); // log something so we can debug this later await cli.bootstrapSecretStorage({ authUploadDeviceSigningKeys: this._doBootstrapUIAuth, createSecretStorageKey: async () => this._recoveryKey, - setupNewKeyBackup: true, + setupNewKeyBackup: this.state.useKeyBackup, setupNewSecretStorage: true, }); + if (!this.state.useKeyBackup && this.state.backupInfo) { + // If the user is resetting their cross-signing keys and doesn't want + // key backup (but had it enabled before), delete the key backup as it's + // no longer valid. + console.log("Deleting invalid key backup (secrets have been reset; key backup not requested)"); + await cli.deleteKeyBackupVersion(this.state.backupInfo.version); + } } else { await cli.bootstrapSecretStorage({ authUploadDeviceSigningKeys: this._doBootstrapUIAuth, diff --git a/src/components/views/settings/CrossSigningPanel.js b/src/components/views/settings/CrossSigningPanel.js index cb04d2a018..c07f1c25dd 100644 --- a/src/components/views/settings/CrossSigningPanel.js +++ b/src/components/views/settings/CrossSigningPanel.js @@ -131,8 +131,8 @@ export default class CrossSigningPanel extends React.PureComponent { } _destroySecureSecretStorage = () => { - const ConfirmDestoryCrossSigningDialog = sdk.getComponent("dialogs.ConfirmDestroyCrossSigningDialog"); - Modal.createDialog(ConfirmDestoryCrossSigningDialog, { + const ConfirmDestroyCrossSigningDialog = sdk.getComponent("dialogs.ConfirmDestroyCrossSigningDialog"); + Modal.createDialog(ConfirmDestroyCrossSigningDialog, { onFinished: this.onDestroyStorage, }); }