Skip to content

Commit

Permalink
key: clear out secret data in DecodeExtKey
Browse files Browse the repository at this point in the history
Same as in `DecodeSecret`, we should also clear out the secret data from
the vector resulting from the Base58Check parsing for xprv keys. Note
that the if condition is needed in order to avoid UB, see bitcoin#14242 (commit
d855e4c).

Github-Pull: bitcoin#31166
Rebased-From: 559a8dd
  • Loading branch information
theStack authored and fanquake committed Oct 31, 2024
1 parent 0773560 commit f998ac6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/key_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ CExtKey DecodeExtKey(const std::string& str)
key.Decode(data.data() + prefix.size());
}
}
if (!data.empty()) {
memory_cleanse(data.data(), data.size());
}
return key;
}

Expand Down

0 comments on commit f998ac6

Please sign in to comment.