wolfSSL — Stale Resumption Flags in the SSLv2-Format ClientHello Handler on Reused Server Connections
The handler for SSLv2-format ClientHello messages sets the server's resumption flag but never clears it, and wolfSSL_clear does not reset it either. On a reused server object, a hello with no session id is processed as a resumption left over from the previous connection: keys are derived and the client is marked authenticated before the handshake fails at ChangeCipherSpec.
- Advisory
- BYTERAY-2026-0421
- CWE
- CWE-1271
- CVSS
- 3.7 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L)
- Vendor
- wolfSSL
- Product
- wolfSSL
- Reported
- 2026-09-28
- Disclosure
- 2026-12-03
- Affected
- wolfSSL 5.9.2 through 5.9.4, server builds with OLD_HELLO_ALLOWED that reuse WOLFSSL objects through wolfSSL_clear
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
A wolfSSL server built with OLD_HELLO_ALLOWED accepts a ClientHello in the old SSLv2 record format. The handler for that format, ProcessOldClientHello(), turns the resuming option on when the hello carries a session id. It has no statement that turns it off. The modern handler, DoClientHello(), resets the flag on entry. The old one relies on the flag being clean already.
It is not clean when the application recycles a WOLFSSL object with wolfSSL_clear(). That function leaves resuming, useTicket and createTicket as the previous connection set them. If the previous connection resumed from a session ticket, the next client can send an SSLv2-format hello with no session id and no ticket, and the server walks the resumption path anyway. It derives record keys, marks the peer as authenticated and sends its own handshake flight. The handshake then fails when the client's ChangeCipherSpec arrives, because the hello was never recorded as received. OLD_HELLO_ALLOWED is off by default and has no configure switch.
Affected Products and Versions
- Component:
src/internal.c,ProcessOldClientHello();src/ssl.c,wolfSSL_clear(). - Required build:
OLD_HELLO_ALLOWEDdefined by hand (src/internal.c:41356-41575; listed as "default: off" atsrc/internal.c:69). The branch that needs no session lookup also needs session tickets (HAVE_SESSION_TICKET). - Required use: a server that calls
wolfSSL_clear()on aWOLFSSLobject and accepts another connection on it. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- The
v5.9.2-stableandv5.9.4-stabletags contain the same handler and the samewolfSSL_clear()behaviour. - Partly addressed on master:
wolfSSL_clear()now resets the two ticket flags. Theresumingflag is still not reset. See Remediation. - A default
./configurebuild does not include this code. Earlier releases were not checked.
Technical Details
The only write to the flag in the handler is conditional on a session id being present (src/internal.c:41503-41509):
/* session id */
if (sessionSz) {
XMEMCPY(ssl->arrays->sessionID, input + idx, sessionSz);
ssl->arrays->sessionIDSz = (byte)sessionSz;
idx += sessionSz;
ssl->options.resuming = 1;
}
A few lines later the handler tests the flag (src/internal.c:41527). If useTicket is 1 it takes ssl->session as the session to resume, with no lookup (src/internal.c:41530-41531). Otherwise it looks the session id up in the cache (src/internal.c:41536). With a session in hand it matches a cipher suite, derives keys from ssl->arrays->masterSecret, sets peerAuthGood and moves the client state to CLIENT_KEYEXCHANGE_COMPLETE (src/internal.c:41542-41564). It returns at src/internal.c:41566. The call that records the hello as received, SanityCheckMsgReceived(ssl, client_hello), is on the other path (src/internal.c:41572) and is skipped.
How the stale state arrives:
- Connection one resumes from a session ticket. The ticket extension parser sets
useTicketandresuming(src/tls.c:6619-6622), and alsocreateTicketwhen it decides to renew the ticket (src/tls.c:6632-6634). - The application calls
wolfSSL_clear()(src/ssl.c:5774-6090). It resetshandShakeDone,peerAuthGoodand the received-message bitmap (src/ssl.c:5805,src/ssl.c:5827,src/ssl.c:6057). It contains no assignment toresuming,useTicketorcreateTicket. - Connection two starts with a record that is neither a handshake record nor ChangeCipherSpec, so the server dispatches to the old-format handler (
src/internal.c:25702-25713). - The hello has
sessionSzof 0. The flag keeps its old value of 1,useTicketis still 1, andssl->sessionis non-NULL. - The handler derives keys and returns success without recording the hello.
DoClientHello() does not have this problem; it clears the flags first (src/internal.c:41871-41873).
Reachability and Preconditions
- The server is built with
OLD_HELLO_ALLOWED. - The server reuses a
WOLFSSLobject throughwolfSSL_clear(). A server that frees the object and creates a new one per connection is not affected, becauseresumingstarts at 0. - The previous connection on that object left
resumingset. For the path without a cache lookup it must also have used a session ticket. - The attacker is any client that can connect next on that object. No credentials are needed. The attacker does not control which object the server picks, which is why the condition is hard to arrange on demand.
Impact
Confirmed from source: the server derives keys from the contents of ssl->arrays->masterSecret and sets peerAuthGood for a client that offered neither a session id nor a ticket. On a recycled object the arrays have been freed and are allocated again zero-filled (src/internal.c:8361-8372), so the keys come from an all-zero master secret. wolfSSL_accept() then sends ServerHello, ChangeCipherSpec and Finished (src/ssl_api_hs.c:976, src/ssl_api_hs.c:1119, src/ssl_api_hs.c:1129). The handshake does not complete: the server-side ChangeCipherSpec check returns OUT_OF_ORDER_E because the hello was never recorded (src/internal.c:20548-20553). The confirmed effect is a failed handshake after the server has done work on state that belongs to another connection.
Not verified: when createTicket is also left set, wolfSSL_accept() sends a NewSessionTicket before its ChangeCipherSpec (src/ssl_api_hs.c:1098-1106), and the ticket is built from the same master secret (src/internal.c:43371). The source suggests the client receives a ticket for a secret it can guess before the handshake fails. ByteRay did not test whether such a ticket is accepted later. The general problem of resumption state surviving wolfSSL_clear() is described in BYTERAY-2026-0307.
ByteRay did not build a proof of concept for this issue. The analysis is from source review.
Remediation and Mitigation
Not fixed on wolfSSL master as of commit e4b0841b32e7 (2026-12-03). Part of the problem is addressed. Commit 78926cec0519cc738831816e5e38a0db741ed08b, merged with PR 11600 on 2026-10-29, makes wolfSSL_clear() reset useTicket and createTicket. That removes the branch that resumed from ssl->session without a lookup on a recycled object. The resuming flag is still not reset by wolfSSL_clear() or by the old-format handler, so a hello with no session id still enters the resumption branch and reaches the session cache lookup. No release contains the partial change.
A complete fix resets resuming, useTicket and createTicket at the top of ProcessOldClientHello(), as DoClientHello() does, and records the hello with SanityCheckMsgReceived() before the resumption shortcut rather than after it.
Workarounds: do not define OLD_HELLO_ALLOWED; no current TLS client needs the SSLv2 hello format. Where it must stay, create a new WOLFSSL object for each connection instead of calling wolfSSL_clear().
Timeline
- 2026-09-28 — Reported to wolfSSL.
- 2026-09-29 — Pull request 11600 opened upstream.
- 2026-10-29 — Pull request 11600 merged to master. It resets the ticket flags in
wolfSSL_clear(). - 2026-12-03 — Public disclosure.
Credits
Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.
References
- Session id handling in
ProcessOldClientHelloat the tested commit - Resumption branch in
ProcessOldClientHelloat the tested commit wolfSSL_clearat the tested commit- wolfSSL pull request 11600
- Commit 78926cec0519, ticket flags reset in
wolfSSL_clear - BYTERAY-2026-0307, resumption state on reused server connections
- BYTERAY-2026-0471, client authentication on SSLv2-format hello resumption
- CWE-1271: Uninitialized Value on Reset for Registers Holding Security Settings