mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
Zero out wallet master key upon lock
When an encrypted wallet is locked (for instance via the RPC `walletlock`), the docs indicate that the key is removed from memory. However, the vector (with a secure allocator) is merely cleared. This allows the key to persist indefinitely in memory. Instead, manually fill the bytes with zeroes before clearing.
This commit is contained in:
parent
b92d609fb2
commit
3a11adc700
1 changed files with 5 additions and 1 deletions
|
@ -26,6 +26,7 @@
|
|||
#include <script/descriptor.h>
|
||||
#include <script/script.h>
|
||||
#include <script/signingprovider.h>
|
||||
#include <support/cleanse.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/bip32.h>
|
||||
#include <util/check.h>
|
||||
|
@ -3407,7 +3408,10 @@ bool CWallet::Lock()
|
|||
|
||||
{
|
||||
LOCK(cs_wallet);
|
||||
vMasterKey.clear();
|
||||
if (!vMasterKey.empty()) {
|
||||
memory_cleanse(vMasterKey.data(), vMasterKey.size() * sizeof(decltype(vMasterKey)::value_type));
|
||||
vMasterKey.clear();
|
||||
}
|
||||
}
|
||||
|
||||
NotifyStatusChanged(this);
|
||||
|
|
Loading…
Add table
Reference in a new issue