Skip to content

fix(keychain): zero sensitive byte slices after use#491

Merged
Benehiko merged 1 commit intomainfrom
keychain/zero/out
Mar 17, 2026
Merged

fix(keychain): zero sensitive byte slices after use#491
Benehiko merged 1 commit intomainfrom
keychain/zero/out

Conversation

@Benehiko
Copy link
Member

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.

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>
@Benehiko Benehiko requested a review from joe0BAB March 17, 2026 12:21
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, manual clear() 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.

@Benehiko Benehiko merged commit 072216a into main Mar 17, 2026
21 checks passed
@Benehiko Benehiko deleted the keychain/zero/out branch March 17, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants