wolfSSL — Predictable DRBG Seed from Clock-Seeded rand() in Dolphin Emulator and Nintendo DS Builds
In builds for the Dolphin emulator and the Nintendo DS, wolfSSL's seed function calls srand(time(NULL)) and returns rand() output as the DRBG seed. The seed, and every random value derived from it, is a function of the wall-clock second at which the generator was initialised. These two targets are not selected by any default build.
- Advisory
- BYTERAY-2026-0425
- CWE
- CWE-323
- CVSS
- 2.6 (CVSS:3.1/AV:A/AC:H/PR:L/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 that define DOLPHIN_EMULATOR or WOLFSSL_NDS and do not supply their own 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
wolfSSL's random number generator is a Hash_DRBG that takes its entropy from wc_GenerateSeed. That function has one implementation per platform. The implementation chosen by DOLPHIN_EMULATOR or WOLFSSL_NDS has no entropy source: it seeds the C library generator from the clock and copies its output.
The clock value is the only unknown, and it has one-second resolution. Someone who knows roughly when the device or program initialised its generator can try each candidate second and reproduce the seed. Everything wolfSSL then draws from the generator, including private keys, nonces and TLS randoms, follows from it. Only builds for these two targets are affected, and neither macro is set by ./configure or by the default settings header. There is no warning at build time.
Affected Products and Versions
- Component:
wolfcrypt/src/random.c,wc_GenerateSeed(), theDOLPHIN_EMULATOR/WOLFSSL_NDSbranch. - Required build:
DOLPHIN_EMULATORorWOLFSSL_NDSdefined, and none of the custom seed macros that are tested earlier in the same chain (wolfcrypt/src/random.c:7743-7769). Both platform macros appear only as commented-out examples in the settings header (wolfssl/wolfcrypt/settings.h:270,wolfssl/wolfcrypt/settings.h:273). The Nintendo DS build instructions in the source tree defineWOLFSSL_NDS. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- The
v5.9.2-stableandv5.9.4-stabletags contain the same branch with no guard. - 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 branch is at wolfcrypt/src/random.c:9534-9544:
#elif defined(DOLPHIN_EMULATOR) || defined (WOLFSSL_NDS)
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
word32 i;
(void)os;
srand(time(NULL));
for (i = 0; i < sz; i++)
output[i] = (byte)rand();
return 0;
}
The generator is re-seeded from the clock on every call, so two calls within the same second return identical bytes. Nothing else is mixed in. How the value is used:
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). Output of a C library generator does not trip it. - The DRBG is instantiated from the seed (
wolfcrypt/src/random.c:3175-3196). Its state is therefore determined by the clock value. - Reseeding calls the same function (
wolfcrypt/src/random.c:4685-4686).
A TLS session creates its generator this way (src/internal.c:8404-8409), and consumers such as the AES-GCM IV generator and the session ticket code draw from it (wolfcrypt/src/aes.c:15126, src/internal.c:44924).
Reachability and Preconditions
- The library is built for one of the two targets with the stock seed function. An integrator who supplies a seed through
CUSTOM_RAND_GENERATE_SEEDor a related macro is not affected. - The attacker needs an estimate of when the generator was initialised. For a TLS connection that is close to the time the connection was made, which an observer of the traffic knows.
- The attacker also needs to know the C library
rand()implementation the target was built with. - No interaction with the device is required beyond observing protocol messages or public keys it produced.
Impact
Confirmed from source: on these builds the DRBG seed is a deterministic function of time(NULL). Values generated from it can be recomputed by anyone who can bound the initialisation time, by trying each second in that window. That covers ephemeral key shares, long-term keys generated on the device, signature nonces and IVs. Two generators initialised within the same second also start from the same state. The rating is Low because of reach, not because of the effect on an affected build: the two targets are a game console and an emulator, and no default configuration selects them. How large the search window is in practice depends on the device clock and was not measured.
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 places a build-time #error in front of this branch unless WOLFSSL_ACCEPT_WEAK_ENTROPY is defined, and adds the configure option --enable-weak-entropy to define it. The srand/rand code itself is unchanged behind that guard. A build for these targets now stops until the integrator provides a seed source or explicitly accepts the weak one. 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: provide a real seed with CUSTOM_RAND_GENERATE_SEED, taking entropy from a hardware or system source, and do not use keys generated by a build that relied on the stock function. After updating, do not define WOLFSSL_ACCEPT_WEAK_ENTROPY in a build that handles real secrets.
The constant test seed used on several other targets is closed by the same commit; see BYTERAY-2026-0426.
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.