Skip to content

Use-After-Free / Dangling Pointer when using session tickets and Open…#964

Merged
chrisvest merged 1 commit intomainfrom
dangling_pointer
Mar 24, 2026
Merged

Use-After-Free / Dangling Pointer when using session tickets and Open…#964
chrisvest merged 1 commit intomainfrom
dangling_pointer

Conversation

@normanmaurer
Copy link
Copy Markdown
Member

…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

…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
@normanmaurer normanmaurer added this to the 2.0.76.Final milestone Mar 23, 2026
@chrisvest chrisvest merged commit 3da7aaa into main Mar 24, 2026
10 checks passed
@chrisvest chrisvest deleted the dangling_pointer branch March 24, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants