wolfSSL — Missing Error Code Store in TLS 1.3 Client Server-Authentication Fail-Safe
The server-authentication fail-safe in wolfSSL_connect_TLSv13 returns WOLFSSL_FATAL_ERROR without storing a cause in ssl->error. wolfSSL_get_error then returns a leftover value, zero or a stale WANT_READ or WANT_WRITE, and a retried connect call hits the same check again.
- Advisory
- BYTERAY-2026-0468
- CWE
- CWE-544
- 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 (tested at master commit d95483f), TLS 1.3 clients; the fail-safe is reachable in builds with WOLFSSL_CERT_WITH_EXTERN_PSK or WOLFSSL_DUAL_ALG_CERTS
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
The TLS 1.3 client handshake in wolfSSL_connect_TLSv13() has a last check that the server was authenticated. If ssl->options.peerAuthGood is still false in the FIRST_REPLY_SECOND state, the function stops and returns WOLFSSL_FATAL_ERROR.
The branch logs the failure but does not write a cause to ssl->error. The neighboring return paths in the same function store one, and the same check in the TLS 1.2 client stores NO_PEER_VERIFY. An application that calls wolfSSL_get_error(), as the API documentation directs, receives whatever the slot held: zero on a reused object, or a WANT_READ or WANT_WRITE from an earlier non-blocking round.
The connection is refused, so server authentication is not bypassed. The application can however read the failure as "no error", or retry a connect call that returns to the same check each time. The missing store is unconditional in the source. Reaching the check with the flag unset needs specific build options, so a default build is not known to be exposed.
Affected Products and Versions
- Component:
src/tls13.c,wolfSSL_connect_TLSv13(), theFIRST_REPLY_SECONDcase. - Required build: TLS 1.3 client. The identified ways to reach the check with
peerAuthGoodunset needWOLFSSL_CERT_WITH_EXTERN_PSKorWOLFSSL_DUAL_ALG_CERTS. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild contains the branch. No route to it withpeerAuthGoodunset was identified without one of the two options. - Other releases were not checked.
Technical Details
The fail-safe in case FIRST_REPLY_SECOND at src/tls13.c:16735-16739:
if (!ssl->options.peerAuthGood) {
WOLFSSL_MSG("Server authentication did not happen");
WOLFSSL_ERROR_VERBOSE(WOLFSSL_FATAL_ERROR);
return WOLFSSL_FATAL_ERROR;
}
WOLFSSL_ERROR_VERBOSE only logs. The adjacent return paths assign ssl->error first (src/tls13.c:16701-16703, src/tls13.c:16743-16747), and the TLS 1.2 client check stores NO_PEER_VERIFY before the same return (src/ssl_api_hs.c:635-638).
Configurations in which peerAuthGood can still be 0 at the check:
WOLFSSL_CERT_WITH_EXTERN_PSK: the flag is held at 0 until certificate authentication happens (src/tls13.c:4562). If the server then sends no Certificate message and no earlier error was stored, the check fires.WOLFSSL_DUAL_ALG_CERTS: the flag is set fromargs->altPeerAuthGood, which is 0 when the alternative signature check fails (src/tls13.c:13385-13388).
After the return, with ssl->error untouched:
wolfSSL_get_error()returns the slot as it is when no conversion applies (src/ssl.c:1701): 0, or a staleWANT_READorWANT_WRITE.- The connect state is already
FIRST_REPLY_SECOND(src/tls13.c:16729). A retry enters the same case and fails the same way.
Reachability and Preconditions
- A TLS 1.3 client built with
WOLFSSL_CERT_WITH_EXTERN_PSKorWOLFSSL_DUAL_ALG_CERTS, and a server that omits or fails authentication in a way that does not store an earlier error on the session. - The application decides what to do from
wolfSSL_get_error()(src/ssl_api_hs.c:346-349), as event-loop and retry-style code does. - The attacker is the remote server, or a party able to act as it. No authentication is needed.
Impact
A final server-authentication failure cannot be identified through the public API. An event-driven client can enter a busy retry loop, or can handle the failure as "no error". There is no confidentiality or integrity effect on application data. The handshake does not complete. The availability effect is limited to the affected connection and the control flow of the application.
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 set ssl->error = NO_PEER_VERIFY before the return in this fail-safe, as the TLS 1.2 client check and the neighboring TLS 1.3 paths do. The remaining fail-safe returns in the connect and accept drivers should be reviewed for the same gap. Application-side mitigation: treat WOLFSSL_FATAL_ERROR from wolfSSL_connect() as final when wolfSSL_get_error() returns zero, and bound the number of handshake retries.
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.