wolfSSL — Predictable DRBG Seed from the System Clock in Deos Builds
On DDC-I Deos builds, wolfSSL's seed function seeds rand_r() from the system clock and returns its output as the DRBG seed. The clock value can be estimated and rand_r() is deterministic, so the seed, and everything drawn from the DRBG, can be recomputed by searching candidate clock values.
- Advisory
- BYTERAY-2026-0329
- CWE
- CWE-323
- CVSS
- 7.4 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N)
- Vendor
- wolfSSL
- Product
- wolfSSL
- Reported
- 2026-09-27
- Disclosure
- 2026-12-03
- Affected
- wolfSSL 5.9.2 (tested at master commit d95483f), builds with WOLFSSL_DEOS and without CUSTOM_RAND_GENERATE that do not supply their own seed source
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
wolfSSL's random number generator is a Hash_DRBG. It takes its entropy from wc_GenerateSeed(), which has one implementation per platform. The implementation selected by WOLFSSL_DEOS has no entropy source. It reads the system clock with XTIME(0), uses the result as the state of rand_r(), and copies rand_r() output into the seed buffer. It reads the clock again after every eight bytes.
rand_r() is a small deterministic generator whose whole output is fixed by its 32-bit state. The re-reads come from the same clock and add nothing. The DRBG state after initialisation is therefore a function of a clock value an observer can estimate. Someone who sees a value the DRBG produced, such as a TLS hello random or an AES-GCM IV, can search for the clock value that reproduces it and then compute every other value the generator gave out.
The branch carries its own build warning, "potential for not enough entropy, currently being used for testing Deos", but nothing stops it from shipping. Only builds for Deos take it. A default ./configure build does not; it seeds from /dev/urandom.
Affected Products and Versions
- Component:
wolfcrypt/src/random.c,wc_GenerateSeed(), theWOLFSSL_DEOSbranch. - Required build:
WOLFSSL_DEOSdefined andCUSTOM_RAND_GENERATEnot defined (wolfcrypt/src/random.c:8588). - No seed override in place.
CUSTOM_RAND_GENERATE_SEEDandCUSTOM_RAND_GENERATE_SEED_OScome first in the same chain (wolfcrypt/src/random.c:7743,wolfcrypt/src/random.c:7756). - 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 function is at wolfcrypt/src/random.c:8592-8607, directly after the warning at wolfcrypt/src/random.c:8591:
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
{
int i;
int seed = XTIME(0);
(void)os;
for (i = 0; i < sz; i++ ) {
output[i] = rand_r(&seed) % 256;
if ((i % 8) == 7) {
seed = XTIME(0);
rand_r(&seed);
}
}
return 0;
}
On Deos, XTIME is deos_time() (wolfssl/wolfcrypt/wc_port.h:1737-1738). When CURRENT_UNIX_TIMESTAMP is defined, that function returns the system tick count converted to seconds plus that build-time constant (wolfcrypt/src/wc_port.c:4784-4794). In that case the value counts seconds since boot from a fixed offset.
Each block of eight bytes comes from one clock reading. After the first block, blocks produced within the same second are identical. The function always returns 0. How the seed is used:
wc_InitRng()(wolfcrypt/src/random.c:3400) calls_InitRng()(wolfcrypt/src/random.c:2745)._InitRng()requests the seed fromwc_GenerateSeed()(wolfcrypt/src/random.c:3135). WithWC_RNG_SEED_CBthe default callback is the same function (wolfcrypt/src/random.c:390). Reseeding also calls it (wolfcrypt/src/random.c:4685).- The branch above fills the buffer from the clock readings taken during the call (
wolfcrypt/src/random.c:8595-8604). Hash_DRBG_Instantiate()takes that buffer as its entropy input (wolfcrypt/src/random.c:3178).wc_RNG_GenerateBlock()hands out DRBG output (wolfcrypt/src/random.c:5605).- That output reaches the wire: per-message AES-GCM IVs from
wc_AesGcmSetIV()(wolfcrypt/src/aes.c:15126), session ticket IVs fromDefTicketEncCb()(src/internal.c:44924), and TLS handshake randoms. Keys generated on the device come from the same stream.
Reachability and Preconditions
- The library is built with
WOLFSSL_DEOS, withoutCUSTOM_RAND_GENERATE, and uses the stock seed function. - Any integration that calls
wc_InitRng(), or lets the TLS layer do so, seeds its DRBG through this branch. No unusual option or call sequence is involved. - The attacker is a passive observer of TLS or DTLS traffic from the device. No authentication and no interaction with the device are needed.
- The attacker can bound the
XTIME(0)value at seeding time, from boot or session timing. - The attacker observes at least one DRBG-derived value to confirm a candidate, and needs the platform's
rand_r()algorithm.
Impact
On these builds the DRBG seed is determined by the clock value at initialisation. An observer who pins that value recovers the DRBG state and can compute the session keys, GCM IVs, session ticket keys and locally generated keys drawn from it. Predictable per-message IVs also break GCM's integrity guarantee through nonce reuse. The main effect is that secret material on affected builds can be derived from public observations.
ByteRay compiled the unmodified wolfCrypt sources with WOLFSSL_DEOS on a Linux host, with the Deos tick, mutex and heap interfaces replaced by stand-ins. A separate replay of the rand_r() algorithm from the clock reading alone matched the output of wc_GenerateSeed() byte for byte, and a search over 2201 candidate boot ticks through wc_InitRng() and wc_AesGcmSetIV() reproduced the victim's DRBG output and AES-GCM IV, ciphertext and tag.
Behaviour on a Deos target was not measured.
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 wire the Deos port to a real entropy source, a platform TRNG or a vendor entropy interface, and to keep the XTIME(0)/rand_r() loop out of production configurations behind an explicit test-only option. Where no entropy source is available, wc_GenerateSeed() should fail closed with an entropy error so that the DRBG refuses to instantiate. Turning the existing #warning into an #error for non-test builds would enforce this at compile time.
Workaround: define CUSTOM_RAND_GENERATE_SEED to a function that reads a hardware entropy source. That macro takes precedence over this branch. Treat keys generated by a build that used the stock 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.
References
- Deos branch of wc_GenerateSeed at the tested commit
- BYTERAY-2026-0325, the PIC32 branch of the same function
- BYTERAY-2026-0326, the EBSnet RTP branch of the same function
- BYTERAY-2026-0327, the INtime RTOS branch of the same function
- BYTERAY-2026-0328, the Apache Mynewt branch of the same function
- BYTERAY-2026-0330, the Nucleus RTOS branch of the same function