From 4fd10117520f72f8c7a462f7ba378d73f1fffbaf Mon Sep 17 00:00:00 2001 From: Jake Fink Date: Tue, 10 Dec 2024 17:07:14 -0500 Subject: [PATCH] catch failed cipher key decryption and return early --- libs/common/src/vault/models/domain/cipher.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/common/src/vault/models/domain/cipher.ts b/libs/common/src/vault/models/domain/cipher.ts index d7355ce5202..0514c3ead3a 100644 --- a/libs/common/src/vault/models/domain/cipher.ts +++ b/libs/common/src/vault/models/domain/cipher.ts @@ -136,7 +136,12 @@ export class Cipher extends Domain implements Decryptable { if (this.key != null) { const encryptService = Utils.getContainerService().getEncryptService(); - encKey = new SymmetricCryptoKey(await encryptService.decryptToBytes(this.key, encKey)); + const keyBytes = await encryptService.decryptToBytes(this.key, encKey); + if (keyBytes == null) { + model.name = "[error: cannot decrypt]"; + return model; + } + encKey = new SymmetricCryptoKey(keyBytes); bypassValidation = false; }