wolfSSL — Incomplete Reset of ECH Retry Configurations in wolfSSL_clear on Reused Client Objects
wolfSSL_clear() does not free the ECH retry configurations stored on a client object or clear their accepted flag. After one ECH rejection, any later rejection on the recycled object fails with a fatal error in SetRetryConfigs, and the getter can return the previous connection's retry configurations.
- Advisory
- BYTERAY-2026-0395
- CWE
- CWE-459
- CVSS
- 5.3 (CVSS:3.1/AV:N/AC:L/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 (tested at master commit d95483f), builds with HAVE_ECH (--enable-ech), TLS 1.3 clients that reuse WOLFSSL objects with wolfSSL_clear()
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
When a server rejects a client's Encrypted Client Hello (ECH), it can send retry configurations in EncryptedExtensions. wolfSSL stores them on the connection object in ssl->echRetryConfigs and marks them with options.echRetryConfigsAccepted. The handshake then aborts with ECH_REQUIRED, as designed, and the application reads the configurations to retry.
wolfSSL_clear(), the call that recycles a WOLFSSL object for a new connection, clears neither the slot nor the flag. On the next connection, a second ECH rejection cannot store new retry configurations: SetRetryConfigs() refuses to overwrite an occupied slot and returns a fatal error, and its caller does not tolerate that error. The connection aborts while processing EncryptedExtensions, with no retry configurations to read. This repeats on every further reuse of the object.
The failure is fail-closed. The effect is loss of the ECH recovery mechanism on recycled client objects, plus the previous connection's retry configurations being reported for a later connection in one case. ECH is not part of a default build.
Affected Products and Versions
- Component:
src/ssl_ech.c,SetRetryConfigs(), and the reset pathwolfSSL_clear()insrc/ssl.c. - Required build:
HAVE_ECHwith TLS 1.3.--enable-echis off by default (configure.ac:2621-2623). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild does not include this code. Clients that allocate a newWOLFSSLobject per connection are not affected. - Other releases were not checked.
Technical Details
The slot is connection state: final teardown frees it (src/internal.c:9951-9954). wolfSSL_clear() (src/ssl.c:5774-6089) resets its fields one by one and contains no reference to echRetryConfigs or echRetryConfigsAccepted.
SetRetryConfigs() guards the slot (src/ssl_ech.c:345-360):
if (ssl->echRetryConfigs != NULL) {
return WOLFSSL_FATAL_ERROR;
}
The sequence on a recycled client object:
- Connection A is rejected.
TLSX_ECH_Parse()callsSetRetryConfigs()(src/tls.c:15044), which fills the slot. At the end of the handshake the client setsechRetryConfigsAcceptedfrom the stored slot and returnsECH_REQUIRED(src/tls13.c:16824-16841). That return comes before the success-path cleanup. The only other cleanup applies to GREASE connections, wheressl->echConfigsis NULL (src/tls.c:15051-15056). - The application calls
wolfSSL_clear(). The slot and the flag keep their values. - Connection B is rejected and the server sends retry configurations.
SetRetryConfigs()returnsWOLFSSL_FATAL_ERRORbecause the slot is occupied. The caller converts onlyUNSUPPORTED_SUITEandUNSUPPORTED_PROTO_VERSIONto success (src/tls.c:15044-15049), so the error propagates and EncryptedExtensions processing fails. - Connection B aborts with a generic fatal error. The application has no retry configurations from this server.
A second effect concerns the getter. If connection B's EncryptedExtensions has no ECH extension, the flag reset at src/tls.c:15060 does not run, and the end-of-handshake code sets the flag again from connection A's slot. wolfSSL_GetEchRetryConfigs() returns whatever the slot holds when the flag is set (src/ssl_ech.c:488-498), so it hands connection A's retry configurations to the application as if they came from connection B.
Reachability and Preconditions
- Build with
HAVE_ECH. The client has ECH configurations set and offers ECH. - The application reuses the client
WOLFSSLobject withwolfSSL_clear(). - One ECH rejection with retry configurations has occurred on the object. Any server the client connects to can deliver that. No authentication is involved.
- A later connection on the same object is rejected again.
Impact
Availability of the ECH retry path. After the first rejection, the recycled object cannot complete the retry flow again: each later rejection ends in a fatal handshake error with no retry configurations. Connections abort; they do not fall back to an unprotected handshake. The stale data returned by the getter is server configuration that is public, so this is state confusion between connections and not disclosure of secrets. There is no memory corruption.
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 for wolfSSL_clear() to free ssl->echRetryConfigs, set it to NULL and clear options.echRetryConfigsAccepted, as teardown does. A single helper for all connection-scoped ECH state, called from both teardown and wolfSSL_clear(), keeps the two paths the same. As a further safeguard, wolfSSL_GetEchRetryConfigs() can check that the stored configurations belong to the current handshake. Applications can avoid the condition by creating a new WOLFSSL object for each connection attempt that uses ECH.
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.