wolfSSL — Constant DRBG Seed from Test Stub Selected by Platform Macros and WOLFSSL_GENSEED_FORTEST
wolfSSL contains a test seed function that returns the bytes 0, 1, 2 and so on. It is selected by WOLFSSL_GENSEED_FORTEST and also, with only a compiler warning, by a group of platform macros that have no entropy source of their own. A build that ships with it starts every random number generator from the same state. Default builds are not affected.
- Advisory
- BYTERAY-2026-0426
- CWE
- CWE-323
- CVSS
- 3.7 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N)
- Vendor
- wolfSSL
- Product
- wolfSSL
- Reported
- 2026-09-28
- Disclosure
- 2026-12-03
- Affected
- wolfSSL 5.9.2 through 5.9.4, builds where wc_GenerateSeed resolves to the test stub (WOLFSSL_GENSEED_FORTEST or one of several platform macros, with no custom seed source)
- Fixed in
- Master commit 09c1648ad4502e7974cef18d47d14367b85d579c (PR 12065, merged 2026-11-10). Not in a wolfSSL stable release as of 2026-12-03.
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
wc_GenerateSeed supplies the entropy for wolfSSL's Hash_DRBG. For platforms without a known entropy source, the library falls back to a stub meant for bring-up and testing. The stub writes an incrementing byte pattern and reports success.
The stub is documented as test-only when it is chosen through WOLFSSL_GENSEED_FORTEST. It is also chosen automatically for thirteen platform and toolchain macros, among them WOLFSSL_MDK_ARM, WOLFSSL_IAR_ARM and NO_STM32_RNG, and for Freescale builds where no hardware generator matched. In all cases the only signal is a compiler warning, and the build succeeds. A product built this way has no secret randomness. The generator produces the same output sequence on every device and every boot, and anyone with the library source can compute it. Whether a given product is affected depends entirely on its build configuration; a default ./configure build is not.
Affected Products and Versions
- Component:
wolfcrypt/src/random.c, theUSE_TEST_GENSEEDimplementation ofwc_GenerateSeed(). - Required build: no earlier seed source in the platform chain matches, and one of the macros at
wolfcrypt/src/random.c:9611-9617is defined, or the Freescale fallback atwolfcrypt/src/random.c:8162-8169applies. A custom seed macro such asCUSTOM_RAND_GENERATE_SEEDis tested first and prevents the stub (wolfcrypt/src/random.c:7743-7769). - Several example configurations in the source tree define
WOLFSSL_GENSEED_FORTEST, for instanceRTOS/nuttx/wolfssl/user_settings.h:36,IDE/MDK5-ARM/Conf/user_settings.h:366andIDE/IAR-EWARM/Projects/user_settings.h:17. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- The
v5.9.2-stableandv5.9.4-stabletags contain the same stub and the same selection. - Fixed on master. No wolfSSL release contains the fix.
- A default
./configurebuild does not include this code. Earlier releases were not checked.
Technical Details
The stub is at wolfcrypt/src/random.c:9916-9934. Its body, with one comment left out:
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
word32 i;
for (i = 0; i < sz; i++ )
output[i] = WC_OCTET(i);
(void)os;
return 0;
}
It is preceded by #warning "write a real random seed!!!!, just for testing now" (wolfcrypt/src/random.c:9917-9921). The warning does not stop the build. How the value is used:
- The platform chain defines
USE_TEST_GENSEEDfor the listed macros (wolfcrypt/src/random.c:9611-9623). wc_InitRng()andwc_InitRng_ex()call the common initialiser with no nonce and no personalization string (wolfcrypt/src/random.c:3400-3411).- The initialiser obtains the seed from
wc_GenerateSeed()(wolfcrypt/src/random.c:3135). - The seed passes a health test that looks for repeated and over-frequent byte values (
wolfcrypt/src/random.c:2525,wolfcrypt/src/random.c:3159). An incrementing pattern has neither. - The DRBG is instantiated from the seed (
wolfcrypt/src/random.c:3175-3196). Reseeding returns the same bytes (wolfcrypt/src/random.c:4685-4686).
The option is described in the file header as default off and "not for production use" (wolfcrypt/src/random.c:47-48). That text covers WOLFSSL_GENSEED_FORTEST only. For the platform macros there is a source comment saying that the integrator must supply a seed function (wolfcrypt/src/random.c:9619-9621).
Reachability and Preconditions
- The shipped binary was built with the stub. This happens when an integrator starts from an example configuration that defines
WOLFSSL_GENSEED_FORTEST, or targets one of the listed platforms without wiring up an entropy source, and does not act on the warning. - No access to the device is needed. The seed is the same constant everywhere, so generator output can be computed offline.
- An integrator who defines
CUSTOM_RAND_GENERATE_SEEDor a related macro, or whose platform has a hardware source earlier in the chain, is not affected.
Impact
Confirmed from source: on a build that uses the stub, the DRBG starts from a fixed, public state, because the standard initialisation path adds no nonce. Private keys generated on the device, ephemeral key shares, signature nonces and IVs are all predictable. This is a configuration-dependent defect. The option that names the stub is documented as test-only and the compiler does warn. The rating is Low because an integrator has to ship a build that printed that warning; on a build that did, the loss of confidentiality is complete.
ByteRay did not build a proof of concept for this issue. The analysis is from source review.
Remediation and Mitigation
Fixed on master by commit 09c1648ad4502e7974cef18d47d14367b85d579c, part of PR 12065, merged 2026-11-10. The commit turns the warning into a build-time #error unless WOLFSSL_ACCEPT_WEAK_ENTROPY is defined, and adds the configure option --enable-weak-entropy to define it. A later commit in the same pull request, 6cf0385bd5dd682979196caf90a8d46146cb59a8, skips the stub when a custom generator macro is defined. The stub body is unchanged behind the guard. The fix is on master only. No wolfSSL release contains it as of 2026-12-03; the newest release tag, v5.9.4-stable, does not.
For affected releases: treat the "write a real random seed" warning as an error, provide a seed with CUSTOM_RAND_GENERATE_SEED or enable the platform's hardware generator, and replace keys generated by a build that used the stub. After updating, do not define WOLFSSL_ACCEPT_WEAK_ENTROPY in a build that handles real secrets.
The clock-seeded fallback for two other targets is closed by the same commit; see BYTERAY-2026-0425.
Timeline
- 2026-09-28 — Reported to wolfSSL.
- 2026-11-09 — Pull request 12065 opened upstream.
- 2026-11-10 — Pull request 12065 merged to master.
- 2026-12-03 — Public disclosure.
Credits
Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.