wolfSSL — Cleartext EGD Entropy Output in RAND_egd Compatibility Debug Code
In builds that define the SHOW_SECRETS debug macro, wolfSSL_RAND_egd prints the entropy bytes it read from an EGD socket to standard output after mixing them into the global DRBG. The bytes are one input to the reseed; they do not by themselves determine the DRBG state.
- Advisory
- BYTERAY-2026-0415
- CWE
- CWE-312
- Vendor
- wolfSSL
- Product
- wolfSSL
- Reported
- 2026-09-28
- Disclosure
- 2026-12-03
- Affected
- wolfSSL 5.9.2 through 5.9.4, OpenSSL compatibility builds with SHOW_SECRETS (set by --enable-keylog-export) whose application calls RAND_egd
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
wolfSSL_RAND_egd() is the OpenSSL compatibility function RAND_egd. An application calls it with the path of an Entropy Gathering Daemon socket. The function reads up to 255 bytes from the daemon and reseeds wolfSSL's global DRBG with them. When the library is compiled with SHOW_SECRETS, it then prints those bytes to standard output as a hex string labelled EGD Entropy =.
Entropy fed to a random number generator should not be written to output that is often captured in logs. That is the defect.
Its effect is limited. The reseed hashes the new bytes together with the generator's existing state, and that state was seeded from the platform entropy source when the global generator was created. A reader of the printed bytes does not learn the state and cannot predict output from them alone. The code also needs a debug macro that wolfSSL warns about, the OpenSSL compatibility layer, and an application that uses the legacy EGD interface. Default builds do not contain it.
Affected Products and Versions
- Component: OpenSSL compatibility layer,
wolfSSL_RAND_egd()insrc/ssl_crypto.c. - Required build:
OPENSSL_EXTRA,SHOW_SECRETS, a Hash-DRBG build with Unix domain sockets (USE_WOLFSSL_IO,HAVE_HASHDRBG,HAVE_SYS_UN_H), not Windows and not FIPS (src/ssl_crypto.c:3842-3847).SHOW_SECRETSis defined by--enable-keylog-export(configure.ac:2661-2671) or by hand. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- The
v5.9.4-stabletag has the same code in the same file. Inv5.9.2-stablethe function, with the same print, is insrc/ssl.c. - Not fixed on master.
- A default
./configurebuild does not include this code. Earlier releases were not checked.
Technical Details
After the read loop, the function reseeds the global generator and then prints the buffer, at src/ssl_crypto.c:3973-3983:
#ifdef SHOW_SECRETS
/* print out entropy found only when no error occurred */
if (ret == WOLFSSL_SUCCESS) {
word32 i;
printf("EGD Entropy = ");
for (i = 0; i < bytes; i++) {
printf("%02X", buf[i]);
}
printf("\n");
}
#endif
The sequence is:
- The request and read loop fills
bufwith up to 255 bytes from the socket (src/ssl_crypto.c:3901-3953). wolfSSL_RAND_Init()makes sure the global generator exists (src/ssl_crypto.c:3957). On first use it callswc_InitRng(), which seeds the DRBG from the platform entropy source (src/ssl_crypto.c:3622-3649).wc_RNG_DRBG_Reseed(&globalRNG, buf, bytes)mixes the bytes in (src/ssl_crypto.c:3966-3970).- The block above prints all
bytesbytes (src/ssl_crypto.c:3973-3983). ForceZero(buf, bytes)clears the buffer (src/ssl_crypto.c:3987), after the print.
What the reseed does with the bytes decides the impact. Hash256_DRBG_Reseed() computes the new state from the old state and the seed together, at wolfcrypt/src/random.c:835-837:
ret = Hash_df(drbg, newV, DRBG_SEED_LEN, drbgReseed,
drbg->V, sizeof(drbg->V), seed, seedSz,
additional, additionalSz);
The SHA-512 variant does the same (wolfcrypt/src/random.c:2022-2024). The printed bytes are seed. drbg->V is not printed.
Reachability and Preconditions
- The library is built as described above, with
SHOW_SECRETS. - The application calls
wolfSSL_RAND_egd()orRAND_egd()with the path of a running EGD socket, and the call succeeds. Nothing in the library calls this function on its own. - The attacker can read the standard output of the process, or wherever the operator stores it.
- No network peer can trigger or influence the print.
Impact
Confirmed from source: each successful call writes the EGD entropy input to standard output in hex.
Also confirmed from source: the bytes alone do not determine the DRBG state, because the reseed input includes the previous state V. A reader would need that state as well to compute the next one. Predicting keys or nonces from the printed bytes would require the initial platform seed to be known or guessable too. That condition was not examined and is not claimed for any platform.
The remaining concern is one of practice: entropy inputs are written to a channel that is commonly logged, in a build an integrator has marked for debugging.
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 fix is to delete the print block, or to print only the number of bytes read. The print has no diagnostic use that the byte count does not serve.
For integrators the workaround is to keep SHOW_SECRETS out of builds that run outside a debugging session. The global generator does not depend on RAND_egd: wc_InitRng() seeds it when it is created.
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.