wolfSSL — Handshake Error-to-Alert Mapping Compiled Out in SendFatalAlertOnly
SendFatalAlertOnly, the function that turns a handshake error code into a fatal alert, is an empty stub unless WOLFSSL_EXTRA_ALERTS is defined. In a default build, out-of-order, duplicate and wrong-side handshake messages end the TLS 1.2 or DTLS connection without an alert.
- Advisory
- BYTERAY-2026-0464
- 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.2 and DTLS endpoints in builds without WOLFSSL_EXTRA_ALERTS, which includes the default configuration
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
When a handshake message is rejected, the wolfSSL record layer passes the error code to SendFatalAlertOnly(). That function is meant to choose the matching fatal alert and send it before the connection is closed.
The mapping exists only when the build defines WOLFSSL_EXTRA_ALERTS. Without the macro the function is a stub that returns 0. The check that would catch a missing alert afterwards, wolfssl_local_MaybeCheckAlertOnErr(), is likewise empty unless WOLFSSL_CHECK_ALERT_ON_ERR is defined. Every TLS 1.2 and DTLS handshake error that relies on this function is therefore dropped without an alert in a default build.
The handling is also uneven. A client that omits the Certificate message under required client authentication gets no alert, while a client that sends an empty Certificate message gets handshake_failure. The handshake fails in every case, so this is a protocol-compliance and diagnosability defect. Default builds are affected.
Affected Products and Versions
- Component:
src/internal.c,SendFatalAlertOnly()and its call sites inDoProcessReplyEx()and the DTLS handshake message handling. - Required build: any build that does not define
WOLFSSL_EXTRA_ALERTS. The macro, together withWOLFSSL_CHECK_ALERT_ON_ERR, is defined by--enable-harden-tls(configure.ac:393); OpenSSL compatibility builds defineWOLFSSL_EXTRA_ALERTS(wolfssl/wolfcrypt/settings.h:4727-4735). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild is affected. - Other releases were not checked.
Technical Details
The mapping version of SendFatalAlertOnly() is at src/internal.c:21132-21187. The other version, at src/internal.c:21189-21195:
int SendFatalAlertOnly(WOLFSSL *ssl, int error)
{
(void)ssl;
(void)error;
/* no op */
return 0;
}
A remotely triggered case:
- A peer sends a handshake message out of order, twice, or for the wrong side.
DoProcessReplyEx()passes the message toDoHandShakeMsg()(src/internal.c:26282-26285).SanityCheckMsgReceived()rejects it withOUT_OF_ORDER_E,DUPLICATE_MSG_EorSIDE_ERROR, for example atsrc/internal.c:20458-20463.DoProcessReplyEx()callsSendFatalAlertOnly(ssl, ret)(src/internal.c:26286-26290). In a default build this does nothing.- The error is returned to the application and the connection is closed with nothing sent.
The same call is made for DTLS 1.2 (src/internal.c:26230), DTLS 1.3 (src/internal.c:26268) and the DTLS buffered-message loop (src/internal.c:21677). With WOLFSSL_EXTRA_ALERTS, the same OUT_OF_ORDER_E maps to unexpected_message (src/internal.c:21168-21172). Two inconsistencies sit next to the gate. An empty Certificate message under required client authentication reaches DoCertFatalAlert() and its ungated SendAlert() (src/internal.c:18457-18466, src/internal.c:16224); an omitted Certificate message does not. In DoProcessReplyEx(), a decrypt failure always sends bad_record_mac (src/internal.c:26006-26009), while the MAC verification failure branches send it only under WOLFSSL_EXTRA_ALERTS and return the generic DECRYPT_ERROR (src/internal.c:25920-25925, src/internal.c:26045-26051). A comment in DoClientHello() notes that the mapper is compiled out and sends protocol_version inline for that reason (src/internal.c:41906-41919).
Reachability and Preconditions
- Build without
WOLFSSL_EXTRA_ALERTS, and a TLS 1.2 or DTLS endpoint, client or server, reachable over the network. No runtime option is needed. - The attacker is any remote peer. It controls which handshake messages it sends and in what order.
- No authentication is needed. The checks run during the handshake.
Impact
A peer that violates the handshake sequence has the connection closed without the fatal alert RFC 5246 requires. The peer sees a truncated connection; a DTLS peer keeps retransmitting until it times out. Interoperability suffers and operators lose the peer-visible reason for a rejected handshake. There is no code execution, disclosure or authentication effect. The handshake is rejected in every build.
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 compile the mapping in SendFatalAlertOnly() into every build and remove the stub, so that each handshake failure at the four call sites sends an alert before teardown. The omitted and the empty Certificate message should get the same alert. The MAC verification failure branches should send bad_record_mac in every build, as the decrypt failure branch does, and keep the specific cause for the application. The wolfssl_local_MaybeCheckAlertOnErr() check should be active by default. Workaround: build with --enable-harden-tls, or define WOLFSSL_EXTRA_ALERTS and WOLFSSL_CHECK_ALERT_ON_ERR in CFLAGS.
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.