← ALL ADVISORIES

LOW BYTERAY-2026-0412Disclosed

wolfSSL — Cleartext Master and Resumption Secret Output in Sniffer Debug Code

In sniffer builds that define the SHOW_SECRETS debug macro, the sniffer prints the master secret of both sides of each decoded session, and the TLS 1.3 resumption secret, to standard output in hex. A reader of the captured output can decrypt those sessions.

Advisory
BYTERAY-2026-0412
CWE
CWE-312
Vendor
wolfSSL
Product
wolfSSL
Reported
2026-09-28
Disclosure
2026-12-03
Affected
wolfSSL 5.9.2 through 5.9.4, builds with --enable-sniffer and SHOW_SECRETS (set by --enable-keylog-export)
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

The wolfSSL sniffer keeps two session objects for each watched connection, one for the server side and one for the client side, and derives the same secrets in both. When the library is compiled with SHOW_SECRETS, the helper ShowTlsSecrets() in src/sniffer.c prints the master secret of both objects to standard output as hex. For TLS 1.3 the sniffer also prints the resumption master secret it derives when the client Finished message is seen.

A master secret and a capture of the connection are enough to derive the record keys and decrypt the traffic. A sniffer usually runs with its output redirected to a file, and in that setup the secrets are stored in that file in the clear.

SHOW_SECRETS is a debug macro. It is defined only by --enable-keylog-export or by hand, and wolfSSL warns at configure time and at compile time that it is not for production. The sniffer is opt-in as well. Default builds contain none of this code. The pre-master secret print in the same file is described in BYTERAY-2026-0411.

Affected Products and Versions

  • Component: wolfSSL sniffer, ShowTlsSecrets() and PrintSecret() in src/sniffer.c, and their callers SetupKeys() and ProcessFinished().
  • Required build: WOLFSSL_SNIFFER (--enable-sniffer) and SHOW_SECRETS. The resumption secret print also needs WOLFSSL_TLS13 and HAVE_SESSION_TICKET.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • The v5.9.2-stable and v5.9.4-stable tags contain the same helpers and the same three call sites.
  • Not fixed on master.
  • A default ./configure build does not include this code. Earlier releases were not checked.

Technical Details

PrintSecret() at src/sniffer.c:2488-2496 writes a label and then each byte of the buffer with printf("%02x", buf[i]). ShowTlsSecrets() follows it at src/sniffer.c:2498-2504:

static void ShowTlsSecrets(SnifferSession* session)
{
    PrintSecret("server master secret", session->sslServer->arrays->masterSecret, SECRET_LEN);
    PrintSecret("client master secret", session->sslClient->arrays->masterSecret, SECRET_LEN);
    printf("server suite = %d\n", session->sslServer->options.cipherSuite);
    printf("client suite = %d\n", session->sslClient->options.cipherSuite);
}

SECRET_LEN is 48. Both helpers are compiled only under #ifdef SHOW_SECRETS. The secrets reach standard output from three places:

  1. TLS 1.2 and earlier: SetupKeys() calls MakeMasterSecret() for both session objects (src/sniffer.c:3428-3429) and then ShowTlsSecrets() (src/sniffer.c:3447-3454).
  2. TLS 1.3: ProcessFinished() calls DeriveMasterSecret() for both objects when the first Finished message is seen and then ShowTlsSecrets() (src/sniffer.c:4865-4867). Here arrays->masterSecret holds the TLS 1.3 master secret, from which the application traffic secrets are derived.
  3. TLS 1.3 with session tickets: on the client Finished, ProcessFinished() derives the resumption master secret into session->sslClient->session->masterSecret (src/sniffer.c:4877-4878) and prints it:
            #ifdef SHOW_SECRETS
            PrintSecret("resumption secret",
                session->sslClient->session->masterSecret, SECRET_LEN);
            #endif

That block is at src/sniffer.c:4883-4886. None of the three sites hashes or truncates the value.

SHOW_SECRETS has one configure-level source, --enable-keylog-export (configure.ac:2661-2671), which prints "Keylog export enabled -- Sensitive key data will be stored insecurely." A build that defines the macro by hand gets a compile-time warning from src/tls.c:195-202.

Reachability and Preconditions

  • The library is built with the sniffer and with SHOW_SECRETS.
  • The sniffer application has been given the keys it needs to decode the watched sessions. Every session it decodes is printed; the watched peers do nothing unusual.
  • The attacker can read the standard output of the sniffer process, or the file the operator redirects it to. The library writes to stdout only.
  • To use a master secret the attacker needs the corresponding traffic capture. To use a resumption secret the attacker also needs the session ticket and its nonce, which the server sends inside the encrypted connection.

Impact

Confirmed from source: on an affected build the sniffer prints the master secret of each session it decodes, twice, and for TLS 1.3 sessions with tickets the resumption master secret. With a master secret and the capture, the session can be decrypted. A resumption master secret is the input from which the pre-shared key of a later resumed session is derived.

The sniffer process already holds the keys from which these secrets follow, so the print discloses nothing to the operator. It matters when captured output is readable by someone who cannot read those keys. Whether that is the case depends on the deployment and was not examined.

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

Remediation and Mitigation

Not fixed on wolfSSL master as of commit e4b0841b32e7 (2026-12-03).

The direct fix is to remove the secret arguments from ShowTlsSecrets() and the resumption secret print, keeping the cipher suite lines if they are useful. If the values are needed for debugging, a length or a digest serves to compare the two sides without disclosing the key.

For integrators the workaround is to keep SHOW_SECRETS out of sniffer builds that process real traffic. If such a build has run with its output captured, treat the captured output as key material for the sessions it covered.

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