x509: use an owned public key for -modulus - #300
Open
julek-wolfssl wants to merge 1 commit into
Open
julek-wolfssl wants to merge 1 commit into
julek-wolfssl wants to merge 1 commit into
Conversation
wolfSSL is moving X509_get0_pubkey() to OpenSSL's borrowed semantics (wolfSSL PR #11428). The -modulus code freed that key, which with the new semantics is the certificate's own key, so X509_free() then hit a use after free. wolfSSL_X509_get_pubkey() returns a reference the caller owns with both old and new wolfSSL, so freeing it stays correct.
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused ownership fix matches the updated wolfSSL API contract and existing regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Updates X509 modulus handling for wolfSSL’s borrowed-key semantics, preventing a use-after-free.
Changes:
- Retrieves an owned public-key reference.
- Removes the obsolete ownership comment.
| File | Description |
|---|---|
src/x509/clu_cert_setup.c |
Uses an owned key for modulus output and safely frees it. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
wolfSSL is moving
X509_get0_pubkey()to OpenSSL's borrowed semantics (wolfSSL PR #11428). Under those semantics the key returned is the certificate's own, so the-moduluscode freeing it caused a use after free whenX509_free()later released the same key.The
-moduluscode now callswolfSSL_X509_get_pubkey(), which returns a reference the caller owns in both old and new wolfSSL. Freeing it remains correct either way.