← ALL ADVISORIES

HIGH BYTERAY-2026-0333Patched

wolfSSL — Predictable DRBG Seed from the System Clock in VxWorks 6.x Builds

On VxWorks 6.x builds, wolfSSL's seed function takes the current time in seconds as the rand_r() state and returns rand_r() output as the DRBG seed. An observer who can bound the device clock at initialisation can recompute the DRBG state and every value drawn from it.

Advisory
BYTERAY-2026-0333
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 through 5.9.4, builds with WOLFSSL_VXWORKS and WOLFSSL_VXWORKS_6_x that 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. VxWorks has two. The one compiled when WOLFSSL_VXWORKS_6_x is not defined uses the operating system's random number service. The one selected by WOLFSSL_VXWORKS_6_x has no entropy source: it reads the clock through XTIME(0), uses the value as the state of rand_r(), and copies rand_r() output into the seed buffer.

For this port XTIME is the C library time(), so the input is the clock in whole seconds. Nothing else goes into the seed. 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. Key shares, nonces, IVs and keys generated on the device follow from it.

Only VxWorks builds that define WOLFSSL_VXWORKS_6_x take this branch. wolfSSL's VxWorks build notes tell VxWorks 6.x users to define it. The compiler prints a warning that the code is "currently being used for testing", and the build continues. A default ./configure build is not affected.

Affected Products and Versions

  • Component: wolfcrypt/src/random.c, wc_GenerateSeed(), the WOLFSSL_VXWORKS_6_x branch.
  • Required build: WOLFSSL_VXWORKS and WOLFSSL_VXWORKS_6_x defined, and none of the custom seed macros tested earlier in the same chain (wolfcrypt/src/random.c:7743-7769). The settings block for VxWorks sets no seed source (wolfssl/wolfcrypt/settings.h:1438-1451).
  • Not affected: VxWorks builds without WOLFSSL_VXWORKS_6_x. They compile the other branch, which calls the VxWorks randBytes() service and fails when it reports an error (wolfcrypt/src/random.c:8628-8680).
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • The v5.9.2-stable and v5.9.4-stable tags contain the same branch with the warning only.
  • Fixed on master. No wolfSSL release contains the fix.
  • A default ./configure build does not include this code. Earlier releases were not checked.

Technical Details

The branch is at wolfcrypt/src/random.c:8608-8627. After a #warning (wolfcrypt/src/random.c:8611) it defines the seed function, whose body begins:

            int i;
            unsigned int seed = (unsigned int)XTIME(0);
            (void)os;

            for (i = 0; i < sz; i++ ) {
                output[i] = rand_r(&seed) % 256;
                if ((i % 8) == 7) {
                    seed = (unsigned int)XTIME(0);
                    rand_r(&seed);
                }
            }

XTIME has no VxWorks-specific definition. It falls through to the default, time() (wolfssl/wolfcrypt/wc_port.h:1931-1936), unless the integrator overrides the time macros. The first eight bytes are the first eight rand_r() outputs for the clock value. After every eighth byte the state is reset from the clock and one output is discarded, so each later block is outputs two to nine for the clock value at that moment. While the second has not changed, those later blocks are identical. The function then returns 0; it has no failure path.

How the seed is used:

  1. wc_InitRng() and wc_InitRng_ex() call the common initialiser with no nonce and no personalization string (wolfcrypt/src/random.c:3400-3411).
  2. The initialiser requests the seed from wc_GenerateSeed() (wolfcrypt/src/random.c:3135); 36 bytes in a default non-FIPS SHA-256 build (wolfcrypt/src/random.c:2755).
  3. The seed health test fails only when one byte value repeats 31 times in a row or fills 325 places of a 512-byte window (wolfcrypt/src/random.c:2506, wolfcrypt/src/random.c:2522, called at wolfcrypt/src/random.c:3159). Repeated eight-byte blocks of rand_r() output pass it.
  4. The DRBG is instantiated from the seed (wolfcrypt/src/random.c:3178-3184).
  5. 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 sends DRBG output in the clear as the hello random (src/internal.c:34895).

Reachability and Preconditions

  • The library is built with WOLFSSL_VXWORKS and WOLFSSL_VXWORKS_6_x and uses the stock seed function. A build that defines CUSTOM_RAND_GENERATE_SEED, CUSTOM_RAND_GENERATE_SEED_OS or CUSTOM_RAND_GENERATE does not reach this code.
  • The attacker observes at least one value derived from the DRBG. A passive observer of a TLS handshake gets the hello random. No authentication and no interaction with the device are needed.
  • The attacker can bound the value time() returned on the device when the generator was initialised. For a per-connection generator that is close to the time of the connection, if the device clock is set.
  • The attacker needs the rand_r() implementation of the C library the image was linked with.

Impact

Confirmed from source: on these builds the DRBG seed is a function of the clock in seconds and of nothing else. Every value drawn from the generator follows from the seed: ephemeral key shares, signature nonces, AES-GCM IVs, session ticket IVs and long-term keys generated on the device. Two generators initialised within the same second start from the same state.

ByteRay compiled the unmodified wolfCrypt sources with WOLFSSL_VXWORKS and WOLFSSL_VXWORKS_6_x on a Linux host, with the VxWorks semaphore calls and time() replaced by stand-ins. The seed matched an independent replay of rand_r() from the clock value byte for byte, and trying 2201 candidate clock values through wc_InitRng() reproduced the first process's DRBG output, AES-GCM IV and tag. A search window that did not contain the value found nothing, and a control build seeded from the host's /dev/urandom did not repeat.

Not verified: behaviour on a VxWorks 6.x target, including what time() returns there before the clock is set, and the rand_r() of the VxWorks C library. The size of the search in a deployment depends on how well the device clock is known and was not measured.

Remediation and Mitigation

Fixed on master by commit 09c1648ad4502e7974cef18d47d14367b85d579c, part of PR 12065, merged 2026-11-10. The commit puts a build-time #error in front of this branch unless WOLFSSL_ACCEPT_WEAK_ENTROPY is defined, and adds the configure option --enable-weak-entropy, which defines that macro. The rand_r() code is unchanged behind the guard. A VxWorks 6.x build on master therefore 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.

For affected releases, define CUSTOM_RAND_GENERATE_SEED to a function backed by a hardware random number generator or another entropy source available to the board support package. Treat keys generated by a build that used the stock function as exposed and replace them. After updating, do not define WOLFSSL_ACCEPT_WEAK_ENTROPY in a build that handles real secrets.

Timeline

  • 2026-09-27 — Reported to wolfSSL.
  • 2026-11-09 — wolfSSL opened PR 12065.
  • 2026-11-10 — PR 12065 merged to master.
  • 2026-12-03 — Public disclosure.

Credits

Discovered and reported by Mehrun P. Hunter and Shahriyar Jalayeri of ByteRay Ltd.

References