fix(keychain): zero sensitive byte slices after use#491
Merged
Conversation
Clear marshalled plaintext, decoded secrets, and cryptographic key material (DH shared secret, PKCS7-padded plaintext) immediately after use across the Linux, Windows, and secretservice backends. Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
There was a problem hiding this comment.
Review Summary
Assessment: 🟢 APPROVE
This PR correctly implements zeroing of sensitive byte slices (plaintext, secrets, cryptographic keys) after use across Linux, Windows, and secretservice backends.
Analysis:
- ✅
defer clear()statements are correctly placed to execute on all return paths (normal and error returns) - ✅ In the
Filter()functions, manualclear()calls are used instead of defer, which correctly handle all normal and error return paths - ✅ All sensitive data (marshalled plaintext, decoded secrets, DH shared secrets, PKCS7-padded plaintext) is properly cleared
- ✅ No resource leaks or logic errors detected
The implementation follows Go's defer semantics properly: deferred functions execute when the containing function returns, regardless of whether it's a normal return or an early error return. This ensures sensitive memory is zeroed in all code paths.
Verdict: The changes are secure and correctly implemented. No issues found.
joe0BAB
approved these changes
Mar 17, 2026
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.
Clear marshalled plaintext, decoded secrets, and cryptographic key material (DH shared secret, PKCS7-padded plaintext) immediately after use across the Linux, Windows, and secretservice backends.