From 23bab62008c9137529c586f66356781af4cc3fc9 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Mon, 1 Feb 2021 12:39:09 -0800 Subject: [PATCH] Reject eth_getEncryptionPublicKey for ledger hw wallets (#10326) Fixes #10111 Determine if the msgParams/address for the newRequestEncryptionPublicKey is a ledger keyring via getKeyringForAccount and return a promise rejection. --- app/scripts/metamask-controller.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index ad6483821..a61a40ed0 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1643,6 +1643,13 @@ export default class MetamaskController extends EventEmitter { * Passed back to the requesting Dapp. */ async newRequestEncryptionPublicKey(msgParams, req) { + const address = msgParams + const keyring = await this.keyringController.getKeyringForAccount(address) + if (keyring.type === 'Ledger Hardware') { + return new Promise((_, reject) => { + reject(new Error('Ledger does not support eth_getEncryptionPublicKey.')) + }) + } const promise = this.encryptionPublicKeyManager.addUnapprovedMessageAsync( msgParams, req,