fix: zeroize req password buffers#272
Open
MarkAtwood wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Closes a security issue where wolfCLU_requestSetup left key-encryption passwords resident in stack buffers on normal and early-return paths by explicitly zeroizing those buffers before returning.
Changes:
- Zeroize the
passwordstack buffer on the-helpearly return path. - Zeroize the stdin
passbuffer after use. - Zeroize the
passwordstack buffer on the normal exit path.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Bug
wolfCLU_requestSetupinsrc/x509/clu_request_setup.creads a key-encryption password into stack buffers (password[MAX_PASSWORD_SIZE]via-passout, and apass[MAX_PASSWORD_SIZE]stdin buffer) but never zeroizes them. The secret is left on the stack at every return path — the normal exit and the-helpearly return (reachable when-passoutprecedes-help). Sibling functions in this codebase already scrub such buffers withwolfCLU_ForceZero(seesrc/pkcs/clu_pkcs8.c:290,src/pkcs/clu_pkcs12.c:237).Fix
Call
wolfCLU_ForceZero(buf, MAX_PASSWORD_SIZE)on each secret buffer before it goes out of scope:passwordbefore the normalreturn retpasswordbefore the-helpearlyreturn WOLFCLU_SUCCESSpassbuffer before it leaves its blockwolfCLU_ForceZerois a project-provided helper declared in the already-includedwolfclu/clu_header_main.h; no new include or dependency.Verification
Compiled the patched translation unit clean against a full-featured wolfSSL install:
gcc -c src/x509/clu_request_setup.c ... -Wallexits 0, andnmconfirms the object now referenceswolfCLU_ForceZero.Reported by static analysis (Fenrir finding 663).