fix: generate_key() BIGNUM leak on OpenSSL 3.x#78
Merged
atoomic merged 1 commit intocpan-authors:mainfrom Mar 12, 2026
Merged
Conversation
timlegge
approved these changes
Feb 25, 2026
Member
timlegge
left a comment
There was a problem hiding this comment.
LGTM - I might add a
if (e != NULL)
before the BN_free() but otherwise LGTM
atoomic
approved these changes
Feb 25, 2026
7d8f14f to
75fef76
Compare
Koan-Bot
added a commit
to atoomic/Crypt-OpenSSL-RSA
that referenced
this pull request
Feb 25, 2026
Contributor
Author
Rebase: fix: generate_key() BIGNUM leak on OpenSSL 3.xBranch Actions
Automated by Kōan |
Contributor
Author
Rebase: fix: generate_key() BIGNUM leak on OpenSSL 3.xBranch Diff: 1 file changed, 2 insertions(+), 1 deletion(-) Review feedback was analyzed and applied. Actions
Automated by Kōan |
75fef76 to
67f8d45
Compare
Koan-Bot
added a commit
to atoomic/Crypt-OpenSSL-RSA
that referenced
this pull request
Mar 15, 2026
Koan-Bot
added a commit
to atoomic/Crypt-OpenSSL-RSA
that referenced
this pull request
Mar 15, 2026
Koan-Bot
added a commit
to atoomic/Crypt-OpenSSL-RSA
that referenced
this pull request
Mar 15, 2026
Koan-Bot
added a commit
to atoomic/Crypt-OpenSSL-RSA
that referenced
this pull request
Mar 16, 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.
Summary
ewas set to NULL before callingBN_free(), making the free a no-opEVP_PKEY_CTX_set1_rsa_keygen_pubexp()usesset1semantics (copies the value), so the caller retains ownership and must free the originale = NULLline soBN_free(e)actually frees the BIGNUMImpact
Memory leak of one BIGNUM on every
generate_key()call when built against OpenSSL >= 3.0.Test plan
generate_key()tested in rsa.t (512-bit and 2048-bit)🤖 Generated with Claude Code