wolfSSL — Missing Zeroization of Replaced Session Ticket in wolfSSL_d2i_SSL_SESSION
When wolfSSL_d2i_SSL_SESSION parses a serialized session into a session object that already holds a heap-allocated ticket, it frees the old ticket without clearing it. The previous ticket remains in freed heap memory.
- Advisory
- BYTERAY-2026-0516
- CWE
- CWE-226
- CVSS
- 3.7 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N)
- Vendor
- wolfSSL
- Product
- wolfSSL
- Reported
- 2026-09-28
- Disclosure
- 2026-12-03
- Affected
- wolfSSL 5.9.2 (tested at master commit d95483f), builds with HAVE_SESSION_TICKET (--enable-session-ticket) whose application deserializes into an existing session object
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
wolfSSL_d2i_SSL_SESSION() parses a serialized TLS session into a WOLFSSL_SESSION. The caller may pass an existing session object as the destination, as the d2i convention allows.
If that object already holds a session ticket in a heap buffer, the function frees the buffer and then stores the parsed ticket. The free is a plain XFREE(). The old ticket bytes are not cleared and stay in freed heap memory.
A ticket is one part of a resumption credential. The secret needed to use it is stored separately. The code is compiled only with session ticket support, which is off by default in this tree, and it runs only when an application deserializes into a session that is already populated.
Affected Products and Versions
- Component:
src/ssl_sess.c,wolfSSL_d2i_SSL_SESSION(). - Required build:
HAVE_SESSION_TICKET.--enable-session-ticketis off by default (configure.ac:9469-9473). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild does not include this code. - Other releases were not checked.
Technical Details
wolfSSL_d2i_SSL_SESSION() is defined at src/ssl_sess.c:2944. Its ticket section reads the ticket length and then disposes of the destination's old ticket (src/ssl_sess.c:3186-3189):
/* Dispose of ol dynamic ticket and ensure space for new ticket. */
if (s->ticketLenAlloc > 0) {
XFREE(s->ticket, NULL, DYNAMIC_TYPE_SESSION_TICK);
}
The steps around it:
- The parser reads the two-byte ticket length from the input (
src/ssl_sess.c:3184). - If the destination holds a dynamic ticket, that buffer is freed as shown. No
ForceZero()precedes the free. - The destination ticket pointer is set to the inline buffer, or to a new allocation when the parsed ticket is larger (
src/ssl_sess.c:3190-3200). - The parsed ticket is copied in (
src/ssl_sess.c:3207).
The comment shows the replacement is intended. Only the clearing step is absent. The same parse also replaces the TLS 1.3 ticket nonce through SessionTicketNoncePopulate() (src/ssl_sess.c:3156) in builds with WOLFSSL_TICKET_NONCE_MALLOC. That release is described in BYTERAY-2026-0514.
Reachability and Preconditions
- Build with
HAVE_SESSION_TICKET. - The application calls
wolfSSL_d2i_SSL_SESSION()with a destination session that already holds a ticket larger than the inline buffer. Deserializing into a fresh object, the common pattern, does not free anything. - The trigger is under application control. A remote party influences it only through whatever causes the application to load a session.
- Disclosure needs a second condition outside this issue: the freed block is reused in the same process and something exposes the reused memory.
Impact
The previous session ticket persists in freed heap memory after the deserialization. Servers usually accept a ticket until it expires, so the bytes can still be meaningful. The ticket without its secret does not allow resumption. The consequence is a limited confidentiality exposure that depends on a separate memory-disclosure primitive.
ByteRay did not build a proof of concept for this issue. The analysis is from source review.
Remediation and Mitigation
ByteRay has not confirmed a fixed wolfSSL release for this issue as of 2026-12-03, and has not checked it against wolfSSL changes made after the tested commit.
The fix direction is to call ForceZero() on s->ticket over s->ticketLenAlloc bytes between the length check and the XFREE(). Ticket installation could be moved into a shared helper that always clears the previous dynamic buffer, so that every replacement path behaves the same way.
Applications can avoid the release by deserializing into a new session object and freeing the old one. That moves the old ticket to the session free path, which is covered in BYTERAY-2026-0518.
Timeline
- 2026-09-28 — Reported to wolfSSL.
- 2026-12-03 — Public disclosure.
Credits
Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.
References
- Ticket replacement in
wolfSSL_d2i_SSL_SESSIONat the tested commit - BYTERAY-2026-0515, replaced session ticket freed without zeroization in SetTicket and wolfSSL_set_SessionTicket
- BYTERAY-2026-0514, replaced TLS 1.3 ticket nonce freed without zeroization
- BYTERAY-2026-0518, session ticket and ticket nonce freed without zeroization on session free and cache eviction