Use-After-Free / Dangling Pointer when using session tickets and Open…#964
Merged
Use-After-Free / Dangling Pointer when using session tickets and Open…#964
Conversation
…SSL 3.x Motivation: On OpenSSL 3.0+, OSSL_PARAM_construct_octet_string stores a raw pointer to the data, not a copy of it and so we need to ensure we make a copy. Modifications: - hmac_key is now unconditional (no longer guarded by < 0x30000000L). This gives the struct a stable, heap-allocated 16-byte buffer that lives as long as the ticket_keys array itself. The mac_params array is now only compiled in on OpenSSL 3.0+, but the raw key bytes always live in hmac_key. - memcpy(ticket_keys[i].hmac_key, ...) now runs unconditionally, copying the 16 bytes out of the JNI array (b) into the struct before b is released. - mac_params[0] now points to ticket_keys[i].hmac_key — memory owned by the ticket_keys allocation — instead of into b. Result: No more use of possible dangling pointer when using OpenSSL 3.x and more consistent code-base
chrisvest
approved these changes
Mar 24, 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.
…SSL 3.x
Motivation:
On OpenSSL 3.0+, OSSL_PARAM_construct_octet_string stores a raw pointer to the data, not a copy of it and so we need to ensure we make a copy.
Modifications:
Result:
No more use of possible dangling pointer when using OpenSSL 3.x and more consistent code-base