← ALL ADVISORIES

LOW BYTERAY-2026-0462Disclosed

wolfSSL — Pending Alert Cleared After Failed Flush in SendAlert_ex

SendAlert_ex clears the pending-alert marker after calling SendBuffered without checking the result. When the flush fails with WANT_WRITE on a non-blocking socket, the retry hook finds no pending alert and the fatal alert is never retransmitted, so the peer sees the connection drop without it.

Advisory
BYTERAY-2026-0462
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), all builds; connections on non-blocking sockets whose send path returns WANT_WRITE while an alert is flushed
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

wolfSSL keeps a pending-alert marker, ssl->pendingAlert, so that an alert that could not be written to the network is sent again at the next write opportunity. SendAlert_ex() sets the marker when it starts, builds the alert record and calls SendBuffered() to flush it.

The marker is cleared right after SendBuffered() returns, whatever it returned. On a non-blocking socket whose peer has stopped reading, the flush fails with WANT_WRITE and the marker is gone. The retry hook RetrySendAlert() then has nothing to resend. Nearly all callers ignore the return value of SendAlert(), and a fatal alert also marks the connection closed, which suppresses a later close_notify.

The result is that the same protocol failure produces a fatal alert or a silent drop depending on socket timing. The effect is limited to error signalling on a connection that is already failing. No build option is involved, so default builds are affected.

Affected Products and Versions

  • Component: src/internal.c, SendAlert_ex(), with SendAlert() and RetrySendAlert().
  • Required build: none. The code is present in every TLS build.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default ./configure build is affected when the application uses non-blocking sockets.
  • Other releases were not checked.

Technical Details

The flush and the clear in SendAlert_ex() at src/internal.c:30227-30230:

    ret = SendBuffered(ssl);

    ssl->pendingAlert.code = 0;
    ssl->pendingAlert.level = alert_none;

The sequence for a fatal alert whose flush fails:

  1. SendAlert_ex() stores the alert in ssl->pendingAlert on entry (src/internal.c:30101-30102).
  2. It records the alert in ssl->alert_history.last_tx and, for a fatal alert, sets ssl->options.isClosed = 1 (src/internal.c:30151-30158).
  3. It queues the record and calls SendBuffered() (src/internal.c:30227). On a non-blocking socket this can return WANT_WRITE with the bytes still queued (src/internal.c:12583).
  4. pendingAlert is cleared without a check of ret (src/internal.c:30229-30230) and the error is returned (src/internal.c:30234).
  5. At the next flush opportunity RetrySendAlert() returns at once because pendingAlert.level is alert_none (src/internal.c:30255-30256).
  6. isClosed prevents the shutdown path from sending close_notify (src/ssl_api_rw.c:948).

Two existing safeguards do not cover this path. Early returns before the SendBuffered() call leave the marker set and are retried correctly. The re-store branch in SendAlert() (src/internal.c:30290-30302) runs only when an earlier alert was already pending, so a first-attempt failure leaves no state to recover from.

Reachability and Preconditions

  • No build flag is required.
  • The application uses non-blocking sockets. Before the handshake completes, SendBuffered() may retry internally when auto-retry is enabled, so the clearest case is a fatal alert after the handshake.
  • A fatal alert is being sent. A remote peer can cause one, for example with a record that fails verification or a certificate the endpoint rejects.
  • The send path returns WANT_WRITE at that moment. A remote peer can encourage this by not reading from its socket, but it does not control the timing exactly.
  • No authentication is needed beyond what the triggering failure requires.

Impact

Under send backpressure a fatal alert is lost, and the peer sees the connection end without the alert the protocol requires. Peers and operators cannot rely on the alert to diagnose the failure, and the external behavior for one and the same failure varies with timing. There is no data exposure and no memory-safety effect. The connection is torn down either way.

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 clear pendingAlert only when SendBuffered() succeeded and to leave it set on WANT_WRITE, so that RetrySendAlert() and the existing flush points resend the record. An alternative is to extend the re-store logic in SendAlert() to the first-attempt case. If a partial write is possible, the retry has to resume rather than queue a second copy. The suppression of close_notify should also be reconsidered for the case where the fatal alert was never delivered. There is no configuration workaround. Applications that use blocking sockets are not exposed to the WANT_WRITE path.

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