wolfSSL — Missing Fatal Alert on Malformed ServerKeyExchange in TLS 1.2 Client
The client-side ServerKeyExchange handler rejects an invalid X25519, X448 or ECC server key and an unsupported signature algorithm, but the fatal alerts for those four cases are compiled only with WOLFSSL_EXTRA_ALERTS. A default build drops the handshake without an alert.
- Advisory
- BYTERAY-2026-0459
- 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 clients 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, a server that uses an ephemeral key exchange sends its key and a signature in a ServerKeyExchange message. The wolfSSL client processes it in DoServerKeyExchange() and, for elliptic-curve suites, in its helper GetEcDiffieHellmanKea(). Both validate the server's ephemeral public key and the signature algorithm it chose.
Four rejection branches map the failure to a fatal alert: decode_error, bad_record_mac, illegal_parameter or handshake_failure. In each branch the SendAlert() call is inside #ifdef WOLFSSL_EXTRA_ALERTS. A default build does not define that macro. Two of the branches discard the specific error with (void)ret;, and all four return a library error code with nothing sent.
The client refuses the connection in every build. In a default build the server sees the handshake stop with no TLS-level reason. Default builds are affected.
Affected Products and Versions
- Component:
src/internal.c,DoServerKeyExchange()and its helperGetEcDiffieHellmanKea(). - 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
The four branches:
- X25519:
wc_curve25519_check_public()fails (src/internal.c:36328-36342). With the macro,BUFFER_Emaps todecode_error,ECC_OUT_OF_RANGE_Etobad_record_macand anything else toillegal_parameter. Without it, the branch is(void)ret;atsrc/internal.c:36339and the function returnsECC_PEERKEY_ERROR. - X448: the same shape (
src/internal.c:36372-36386), with its own(void)ret;atsrc/internal.c:36383. - ECC: the X9.63 point import fails (
src/internal.c:36423-36428). The guarded alert isillegal_parameter. The function returnsECC_PEERKEY_ERROR. - Signature algorithm: the hash and signature pair in the message is not one the client supports (
src/internal.c:36621-36628). The guarded alert ishandshake_failure. The handler exits withMATCH_SUITE_ERROR.
The signature-algorithm branch, from src/internal.c:36623-36628:
if (!SupportedHashSigAlgo(ssl, &input[args->idx])) {
#ifdef WOLFSSL_EXTRA_ALERTS
SendAlert(ssl, alert_fatal, handshake_failure);
#endif
ERROR_OUT(MATCH_SUITE_ERROR, exit_dske);
}
- The client negotiates a DHE or ECDHE suite. The server sends a ServerKeyExchange with an ephemeral public key that fails validation, or with a signature algorithm the client does not support.
- The client takes one of the four branches. Without
WOLFSSL_EXTRA_ALERTSnoSendAlert()call is compiled there. - The error returns through
DoHandShakeMsg()to the record loop, and the client abandons the handshake. 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 client. - A TLS 1.2 or earlier handshake with a suite that uses a ServerKeyExchange.
- The attacker is the server the client connects to, or a server that simply misbehaves. It controls the key and the signature-algorithm bytes. One message is enough, and the trigger is deterministic.
Impact
The client rejects the handshake in every build, so no authentication is bypassed and no data is exposed. In a default build it sends no alert. The server and any operator see a truncation, and a deliberate protocol violation cannot be told apart from a network failure. The effect is on protocol conformance, diagnostics and interoperability.
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 send the four alerts in every build and to remove the (void)ret; placeholders: decode_error, bad_record_mac or illegal_parameter for the X25519 and X448 checks, illegal_parameter for the ECC import, and handshake_failure for an unsupported signature algorithm. The library error codes returned to the application should stay as they are. The server-side counterpart is described in BYTERAY-2026-0455. 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.
References
- X25519, X448 and ECC branches in
GetEcDiffieHellmanKeaat the tested commit - Signature-algorithm check in
DoServerKeyExchangeat the tested commit - BYTERAY-2026-0455, missing fatal alert on malformed ClientKeyExchange
- BYTERAY-2026-0464, handshake failures dropped without a fatal alert in default builds