diff --git a/src/services/nativeMessaging.service.ts b/src/services/nativeMessaging.service.ts index 1b45ba2782..910e5fd094 100644 --- a/src/services/nativeMessaging.service.ts +++ b/src/services/nativeMessaging.service.ts @@ -22,8 +22,9 @@ export class NativeMessagingService { private sharedSecrets = new Map(); constructor(private cryptoFunctionService: CryptoFunctionService, private cryptoService: CryptoService, - private platformUtilService: PlatformUtilsService, private logService: LogService, private i18nService: I18nService, - private userService: UserService, private messagingService: MessagingService, private vaultTimeoutService: VaultTimeoutService, private storageService: StorageService) { + private platformUtilService: PlatformUtilsService, private logService: LogService, + private i18nService: I18nService, private userService: UserService, private messagingService: MessagingService, + private vaultTimeoutService: VaultTimeoutService, private storageService: StorageService) { ipcRenderer.on('nativeMessaging', async (event: any, message: any) => { this.messageHandler(message); }); @@ -37,6 +38,12 @@ export class NativeMessagingService { if (rawMessage.command === 'setupEncryption') { const remotePublicKey = Utils.fromB64ToArray(rawMessage.publicKey).buffer; + // Valudate the UserId to ensure we are logged into the same account. + if (rawMessage.userId !== await this.userService.getUserId()) { + ipcRenderer.send('nativeMessagingReply', {command: 'wrongUserId', appId: appId}); + return; + } + if (await this.storageService.get(ElectronConstants.enableBrowserIntegrationFingerprint)) { ipcRenderer.send('nativeMessagingReply', {command: 'verifyFingerprint', appId: appId});