Fix PKCS11 object leak in Pkcs11ECDH#9780
Open
mattia-moffa wants to merge 1 commit intowolfSSL:masterfrom
Open
Fix PKCS11 object leak in Pkcs11ECDH#9780mattia-moffa wants to merge 1 commit intowolfSSL:masterfrom
mattia-moffa wants to merge 1 commit intowolfSSL:masterfrom
Conversation
Contributor
|
Jenkins retest this please. FIPS v3 no history |
dgarske
approved these changes
Feb 16, 2026
SparkiDev
requested changes
Feb 16, 2026
| if (secret != CK_INVALID_HANDLE) | ||
| session->func->C_DestroyObject(session->handle, secret); | ||
|
|
||
| if (sessionKey) { |
Contributor
There was a problem hiding this comment.
Please check against NULL.
| else { | ||
| ret = Pkcs11FindEccKey(&privateKey, CKO_PRIVATE_KEY, session, | ||
| info->pk.ecdh.public_key, CKA_DERIVE); | ||
| if (ret == 0) { |
Contributor
There was a problem hiding this comment.
The private key lifecycle should be bound to the ECC object.
I don't think the private key should be destroyed here.
|
|
||
| if (sessionKey) | ||
| if (secret != CK_INVALID_HANDLE) | ||
| session->func->C_DestroyObject(session->handle, secret); |
Contributor
There was a problem hiding this comment.
May want the secret held on the device!
When doing TLS on the device, you don't want the secret to leave it. Instead the secret is used to generate the TLS session keys.
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.
Description
Pkcs11ECDHleaked two PKCS11 objects per ECDH operation:C_DeriveKeyis never destroyed after its value is extracted viaC_GetAttributeValuePkcs11EcKeyGen(e.g. for TLS ECDHE) is not cleaned up.Pkcs11EcKeyGenintentionally leaves the private key alive for the subsequentPkcs11ECDHcall, butPkcs11ECDHonly destroys private keys created from raw scalar data (if (sessionKey)), not keys found viaPkcs11FindEccKey.Reported via ZD#20700
Testing