← ALL ADVISORIES

LOW BYTERAY-2026-0420Patched

wolfSSL — Stale TLS 1.3 PSK Flag After wolfSSL_clear on Reused Client Objects

A TLS 1.3 client records that the server selected a pre-shared key in a flag that wolfSSL_clear does not reset. After a PSK or resumption handshake, a client object that is cleared and reused rejects the next full certificate handshake with a message-ordering error. The stale flag does not let a server skip authentication.

Advisory
BYTERAY-2026-0420
CWE
CWE-1271
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 through 5.9.4, TLS 1.3 clients built with session tickets or PSK that reuse a WOLFSSL object through wolfSSL_clear
Fixed in
Master commit 0ad347ec2a941a0682ed8405630676edc09e423a (PR 11600, merged 2026-10-29). Not in a wolfSSL stable release as of 2026-12-03.
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

When a TLS 1.3 server selects a pre-shared key, whether an external PSK or a session ticket, the wolfSSL client sets ssl->options.pskNegotiated. The handshake message checks use that flag to decide which server messages are allowed: with a PSK, the server must not send a certificate request or a CertificateVerify.

wolfSSL_clear() prepares a WOLFSSL object for another connection. It resets the other per-handshake authentication flags but not this one, and the ServerHello code never clears the flag when the server selects no PSK. A client that completed a PSK handshake, called wolfSSL_clear(), and then connects to a server that performs a full certificate handshake treats the server's CertificateVerify as a protocol violation and aborts.

The effect is a failed handshake on a reused object, each time the server does not resume. Server authentication is not weakened. Default builds are not affected: the flag exists only when session tickets or PSK are compiled in, and both are off by default.

Affected Products and Versions

  • Component: TLS 1.3 client handshake in src/tls13.c (DoTls13ServerHello(), SanityCheckTls13MsgReceived()) and wolfSSL_clear() in src/ssl.c.
  • Required build: TLS 1.3 with HAVE_SESSION_TICKET (--enable-session-ticket, configure.ac:9468-9483) or PSK support (--enable-psk, configure.ac:6164-6169).
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • The v5.9.2-stable and v5.9.4-stable tags contain the same code.
  • Fixed on master by commit 0ad347ec2a941a0682ed8405630676edc09e423a (PR 11600). No release contains the fix.
  • A default ./configure build enables neither option and is not affected. Earlier releases were not checked.

Technical Details

The flag is a bit in the connection options (wolfssl/internal.h:5612). On the client it is written in one place, when the ServerHello selects one of the offered PSKs (src/tls13.c:6261-6263):

            if ((ret = SetupPskKey(ssl, psk, 0)) != 0)
                return ret;
            ssl->options.pskNegotiated = 1;

The branch for a ServerHello without a selected PSK resets other resumption state and leaves the flag alone (src/tls13.c:6234-6236):

            ssl->options.resuming = 0;
            ssl->arrays->psk_keySz = 0;
            XMEMSET(ssl->arrays->psk_key, 0, MAX_PSK_KEY_LEN);

wolfSSL_clear() (src/ssl.c:5774) resets the neighbouring flags (src/ssl.c:5825-5827) and has no assignment to pskNegotiated:

        ssl->options.havePeerVerify = 0;
        ssl->options.havePeerCert = 0;
        ssl->options.peerAuthGood = 0;

The sequence on a reused client object is:

  1. The first handshake uses a PSK or a session ticket. pskNegotiated becomes 1.
  2. The application calls wolfSSL_clear() and connects again. The flag is still 1.
  3. The server does not select a PSK, for example because the ticket has expired or the server no longer has the ticket key, and sends Certificate and CertificateVerify.
  4. SanityCheckTls13MsgReceived() rejects CertificateVerify with SANITY_MSG_E because the flag is set (src/tls13.c:15297-15305). If the server asks for a client certificate, the CertificateRequest is rejected first (src/tls13.c:15252-15260).
  5. The connection attempt fails. Clearing the object again does not help. The flag stays set for the life of the object, so only handshakes in which the server selects a PSK succeed.

The stale flag also disables the check that a non-PSK ServerHello carries a key share (src/tls13.c:6271-6278) and makes the Finished ordering check accept a flight without a certificate (src/tls13.c:15355-15376). This does not lead to an unauthenticated connection. On the client peerAuthGood is set only when a PSK is actually selected (src/tls13.c:4417-4420, src/tls13.c:4558-4570) or a CertificateVerify has been verified. wolfSSL_clear() does reset it, and wolfSSL_connect_TLSv13() stops before sending the client Finished when it is not set (src/tls13.c:16735-16739).

The server side is not affected. DoTls13ClientHello() recomputes the flag for every ClientHello (src/tls13.c:8532).

Reachability and Preconditions

  • The client is built with TLS 1.3 and session tickets or PSK.
  • The application reuses a WOLFSSL object with wolfSSL_clear() instead of creating a new one for each connection.
  • An earlier handshake on that object used a PSK or resumed a session.
  • The next server selects no PSK and authenticates with a certificate. A server operator, or anything that causes resumption to be declined, controls this. A network attacker without the server's keys cannot make an honest server decline in a way the client accepts.
  • No user interaction is needed.

Impact

A reused client object fails its next full handshake and keeps failing for as long as the server declines resumption. For a client that always reuses one object, for example a long-running device agent, this is a loss of connectivity to that server until the object is recreated. There is no memory corruption and no authentication bypass.

ByteRay did not build a proof of concept for this issue. The analysis is from source review.

Remediation and Mitigation

Fixed on wolfSSL master by commit 0ad347ec2a941a0682ed8405630676edc09e423a, merged in PR 11600. The commit adds the reset of pskNegotiated, together with the PSK and anonymous cipher suite flags, to wolfSSL_clear(); the pull request also changes other resumption and client authentication handling. The fix is on master only; no release contains it as of 2026-12-03.

Until a release is available, applications can free the WOLFSSL object and create a new one with wolfSSL_new() instead of calling wolfSSL_clear(), at the cost of the allocation and setup that reuse was meant to save.

Timeline

  • 2026-09-28 — Reported to wolfSSL.
  • 2026-09-29 — wolfSSL opened PR 11600.
  • 2026-10-29 — PR 11600 merged to master.
  • 2026-12-03 — Public disclosure.

Credits

Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.

References