From 031a689667b87d275358b41b3ec94c1a8a2846b5 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Tue, 22 Jul 2025 13:36:30 +0200 Subject: [PATCH] Add arg null check --- .../services/master-password.service.ts | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/libs/common/src/key-management/master-password/services/master-password.service.ts b/libs/common/src/key-management/master-password/services/master-password.service.ts index 8c5c1077b55..ac8a817d9e1 100644 --- a/libs/common/src/key-management/master-password/services/master-password.service.ts +++ b/libs/common/src/key-management/master-password/services/master-password.service.ts @@ -227,6 +227,16 @@ export class MasterPasswordService implements InternalMasterPasswordServiceAbstr kdf: KdfConfig, salt: MasterPasswordSalt, ): Promise { + if (password == null) { + throw new Error("Password is required."); + } + if (kdf == null) { + throw new Error("KDF configuration is required."); + } + if (salt == null) { + throw new Error("Salt is required."); + } + const SERVER_AUTHENTICATION_HASH_ITERATIONS = 1; const masterKey = (await this.keyGenerationService.deriveKeyFromPassword( @@ -257,6 +267,19 @@ export class MasterPasswordService implements InternalMasterPasswordServiceAbstr salt: MasterPasswordSalt, userKey: UserKey, ): Promise { + if (password == null) { + throw new Error("Password is required."); + } + if (kdf == null) { + throw new Error("KDF configuration is required."); + } + if (salt == null) { + throw new Error("Salt is required."); + } + if (userKey == null) { + throw new Error("User key is required."); + } + await SdkLoadService.Ready; const masterKeyWrappedUserKey = new EncString( PureCrypto.encrypt_user_key_with_master_password( @@ -277,6 +300,13 @@ export class MasterPasswordService implements InternalMasterPasswordServiceAbstr password: string, masterPasswordUnlockData: MasterPasswordUnlockData, ): Promise { + if (password == null) { + throw new Error("Password is required."); + } + if (masterPasswordUnlockData == null) { + throw new Error("Master password unlock data is required."); + } + await SdkLoadService.Ready; const userKey = new SymmetricCryptoKey( PureCrypto.decrypt_user_key_with_master_password(