1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

Ps/pm-8003/handle-dekstop-invalidated-message-encryption (#9181)

* Do not initialize symmetric crypto keys with null

* Require new message on invalid native message encryption

Handling of this error is to require the user to retry, so the promise needs to resolve.
This commit is contained in:
Matt Gibson
2024-05-15 10:45:40 -04:00
committed by GitHub
parent b14bb92d78
commit 426bacfd67
2 changed files with 12 additions and 2 deletions

View File

@@ -167,6 +167,11 @@ export class NativeMessagingBackground {
cancelButtonText: null, cancelButtonText: null,
type: "danger", type: "danger",
}); });
if (this.resolver) {
this.resolver(message);
}
break; break;
case "verifyFingerprint": { case "verifyFingerprint": {
if (this.sharedSecret == null) { if (this.sharedSecret == null) {

View File

@@ -92,7 +92,9 @@ export class ElectronCryptoService extends CryptoService {
if (keySuffix === KeySuffixOptions.Biometric) { if (keySuffix === KeySuffixOptions.Biometric) {
await this.migrateBiometricKeyIfNeeded(userId); await this.migrateBiometricKeyIfNeeded(userId);
const userKey = await this.stateService.getUserKeyBiometric({ userId: userId }); const userKey = await this.stateService.getUserKeyBiometric({ userId: userId });
return new SymmetricCryptoKey(Utils.fromB64ToArray(userKey)) as UserKey; return userKey == null
? null
: (new SymmetricCryptoKey(Utils.fromB64ToArray(userKey)) as UserKey);
} }
return await super.getKeyFromStorage(keySuffix, userId); return await super.getKeyFromStorage(keySuffix, userId);
} }
@@ -169,7 +171,9 @@ export class ElectronCryptoService extends CryptoService {
// decrypt // decrypt
const masterKey = new SymmetricCryptoKey(Utils.fromB64ToArray(oldBiometricKey)) as MasterKey; const masterKey = new SymmetricCryptoKey(Utils.fromB64ToArray(oldBiometricKey)) as MasterKey;
userId ??= (await firstValueFrom(this.accountService.activeAccount$))?.id; userId ??= (await firstValueFrom(this.accountService.activeAccount$))?.id;
const encUserKeyPrim = await this.stateService.getEncryptedCryptoSymmetricKey(); const encUserKeyPrim = await this.stateService.getEncryptedCryptoSymmetricKey({
userId: userId,
});
const encUserKey = const encUserKey =
encUserKeyPrim != null encUserKeyPrim != null
? new EncString(encUserKeyPrim) ? new EncString(encUserKeyPrim)
@@ -180,6 +184,7 @@ export class ElectronCryptoService extends CryptoService {
const userKey = await this.masterPasswordService.decryptUserKeyWithMasterKey( const userKey = await this.masterPasswordService.decryptUserKeyWithMasterKey(
masterKey, masterKey,
encUserKey, encUserKey,
userId,
); );
// migrate // migrate
await this.storeBiometricKey(userKey, userId); await this.storeBiometricKey(userKey, userId);