Repository navigation
fix(yubihsm): wipe the key on every keys import exit - #14
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tmkms yubihsm keys importended the process withprocess::exitfrom 15 places afterreading the key file, and
process::exitruns no destructors. So a failed import left thefile's contents, and any key already decoded, in memory unwiped. Now:
run(), which reports it and exits only after the import hasdropped the file buffer and any decoded key, so whatever wipes itself on drop is wiped, as on
success. Exit codes and messages are unchanged.
connection still ends the process where it happens. With an unreachable HSM, its error now
wins over a bad key file, key type or missing key ID, and a
yubihsm-serverCLI passwordprompt comes before any of those errors.
it reports an invalid one, into a buffer that used to be freed unwiped. The KMS's own startup
load of Base64 keys shares the fix.
iq-cometbft, for everypriv_validator_key.json, and insideyubihsm, for every keykeys importstores.Changes
keys importoutcome prints and returns, before the refactor —aa29139run(), the only place that exits —2b5cabe8ade48frun()connected with, so the HSM's own failures can be tested, and share the Ed25519 import steps —a5bfa81,36717d7keys importand in key load —03c0aa1keys importpath too, which makescommands::yubihsm::keys, itsimportmodule and theimportmethod public —f623cbfkeys importCLI tests —6f5a0174fa75cb,8a189134925164,f3924bc,1d85340Testing
keys importcases against MockHsm and pins each exit code and everystderr line. It passed before the refactor and passes after.
run(),including the HSM's own refusals (a MockHsm client with the wrong password). A helper that
exits in place kills the test process.
to decode, through key load or through
keys import. Before the fix it found them.so the import connects first.
imported key's public key: the CLI's MockHsm has no wrap key, and an in-process test can't
print the success message. Those paths change only mechanically.
but their results.