← ALL ADVISORIES

LOW BYTERAY-2026-0451Disclosed

wolfSSL — Missing Fatal Alert on Malformed Alert Record in DoAlert

DoAlert rejects an alert record whose payload is not exactly two bytes, but the fatal unexpected_message alert it sends in reply is compiled only with WOLFSSL_EXTRA_ALERTS. A default build drops the connection without telling the peer why.

Advisory
BYTERAY-2026-0451
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

A TLS alert is two bytes: a level and a description. DoAlert() in src/internal.c checks that an incoming alert record has exactly that size and fits in the input buffer. A record that fails the check is rejected and the connection ends.

The code answers the malformed record with a fatal unexpected_message alert before it returns the error. That call is inside #ifdef WOLFSSL_EXTRA_ALERTS. The macro is not defined in a default build, so the reply is compiled out and the function returns BUFFER_E with nothing sent.

The peer sees the connection stop without a TLS-level reason. The connection ends in both configurations. What a default build loses is the error signal that TLS defines for this case. Default builds are affected.

Affected Products and Versions

  • Component: src/internal.c, DoAlert(), the handler for received alert 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 ./configure build is affected. Other releases were not checked.

Technical Details

The size check and its reply are at src/internal.c:24520-24526:

    if (dataSz != ALERT_SIZE ||
            *inOutIdx + ALERT_SIZE > ssl->buffers.inputBuffer.length) {
#ifdef WOLFSSL_EXTRA_ALERTS
        SendAlert(ssl, alert_fatal, unexpected_message);
#endif
        return BUFFER_E;
    }

The check itself is correct. Only the reply depends on the build.

  1. A peer sends a record of content type alert whose payload length is not two, for example a single byte.
  2. DoProcessReplyEx() dispatches the record to DoAlert().
  3. The size check at src/internal.c:24520-24521 fails.
  4. Without WOLFSSL_EXTRA_ALERTS, lines src/internal.c:24522-24524 do not exist in the binary. DoAlert() returns BUFFER_E at src/internal.c:24525.
  5. The error propagates out of the record loop and the connection is abandoned. No alert was written.

The same function shows the unconditional form. A plaintext alert received while TLS 1.3 encryption is on is answered with SendAlert(ssl, alert_fatal, unexpected_message) at src/internal.c:24592, with no build guard. The malformed-record branch does not follow that pattern.

Reachability and Preconditions

  • Build without WOLFSSL_EXTRA_ALERTS.
  • Client or server role, TLS or DTLS. The handler runs for every received alert record.
  • The attacker is the remote peer, or a party on the path who can inject a record that the receiver accepts as an alert.
  • No authentication is required. The record can arrive during or after the handshake. One malformed record is enough, and the trigger is deterministic.

Impact

The malformed record is rejected and the connection ends, which is the correct outcome. The defect is that a default build ends it silently. The peer cannot tell a protocol violation from a network failure, and a DTLS peer that receives no alert can keep retransmitting until its own timer expires. The effect is on protocol conformance, interoperability and diagnostics. Confidentiality and integrity are not affected, and the availability effect is limited to the connection that sent the malformed record.

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 remove the WOLFSSL_EXTRA_ALERTS guard around this SendAlert() call so the alert is sent in every build, as the unguarded call later in the same function already is. The remaining guarded alert sites in DoAlert() deserve the same review. One of them is described in BYTERAY-2026-0452. Workaround: build with WOLFSSL_EXTRA_ALERTS defined, for example with CPPFLAGS=-DWOLFSSL_EXTRA_ALERTS. That enables the alert at this site and at the other sites guarded by the same macro.

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