wolfSSL — Cleartext Pre-Master and Master Secret Output in SSL 3.0 Key Derivation Debug Code
In builds that define the SHOW_SECRETS debug macro and enable SSL 3.0, the SSL 3.0 master secret derivation prints the pre-master secret and the master secret to standard output in hex. Anyone who can read the captured output can decrypt those sessions.
- Advisory
- BYTERAY-2026-0410
- 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 SHOW_SECRETS (set by --enable-keylog-export) and SSL 3.0 (--enable-sslv3)
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
MakeSslMasterSecret() in src/keys.c derives the master secret for SSL 3.0 connections. When the library is compiled with SHOW_SECRETS, the function prints the pre-master secret before the derivation and the 48-byte master secret after it, each as a hex string on standard output.
The master secret, together with a capture of the handshake, is enough to derive the record keys of that connection. If the process output is redirected to a log file, a journal or a container log collector, the secrets are stored there in the clear, and a reader of that log can decrypt the recorded sessions.
This is debug output behind two opt-in switches. SHOW_SECRETS 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 function runs only for SSL 3.0, which is disabled by default. Default builds contain none of this code. TLS 1.0 to 1.2 connections in the same build use a different function; see BYTERAY-2026-0414.
Affected Products and Versions
- Component: SSL 3.0 key derivation,
MakeSslMasterSecret()insrc/keys.c. - Required build:
SHOW_SECRETSdefined,NO_OLD_TLSnot defined, and SSL 3.0 enabled (WOLFSSL_ALLOW_SSLV3). With./configurethat is--enable-keylog-export --enable-sslv3. The CMake optionWOLFSSL_KEYLOG_EXPORTdefines the same macros (CMakeLists.txt:4420-4430). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- The
v5.9.2-stableandv5.9.4-stabletags contain the same two print blocks in the same function. - Not fixed on master.
- A default
./configurebuild does not include this code. Earlier releases were not checked.
Technical Details
The first block runs on entry, at src/keys.c:4120-4128:
#ifdef SHOW_SECRETS
{
word32 j;
printf("pre master secret: ");
for (j = 0; j < pmsSz; j++)
printf("%02x", ssl->arrays->preMasterSecret[j]);
printf("\n");
}
#endif
The second block runs after the MD5 and SHA-1 rounds have filled ssl->arrays->masterSecret, at src/keys.c:4204-4212. It prints SECRET_LEN (48) bytes with the label master secret:. Neither block hashes or truncates the value.
The function is reached as follows.
MakeMasterSecret()is the common entry point for TLS 1.2 and earlier. It is called fromSendClientKeyExchange()(src/internal.c:38162), fromDoClientKeyExchange()(src/internal.c:46211) and from the sniffer (src/sniffer.c:3428-3429).- At
src/keys.c:4256-4258it callsMakeTlsMasterSecret()whenssl->options.tlsis set andMakeSslMasterSecret()otherwise. The flag is set for every version from TLS 1.0 up (src/keys.c:68-71), so only SSL 3.0 takes the second branch. MakeSslMasterSecret()is compiled only whenNO_OLD_TLSis not defined (src/keys.c:3968-4237).
SHOW_SECRETS has one configure-level source, --enable-keylog-export (configure.ac:2661-2671). That switch prints "Keylog export enabled -- Sensitive key data will be stored insecurely." and also defines WOLFSSL_KEYLOG_EXPORT_WARNED, which silences the compile-time warning at src/tls.c:195-202. A build that defines SHOW_SECRETS by hand gets that compile-time warning.
Reachability and Preconditions
- The library is built with
SHOW_SECRETSand with SSL 3.0 enabled. SSL 3.0 is off by default and--enable-alldoes not turn it on (configure.ac:6240-6260). - A connection negotiates SSL 3.0. A peer can cause that only if the application permits SSL 3.0 at run time.
- The attacker can read the standard output of the process, or wherever the operator stores it. The library writes to
stdoutonly; it does not create a file here. - To decrypt traffic the attacker also needs a capture of the corresponding connection.
- No authentication or user interaction is involved beyond the above.
Impact
Confirmed from source: on an affected build every SSL 3.0 handshake writes its pre-master secret and master secret to standard output in hex. With either value and a capture of the handshake, the session keys can be recomputed and the connection decrypted.
The practical exposure depends on the deployment. If standard output goes to a terminal, the secrets are transient. If it is captured to persistent logs, the secrets persist with the permissions of those logs. That part depends on the operator's setup 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 two print blocks, or to print only a length or a digest of each secret. If raw output is kept for debugging, it should require a run-time opt-in in addition to the macro.
For integrators the workaround is to keep SHOW_SECRETS out of any build that handles real traffic. Check the generated options.h or user_settings.h for SHOW_SECRETS and for --enable-keylog-export in the configure line. Disabling SSL 3.0 also removes this path and has no cost for modern peers. If such a build has run with its output captured, treat the captured logs as containing session keys.
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
- Pre-master secret print in MakeSslMasterSecret at the tested commit
- Master secret print in MakeSslMasterSecret
- Dispatch between the TLS and SSL 3.0 derivations
- The keylog export configure switch
- BYTERAY-2026-0414, the TLS 1.0 to 1.2 master secret in the same build
- BYTERAY-2026-0411, the sniffer pre-master secret print
- CWE-312: Cleartext Storage of Sensitive Information