wolfSSL — Missing Zeroization of Freed Dynamic Session Ticket in Server Ticket Creation
CreateTicket switches the session back to its static ticket buffer before building a new ticket. If the session's ticket was in a heap buffer, that buffer is freed without being wiped, and the previously installed ticket stays in freed heap memory.
- Advisory
- BYTERAY-2026-0507
- 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), server builds with HAVE_SESSION_TICKET (--enable-session-ticket) where the session holds a dynamically allocated ticket buffer when a new ticket is created
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
On a server, CreateTicket() builds the ticket that is sent in a NewSessionTicket message. It always works in the session's fixed-size static ticket buffer. If the session's ticket pointer currently refers to a heap buffer, the function frees that buffer and switches to the static one.
The free is not preceded by a wipe. A session has a heap ticket buffer when a ticket was installed from outside the handshake, for example through wolfSSL_set_SessionTicket() or through the ticket parse callback. The freed block still holds that ticket, an encrypted token the server may keep accepting for resumption until it expires. A few lines later the same function clears the static buffer it is about to fill, so the replacement is scrubbed and the released buffer is not.
The residue cannot be used directly. Recovering it needs a separate way to read reused heap memory in the same process, and the ticket is encrypted under server-side keys. Session tickets are off in a default build, and routine server deployments do not hold a dynamic ticket buffer at this point.
Affected Products and Versions
- Component:
src/internal.c,CreateTicket(). - Required build:
HAVE_SESSION_TICKET, server side. The callback route to a dynamic ticket buffer also needsHAVE_SECRET_CALLBACK. At run time,ssl->session->ticketmust point to a heap buffer whenCreateTicket()runs. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- Session tickets are off in a default
./configurebuild (configure.ac:9470-9473), so a default build does not include this code. - Other releases were not checked.
Technical Details
The release is at the start of the function (src/internal.c:43337-43342):
if (ssl->session->ticket != ssl->session->staticTicket) {
/* Always use the static ticket buffer */
XFREE(ssl->session->ticket, NULL, DYNAMIC_TYPE_SESSION_TICK);
ssl->session->ticket = ssl->session->staticTicket;
ssl->session->ticketLenAlloc = 0;
}
The static buffer is then cleared with XMEMSET(ssl->session->ticket, 0, SESSION_TICKET_LEN) (src/internal.c:43351). There is no ForceZero before the XFREE.
Data flow:
- A ticket is installed into the session's heap buffer.
wolfSSL_set_SessionTicket()allocates one when the ticket does not fit the static buffer (src/ssl_api_ext.c:1507-1519). The same function is called on received ticket bytes on the ticket parse callback path (src/internal.c:44230). - The server issues a new ticket.
CreateTicket()is called from the TLS 1.2 server path (src/internal.c:44354) and from the TLS 1.3 server path (src/tls13.c:14828). CreateTicket()sees that the ticket pointer is not the static buffer and frees the heap buffer (src/internal.c:43339). The freed block keeps the previous ticket bytes until the allocator reuses it.
Reachability and Preconditions
- Server build with session tickets enabled.
- The server-side session holds a dynamically allocated ticket buffer. This comes from the API or callback paths above, or from session duplication and set APIs. It is not the state of a routine server handshake.
- A new ticket is issued on that session. Each issuance in this state releases one unwiped buffer.
- To learn the residue, an attacker additionally needs a memory-disclosure primitive in the same process. This issue does not provide one.
Impact
A copy of a session ticket that may still be valid is left in freed heap memory. The ticket is encrypted under the server's ticket keys and has no impersonation value by itself. Disclosure depends on heap reuse and a second defect that reads the reused block.
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 wipe the dynamic buffer over its allocated length immediately before the free in CreateTicket(), matching the clear already applied to the static buffer. Every other site that releases a session ticket buffer should follow the same rule, including the renewal and API install paths. Builds without HAVE_SESSION_TICKET do not contain this code.
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.