mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-26 03:03:22 -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.
Github-Pull: #27080
Rebased-From: 3a11adc700
This commit is contained in:
parent
b7e242ecb3
commit
64e7db6f4f
1 changed files with 5 additions and 1 deletions
|
@ -25,6 +25,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>
|
||||
|
@ -3293,7 +3294,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