wolfSSL — Missing Fatal Alert When the Empty-Record Limit Is Reached
wolfSSL closes a connection after WOLFSSL_MAX_EMPTY_RECORDS consecutive zero-length application-data records. The fatal unexpected_message alert for that case is compiled only with WOLFSSL_EXTRA_ALERTS, so a default build returns EMPTY_RECORD_LIMIT_E and sends nothing.
- Advisory
- BYTERAY-2026-0456
- 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 empty application-data records a peer may send in a row. The record path counts them in ssl->options.emptyRecordCount. When the count reaches WOLFSSL_MAX_EMPTY_RECORDS, the connection is closed with EMPTY_RECORD_LIMIT_E.
The code sends a fatal unexpected_message alert before it returns that error. The call is inside #ifdef WOLFSSL_EXTRA_ALERTS, which a default build does not define. A few lines earlier in the same function, the early-data overflow check sends the same alert with no build guard.
The limiter works in every build, and a flood of empty records is cut off either way. A default build cuts it off 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, the empty-record limiter inDoApplicationData(), which the record loopDoProcessReplyEx()calls for application-data records. - 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:24117-24128. WOLFSSL_MAX_EMPTY_RECORDS defaults to 32 (wolfssl/wolfcrypt/settings.h:4785-4787).
if (dataSz == 0) {
if (++ssl->options.emptyRecordCount >= WOLFSSL_MAX_EMPTY_RECORDS) {
WOLFSSL_MSG("Too many empty records");
#ifdef WOLFSSL_EXTRA_ALERTS
if (sniff == NO_SNIFF) {
SendAlert(ssl, alert_fatal, unexpected_message);
}
#endif
WOLFSSL_ERROR_VERBOSE(EMPTY_RECORD_LIMIT_E);
return EMPTY_RECORD_LIMIT_E;
}
}
- After the handshake, the peer sends application-data records whose plaintext length is zero. Each one increments
ssl->options.emptyRecordCountatsrc/internal.c:24118. - At the limit, the
SendAlert()call atsrc/internal.c:24120-24124is the only peer-visible response. WithoutWOLFSSL_EXTRA_ALERTSit is not compiled. With the macro it is still skipped when the function runs for the sniffer. - The function returns
EMPTY_RECORD_LIMIT_Eatsrc/internal.c:24126. The record loop returns the error and the connection is abandoned.
For comparison, the early-data overflow branch at src/internal.c:24104-24110 calls SendAlert(ssl, alert_fatal, unexpected_message) in every build. Two protocol violations handled side by side in one function get different treatment, which indicates that the guard on the empty-record branch is not a deliberate policy.
Reachability and Preconditions
- Build without
WOLFSSL_EXTRA_ALERTS. - Client or server role. The peer must be able to send application-data records, which means an established session.
- The attacker is the remote peer and sends empty records until the limit is reached. No further privilege is needed. The trigger is deterministic.
Impact
The connection that trips the limiter is closed in every build, so an attacker gains no additional denial-of-service capability. 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. The peer and any operator see a truncation and no cause. The effect is on protocol conformance, interoperability and diagnostics. The only connection affected is the one that sent the empty records. 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 move the SendAlert() call for the empty-record limit out of the WOLFSSL_EXTRA_ALERTS block, matching the early-data branch above it. If the sniffer exception is intended, it can stay as the only exception. The other error returns on the record path deserve the same review so that one violation maps to one alert in every build. 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.