← ALL ADVISORIES

HIGH BYTERAY-2026-0334Disclosed

wolfSSL — Predictable DRBG Seed from time() and rand() in Dolphin Emulator and Nintendo DS Builds

On builds that define DOLPHIN_EMULATOR or WOLFSSL_NDS, wc_GenerateSeed() calls srand(time(NULL)) and fills the DRBG seed from rand(). The seed is a function of the clock in whole seconds, so an observer who can bound that clock can recompute the DRBG state and every value drawn from it.

Advisory
BYTERAY-2026-0334
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 with DOLPHIN_EMULATOR or WOLFSSL_NDS 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 that takes its entropy from wc_GenerateSeed(). That function has one implementation per platform. The one compiled for the Dolphin emulator target (DOLPHIN_EMULATOR) and the Nintendo DS target (WOLFSSL_NDS) has no entropy source. It seeds the C library generator with time(NULL) and copies rand() output into the seed buffer.

Nothing else goes into the seed, so it 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 clock at the moment the generator was initialised, can try each candidate second and recompute the generator state. Session keys, nonces, IVs and ephemeral keys generated on the device follow from it.

Only builds that define one of these two macros take this branch. They are emulator and homebrew console targets. A default ./configure build is not affected.

Affected Products and Versions

  • Component: wolfCrypt, wolfcrypt/src/random.c, wc_GenerateSeed(), the DOLPHIN_EMULATOR / WOLFSSL_NDS branch.
  • Required build: DOLPHIN_EMULATOR or WOLFSSL_NDS defined, and no seed override (CUSTOM_RAND_GENERATE_SEED, CUSTOM_RAND_GENERATE_SEED_OS or a seed callback).
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default ./configure build does not include this code. All other platforms compile a different branch.
  • Other 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;
        }

srand() is called once with the clock in seconds (wolfcrypt/src/random.c:9540). Every seed byte is the low byte of the next rand() output (wolfcrypt/src/random.c:9541-9542). The function returns 0 in all cases. There is no compile-time warning, no second input and no failure path.

How the seed is used:

  1. wc_InitRng() calls the common initialiser (wolfcrypt/src/random.c:3400), directly from the application or from the TLS layer when it sets up a session.
  2. The initialiser requests the seed from wc_GenerateSeed() (wolfcrypt/src/random.c:3135).
  3. The branch above fills the buffer from rand().
  4. The Hash_DRBG is instantiated from that seed (wolfcrypt/src/random.c:3178).
  5. Reseeding calls the same function (wolfcrypt/src/random.c:4685-4686), so a reseed adds nothing an observer cannot also compute.
  6. 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 at src/tls13.c:8762.

An observer replays the same steps for each candidate second: srand(t), the rand() fill, the DRBG instantiation, and one generate call. The candidate whose output equals the captured hello random is the seed.

Reachability and Preconditions

  • The library is built with DOLPHIN_EMULATOR or WOLFSSL_NDS and uses the stock 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(NULL) returned when the generator was initialised. Packet capture timestamps are enough when the device clock is set.
  • 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. A match against one recorded handshake gives the DRBG state, and with it session keys, IVs, nonces and any ECDHE or ECDSA ephemeral values drawn from the same generator. Two generators initialised within the same second start from the same state.

ByteRay compiled the unmodified wolfCrypt sources with DOLPHIN_EMULATOR on a Linux host. Two processes started in the same second produced the same AES-GCM key, IV, ciphertext and tag, and a search of candidate seconds within 1024 seconds of the start time, run through wc_InitRng(), reproduced another process's key, IV, ciphertext and tag; a control build seeded from the host's /dev/urandom did not repeat and was not found by the search.

The exposure is limited by the targets. These are emulator and homebrew console builds, not industrial ports. An application on such a build that uses wolfSSL for TLS on a shared network has its traffic exposed to this search.

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 use a real entropy source on these platforms, and otherwise to fail closed: wc_GenerateSeed() returns an error so that wc_InitRng() fails, instead of returning clock-keyed rand() output as success. If a fallback is kept for test builds, it should mix every available low-grade source through a hash and carry a compile-time warning.

Workaround for affected builds: define CUSTOM_RAND_GENERATE_SEED to a function backed by an entropy source the platform provides. 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