← ALL ADVISORIES

LOW BYTERAY-2026-0457Disclosed

wolfSSL — Missing Fatal Alert on Record Body Read Failure in DoProcessReplyEx

When the record loop fails to read a record body for a reason other than WANT_READ, for example MEMORY_E while growing the input buffer, the fatal alert is compiled only with WOLFSSL_EXTRA_ALERTS. A default build returns the raw error, and the DTLS branch has no alert in any build.

Advisory
BYTERAY-2026-0457
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 in builds without WOLFSSL_EXTRA_ALERTS, which includes the default configuration; DTLS in every build
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

DoProcessReplyEx() in src/internal.c reads one record at a time through a small state machine. Its getData stage calls GetInputData() to read the record body, whose length the peer declared in the record header.

A negative result other than WANT_READ is fatal for the connection. The TLS branch sends a fatal bad_record_mac alert in that case, but only inside #ifdef WOLFSSL_EXTRA_ALERTS. A default build compiles the branch down to a bare return ret. The DTLS branch of the same stage returns the error with no alert path in any configuration.

The connection ends either way. The peer gets no alert and sees an abrupt close. Reaching the hard failure takes memory pressure on the host, so the practical effect is reduced observability. Default builds are affected.

Affected Products and Versions

  • Component: src/internal.c, DoProcessReplyEx(), the getData stage.
  • Required build: for TLS, 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). For DTLS (WOLFSSL_DTLS), every build.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default ./configure build is affected on the TLS branch. Other releases were not checked.

Technical Details

The TLS branch is at src/internal.c:25845-25853:

            if (!ssl->options.dtls) {
                if ((ret = GetInputData(ssl, ssl->curSize)) < 0) {
#ifdef WOLFSSL_EXTRA_ALERTS
                    if (ret != WC_NO_ERR_TRACE(WANT_READ))
                        SendAlert(ssl, alert_fatal, bad_record_mac);
#endif
                    return ret;
                }
            }

The DTLS branch at src/internal.c:25865-25866 is if ((ret = GetInputData(ssl, ssl->curSize)) < 0) return ret;.

  1. The peer sends record headers. ssl->curSize is the body length taken from the header.
  2. GetInputData() is called at src/internal.c:25846 to make that many bytes available. It can fail hard, for example with MEMORY_E when the input buffer cannot be grown.
  3. Without WOLFSSL_EXTRA_ALERTS the SendAlert() call at src/internal.c:25847-25850 is not compiled. The function returns the error at src/internal.c:25851.
  4. The connection is abandoned with nothing sent to the peer.

The same function is not consistent with itself. A decryption failure in the decrypt stage sends bad_record_mac in every build (src/internal.c:26006-26009), while the MAC verification failure is guarded by the same macro (src/internal.c:25920-25923). WANT_READ is correctly excluded from the alert, because a partial read is recoverable.

Reachability and Preconditions

  • Build without WOLFSSL_EXTRA_ALERTS for TLS, or any DTLS build.
  • Client or server role. Any remote peer reaches the getData stage with ordinary records, before or after authentication.
  • The hard failure itself depends on the host. The attacker can send records that declare large sizes to drive buffer growth, but whether an allocation fails depends on available memory. The attacker cannot control the outcome deterministically.

Impact

On a read-side resource failure the connection is closed without the fatal alert that RFC 5246 section 7.2.2 expects. The peer and the operator see an abrupt close and no diagnostic. The connection would end with or without the alert, so the attacker gains no availability advantage. The effect is limited to observability and conformance. 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 fatal alert for failures other than WANT_READ outside the #ifdef, as the decrypt stage already does, and to give the DTLS branch the same treatment. A resource failure such as MEMORY_E is better reported as internal_error than as bad_record_mac. The error code returned to the local caller should stay unchanged. Workaround: for TLS, build with WOLFSSL_EXTRA_ALERTS defined, for example with CPPFLAGS=-DWOLFSSL_EXTRA_ALERTS. That does not change the DTLS branch.

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