wolfSSL — Incomplete Reset of the ECH Accepted Flag in wolfSSL_clear on Reused Server Objects
wolfSSL_clear() does not reset ssl->options.echAccepted, and no server code path clears it. After one accepted ECH connection, a recycled server object answers any later ClientHello whose ECH extension fails to decrypt, including GREASE, with a fatal decrypt_error alert instead of falling back to the outer ClientHello.
- Advisory
- BYTERAY-2026-0396
- CWE
- CWE-665
- 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 servers that reuse WOLFSSL objects with wolfSSL_clear()
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
A wolfSSL server records that it accepted Encrypted Client Hello (ECH) for a connection in ssl->options.echAccepted. The same flag decides what happens when an ECH extension fails to decrypt. With the flag clear, the server falls back: it completes the handshake over the outer ClientHello and sends retry configurations. With the flag set, it treats the failure as fatal and sends a decrypt_error alert.
wolfSSL_clear() does not reset the flag, and no server-side code ever writes it back to 0. On a server that recycles WOLFSSL objects, the first connection accepted with ECH leaves the flag set for the rest of the object's life. Every later connection on that object that presents an ECH extension the server cannot decrypt is dropped with a fatal alert. GREASE ECH extensions, which are not meant to decrypt, fall in that group.
The failure is fail-closed, so the impact is availability. An unauthenticated client can set the flag, because ECH configurations are public. ECH is not part of a default build.
Affected Products and Versions
- Component:
src/tls.c,TLSX_ECH_Parse(), 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. Servers that allocate a newWOLFSSLobject per connection are not affected. - Other releases were not checked.
Technical Details
wolfSSL_clear() (src/ssl.c:5774-6089) resets the object field by field. It resets the options members individually, without a bulk clear (src/ssl.c:5794-5945), and it contains no ECH identifier.
The flag is written in three places. The client sets it to 1 and to 0 when it checks the server's acceptance (src/tls13.c:5503, src/tls13.c:5529). The server sets it to 1 when it decrypts the inner ClientHello (src/tls.c:15254). There is no reset at the start of a handshake and no server-side write of 0, including on the decryption-failure path.
The consumer is the decryption-failure branch in TLSX_ECH_Parse() (src/tls.c:15234-15250). When echAccepted is 0, the branch sets the extension state to ECH_WRITE_RETRY_CONFIGS and returns success. Otherwise it sends a fatal decrypt_error alert and returns DECRYPT_ERROR. That second case is meant for a failure after a HelloRetryRequest, when ECH was already accepted on the first ClientHello of the same connection.
The sequence on a recycled server object:
- Connection A carries an ECH extension that decrypts. The server sets
echAccepted = 1while parsing the ClientHello. The handshake does not have to complete. - The connection ends and the application calls
wolfSSL_clear(). The flag stays 1. - Connection B carries an ECH extension that does not decrypt: a malformed one, or a GREASE extension. A fresh object would take the first branch and complete over the outer ClientHello. The recycled object takes the second branch and aborts.
- Nothing clears the flag afterwards. A connection whose ECH extension decrypts rewrites it with 1 again.
The stale value has no further effect that weakens a check. On the client, an ECH-offering handshake rewrites the flag before the checks that read it. The post-HelloRetryRequest comparison on the server (src/tls.c:19612-19621) runs only when the second ClientHello carries ECH, by which point the flag reflects the current connection or the handshake has already aborted.
Reachability and Preconditions
- Build with
HAVE_ECH. The server has ECH configurations loaded. - The server application reuses
WOLFSSLobjects withwolfSSL_clear(). - An unauthenticated client sends one ClientHello with a valid ECH extension to set the flag on an object. ECH configurations are published, so any client can do this.
- Later clients served by that object send an ECH extension that fails to decrypt. Clients that send GREASE ECH do this in normal operation.
Impact
Connections on a contaminated object that would have completed over the outer ClientHello are aborted with a fatal decrypt_error alert. The condition lasts for the lifetime of the object and can be re-established on other pooled objects by repeating step 1. Connections without an ECH extension, and connections whose ECH decrypts, are unaffected. There is no confidentiality or integrity loss and 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 to clear ssl->options.echAccepted in wolfSSL_clear() with the other per-connection option fields, preferably through one reset helper for all ECH state. As a second measure, the server can write 0 to the flag when it rejects or fails to decrypt ECH, so the fallback branch always reads the current connection's decision.
Server applications can avoid the condition by allocating a new WOLFSSL object per connection instead of calling wolfSSL_clear().
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.