wolfSSL — Missing Fatal Alert When the Alert-Count Limit Is Reached in DoAlert
DoAlert closes a connection once the peer has sent WOLFSSL_ALERT_COUNT_MAX alert records. The fatal unexpected_message alert that announces this is compiled only with WOLFSSL_EXTRA_ALERTS, so a default build ends the connection with ALERT_COUNT_E and sends nothing.
- Advisory
- BYTERAY-2026-0452
- 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), builds without WOLFSSL_EXTRA_ALERTS, which includes the default configuration
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
wolfSSL limits how many alert records a peer may send on one connection. DoAlert() counts each received alert in ssl->options.alertCount. When the count reaches WOLFSSL_ALERT_COUNT_MAX, the connection is treated as an alert flood and is closed.
The handler replies to the flood with a fatal unexpected_message alert. That reply is inside #ifdef WOLFSSL_EXTRA_ALERTS, which a default build does not define. In a default build the function goes straight to return ALERT_COUNT_E.
The limiter works in every build and the flooding connection is closed either way. A default build closes it without the alert, so the peer sees the connection stop with no TLS-level reason. Default builds are affected.
Affected Products and Versions
- Component:
src/internal.c,DoAlert(), the alert-count limiter. - 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 alert. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild is affected. Other releases were not checked.
Technical Details
The limiter is at src/internal.c:24566-24574. WOLFSSL_ALERT_COUNT_MAX defaults to 5 (wolfssl/wolfcrypt/settings.h:4778-4780).
if (++ssl->options.alertCount >= WOLFSSL_ALERT_COUNT_MAX) {
WOLFSSL_MSG("Alert count exceeded");
#ifdef WOLFSSL_EXTRA_ALERTS
if (level != alert_warning || code != close_notify)
SendAlert(ssl, alert_fatal, unexpected_message);
#endif
WOLFSSL_ERROR_VERBOSE(ALERT_COUNT_E);
return ALERT_COUNT_E;
}
- The peer sends alert records.
DoAlert()reads the level and description of each one (src/internal.c:24528-24530). Both bytes are chosen by the peer. - Each alert increments
ssl->options.alertCountatsrc/internal.c:24566. - When the count reaches the limit, the only peer-visible response is the
SendAlert()call atsrc/internal.c:24568-24571. WithoutWOLFSSL_EXTRA_ALERTSit is not compiled. DoAlert()returnsALERT_COUNT_Eatsrc/internal.c:24573. The record loop returns the error and the connection is abandoned.
With the macro defined, the same input produces a fatal unexpected_message alert, except when the last alert was a warning-level close_notify.
Reachability and Preconditions
- Build without
WOLFSSL_EXTRA_ALERTS. - Client or server role, TLS or DTLS.
- The attacker is the remote peer and must send enough alert records on one connection to reach the limit. Alerts that do not themselves end the connection, such as
user_canceled, are sufficient. - No authentication is required. The trigger is deterministic.
Impact
The connection that trips the limiter is closed in every build, so the flood is contained. In a default build it is closed without the fatal alert that a TLS endpoint is expected to send when it aborts on an error. A conformant peer, or an operator reading a capture, sees a truncation and no cause. The effect is on protocol conformance and diagnostics. The only connection affected is the one that sent the alerts. Confidentiality and integrity are not affected.
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 unexpected_message alert at this site in every build, and to keep WOLFSSL_EXTRA_ALERTS for alerts that are optional. A regression test on the default configuration that trips the limiter and expects the alert would keep the two configurations aligned. The other guarded alert site in DoAlert() is described in BYTERAY-2026-0451. 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.