codechain-keystore-js icon indicating copy to clipboard operation
codechain-keystore-js copied to clipboard

Clear secret keys when they are not needed anymore

Open HoOngEe opened this issue 5 years ago • 2 comments

Currently, private key type is string but string type variables cannot be explicitly dropped or cleared. Change the type of secret key to Buffer and clear(fill zeros to the memory it holds) when the necessity of them ends to enhance security.

HoOngEe avatar Oct 25 '19 06:10 HoOngEe

To Apply this change, we should consider all the dependencies using secret keys' data from the bottom. codechain-keystore-js is dependent on codechain-primitives-js which is dependent on the indutny's elliptic curve library

HoOngEe avatar Oct 25 '19 07:10 HoOngEe

One similar issue is here: https://github.com/ethereumjs/ethereumjs-wallet/issues/89. I failed to find some guidelines about keeping private information secret in javascript implementations. Currently, many external libraries are using immutable string type to store private keys. As long as keystore is dependent on those libraries, the copies of secret keys cannot be cleared.

HoOngEe avatar Oct 25 '19 09:10 HoOngEe