wolfSSL — Predictable DRBG Seed from time() and rand() in the STARCORE Project Seed Callback
The settings file shipped with wolfSSL's NXP StarCore project selects my_rng_generate_seed() as the DRBG seed source. That function seeds rand() with the clock in seconds and returns rand() output, so an observer who can bound the device clock can recompute the DRBG state and every value drawn from it.
- Advisory
- BYTERAY-2026-0335
- CWE
- CWE-337
- CVSS
- 8.1 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H)
- Vendor
- wolfSSL
- Product
- wolfSSL
- Reported
- 2026-09-27
- Disclosure
- 2026-12-03
- Affected
- wolfSSL 5.9.2 (tested at master commit d95483f), builds that use the in-tree IDE/STARCORE project and its user_settings.h
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
wolfSSL's random number generator is a Hash_DRBG that takes its entropy from wc_GenerateSeed(). A port can replace the platform seed source by defining CUSTOM_RAND_GENERATE_SEED to a function of its own. The NXP StarCore DSP project in IDE/STARCORE does this in its shipped user_settings.h, and the function it names is my_rng_generate_seed() in IDE/STARCORE/starcore_test.c.
That function collects no entropy. It reads the clock with time(), passes the value to srand(), and fills the seed buffer from rand(). The seed is determined by one value with a resolution of one second. Someone who sees a value the DRBG produced, such as a TLS hello random, and can bound the device clock at the moment the generator was initialised, can try each candidate second and recompute the generator state.
The definition sits in an unconditional #if 1 block, so every build that consumes this settings file uses the function as its only seed source. A default ./configure build does not use the StarCore project and is not affected.
Affected Products and Versions
- Component: wolfCrypt, the NXP StarCore IDE port:
my_rng_generate_seed()inIDE/STARCORE/starcore_test.c, selected byIDE/STARCORE/user_settings.h. - Required build: the in-tree
IDE/STARCOREproject with its shippeduser_settings.h. No further flag is needed, and the configuration offers no other seed source. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild does not include this code. - Other releases were not checked.
Technical Details
The settings file wires the function in (IDE/STARCORE/user_settings.h:471-475). Inside an #if 1 block it declares my_rng_generate_seed() and defines CUSTOM_RAND_GENERATE_SEED to it. The function itself is at IDE/STARCORE/starcore_test.c:68-79:
int my_rng_generate_seed(unsigned char* output, int sz)
{
unsigned int i;
long t;
time(&t); /* init */
srand(t); /* init */
for (i = 0; i < sz; i++) {
output[i] = (unsigned char) rand();
}
return 0;
}
It always returns 0. The file name suggests a test helper, but the shipped settings select it without a condition, so the name does not keep it out of a product build.
How the seed is used:
wc_InitRng()calls the common initialiser (wolfcrypt/src/random.c:3400). The port's ownsimpleRngTest()takes this path (IDE/STARCORE/starcore_test.c:82-100).- The initialiser requests the seed from
wc_GenerateSeed()(wolfcrypt/src/random.c:3135). - With
CUSTOM_RAND_GENERATE_SEEDdefined,wc_GenerateSeed()is a wrapper that forwards to the named function (wolfcrypt/src/random.c:7750-7754). my_rng_generate_seed()fills the buffer from clock-keyedrand()output.- The Hash_DRBG is instantiated from that seed (
wolfcrypt/src/random.c:3178). Reseeding goes through the same hook (wolfcrypt/src/random.c:4685-4686). - A TLS endpoint sends DRBG output in the clear as the hello random: the client random (
src/internal.c:34895) and the server random, in TLS 1.3 atsrc/tls13.c:8762.
Reachability and Preconditions
- The firmware is built from the
IDE/STARCOREconfiguration with the shippeduser_settings.h, and the integrator has not replaced the seed function. - The attacker observes at least one value derived from the DRBG. A passive observer of one TLS handshake gets the hello random. No authentication and no active position are needed.
- The attacker can bound the value
time()returned on the device when the generator was initialised, for example from capture timestamps. - The attacker needs the
rand()implementation of the C library the image was linked with.
Impact
On these builds the DRBG seed is a function of the clock in seconds and of nothing else. An observer who validates seed guesses offline against one recorded handshake recovers the DRBG state, and with it session keys, IVs, nonces and any ECDHE or ECDSA ephemeral values drawn from the same generator. That breaks the confidentiality of recorded and later sessions and allows the endpoint to be impersonated.
StarCore DSPs are used in baseband, telecom and industrial signal-processing equipment. An integrator who starts from the shipped project inherits this seed source without a warning.
ByteRay did not build a proof of concept for this issue. The analysis is from source review.
Remediation and Mitigation
ByteRay has not confirmed a fixed wolfSSL release for this issue as of 2026-12-03, and has not checked it against wolfSSL changes made after the tested commit.
The fix direction is to back the seed function with the target's hardware random number generator, or with a hash-conditioned pool of asynchronous hardware inputs, and to return an error when not enough entropy is available so that wc_InitRng() fails. The test helper should also be moved or guarded so that the shipped user_settings.h cannot select a srand(time()) function as a product seed source.
Workaround for affected builds: change the CUSTOM_RAND_GENERATE_SEED definition in the project's user_settings.h to a function backed by a hardware entropy source. Treat keys generated by a build that used the shipped function as exposed and replace them.
Timeline
- 2026-09-27 — Reported to wolfSSL.
- 2026-12-03 — Public disclosure.
Credits
Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.