fix(crypto): implement ephemeral key zeroization wrappers (#640) - #732
Merged
Sadeequ merged 1 commit intoJul 30, 2026
Merged
Conversation
|
@TheFaith-Code Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Crypto-Isolation | Ephemeral Key Zeroization Wrappers for Transaction Signers
Description
This PR addresses critical vulnerability #640, where secret keys used during automated signing operations could persist in Python heap objects until garbage collection runs.
Technical Details
ctypes.memsetIn-Place Memory Overwrite:_wipe_bytes_viewinsrc/crypto/signer.pyandsrc/crypto/engine.pyto directly zero out the CPythonbytesobject buffer in-place usingctypes.memsetat the underlying C-struct data offset (id(view) + offset), rather than making a throwaway copy viafrom_buffer_copy._wipe_key_handle):_wipe_key_handleto recursively traverse and zeroize internal key attributes (such as_seed,_signing_key,_key,secret_key,_secret_key,_raw_secret_key,raw_secret_key,_keypair,_private_key,private_key,_sk,sk,_vk,vk) acrossstellar_sdk.Keypair,nacl.signing.SigningKey, and custom key handles.finallyzeroization wipes in context managers (SecureKeyHandle,SecureSessionCredentials,SecureVariableWrapper,_SecureKeypairContext) and signing entry points (sign,_sign_internal,_try_stellar_sdk,_try_pynacl)._do_wipe()inSecureKeyHandleto properly invoke_munlock_bufferand reset_locked = Falseupon memory cleanup.Verification Test Results
Executed
pytest tests/test_signer.pyandpytest test/test_signer.py: