wolfSSL — Missing Fatal Alert on Malformed ClientKeyExchange in TLS 1.2 Server
The server-side ClientKeyExchange handler rejects an invalid X25519, X448 or ECC public key and a mismatched RSA premaster length, but the fatal alerts for those four cases are compiled only with WOLFSSL_EXTRA_ALERTS. A default build closes the connection without an alert.
- Advisory
- BYTERAY-2026-0455
- 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 earlier servers in builds without WOLFSSL_EXTRA_ALERTS, which includes the default configuration
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
In TLS 1.2 and earlier the client sends its key-exchange value in a ClientKeyExchange message. The wolfSSL server processes it in DoClientKeyExchange() and, for elliptic-curve suites, in its helper ImportPeerECCKey(). Both validate what the client sent and reject bad values.
Four rejection branches pair the error return with a fatal alert: decode_error, bad_record_mac or illegal_parameter, depending on the failure. In each branch the SendAlert() call is inside #ifdef WOLFSSL_EXTRA_ALERTS. A default build does not define that macro and returns the internal error code with nothing sent.
The malformed key is never accepted and the handshake fails in every build. In a default build the client sees the connection stop with no TLS-level reason. Default builds are affected.
Affected Products and Versions
- Component:
src/internal.c,DoClientKeyExchange()and its helperImportPeerECCKey(). - Required build: any build that does not define
WOLFSSL_EXTRA_ALERTS. The macro is defined by--enable-harden-tls(configure.ac:393) and by OpenSSL compatibility builds (wolfssl/wolfcrypt/settings.h:4727-4735). Those builds send the alerts. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild is affected. Other releases were not checked.
Technical Details
Four branches reject the message:
- X25519:
wc_curve25519_check_public()or the import that follows fails (src/internal.c:45299-45321). The guarded alert isdecode_error,bad_record_macorillegal_parameter, chosen by the error. The function returnsECC_PEERKEY_ERROR. The(void)ret;atsrc/internal.c:45310exists only to silence the unused value when the alert block is compiled out. - X448: the same shape with
wc_curve448_check_public()(src/internal.c:45358-45381), with its own(void)ret;atsrc/internal.c:45369. - ECC: the X9.63 point import fails (
src/internal.c:45419-45434). The guarded alert isillegal_parameter. The function returnsECC_PEERKEY_ERROR. - RSA: the explicit length that precedes the encrypted premaster secret does not match the server key size (
src/internal.c:45645-45651). The guarded alert isbad_record_mac. The handler exits withRSA_PRIVATE_ERROR.
The RSA length check, from src/internal.c:45645-45651:
if ((word32)check != args->length) {
WOLFSSL_MSG("RSA explicit size doesn't match");
#ifdef WOLFSSL_EXTRA_ALERTS
SendAlert(ssl, alert_fatal, bad_record_mac);
#endif
ERROR_OUT(RSA_PRIVATE_ERROR, exit_dcke);
}
- A client sends a ClientKeyExchange with a public key that fails validation, or with a wrong RSA length prefix.
- The server takes one of the four branches. Without
WOLFSSL_EXTRA_ALERTSnoSendAlert()call is compiled there. The error returns throughDoHandShakeMsg()to the record loop, and the connection is abandoned. The record loop's general fallback,SendFatalAlertOnly(), is an empty stub in the same builds. That is described in BYTERAY-2026-0464.
Reachability and Preconditions
- Build without
WOLFSSL_EXTRA_ALERTS. wolfSSL acts as a server in a TLS 1.2 or earlier handshake with an elliptic-curve suite (X25519, X448 or ECC), or with RSA key transport for the fourth branch. - The attacker is a remote client. The message is sent before any client authentication. One message is enough, and the trigger is deterministic.
Impact
The server refuses the handshake in every build. In a default build it does so without the fatal alert, so the client cannot tell a rejected key from a network fault. Interoperability testing and monitoring lose the signal they rely on, and identical input produces different wire behavior depending on the build. No state is corrupted and no data is exposed. The only connection affected is the one that sent the malformed message.
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 move the four SendAlert() calls out of the WOLFSSL_EXTRA_ALERTS blocks, all together, so that the same violation produces the same alert in every configuration. An equivalent approach is to map ECC_PEERKEY_ERROR and RSA_PRIVATE_ERROR to fatal alerts in a handshake-layer error handler that is active in default builds. The client-side counterpart is described in BYTERAY-2026-0459. Workaround: build with WOLFSSL_EXTRA_ALERTS defined, for example with CPPFLAGS=-DWOLFSSL_EXTRA_ALERTS.
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.