fix: zero stdin password buffer in req#268
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.
Adds an explicit secure wipe of the stack password buffer in wolfCLU_requestSetup to prevent plaintext passwords lingering in memory after use.
Changes:
- Securely zeroes
passviawolfCLU_ForceZero()after the password is consumed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1107
to
1110
| wolfCLU_ForceZero(pass, MAX_PASSWORD_SIZE); | ||
| } | ||
| else { | ||
| ret = wolfCLU_pKeyPEMtoPriKeyEnc(keyOutBio, pkey, DES3b, |
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
In
wolfCLU_requestSetup(src/x509/clu_request_setup.c), the local stack bufferbyte pass[MAX_PASSWORD_SIZE](256 bytes) holds a password read from stdin viawolfCLU_GetStdinPassword. After the password is consumed bywolfCLU_pKeyPEMtoPriKeyEnc, the buffer goes out of scope without being cleared, leaving the plaintext password on the stack (recoverable via core dump or later stack reuse).Fix
Add
wolfCLU_ForceZero(pass, MAX_PASSWORD_SIZE)after the buffer's last use, before it leaves scope. This matches the existing secure-clear convention already used elsewhere in the codebase (e.g.src/pkey/clu_rsa.c,src/tools/clu_rand.c,src/x509/clu_x509_sign.c).How verified
--enable-allwolfSSL:gcc -c src/x509/clu_request_setup.cexits 0.objdump -dron the object confirms a new relocation call towolfCLU_ForceZerothat was absent before the change; object size grew by the added call.Reported by static analysis (Fenrir finding 744). A sibling uncleared buffer (function-level
password[], finding 663) is tracked separately and left out of scope here.