← ALL ADVISORIES

MEDIUM BYTERAY-2026-0378Disclosed

wolfSSL — Fixed All-Zero IV in EVP Single-DES CBC Initialization Without an IV

In the wolfSSL EVP compatibility layer, initializing single-DES CBC with a key and a NULL IV succeeds, and the DES key setup sets the IV register to zero. Every message under that key is then encrypted with the same all-zero IV, and no error is reported.

Advisory
BYTERAY-2026-0378
CWE
CWE-329
Vendor
wolfSSL
Product
wolfSSL
Reported
2026-09-28
Disclosure
2026-12-03
Affected
wolfSSL 5.9.2 (tested at master commit d95483f), builds with the OpenSSL compatibility layer and DES where an application initializes EVP DES-CBC with a key and a NULL IV
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

wolfSSL_EVP_CipherInit() in wolfcrypt/src/evp.c is the common initialization function behind the EVP cipher API. Its single-DES CBC branch, selected with EVP_des_cbc(), passes the IV pointer it was given straight to the DES key setup and does not check it.

When the application supplies a key and a NULL IV, the key setup zeroes the IV register and returns success. The fallback that reuses an IV stored in the context does not apply to a fresh context. No error is raised and no random IV is generated.

Every message encrypted under that key then uses the same all-zero IV, so the first ciphertext block is a fixed function of the first plaintext block. An observer can tell when two messages begin with the same block. The condition is created by the application that omits the IV, not by a remote party. Single DES has a 56-bit key regardless, so the added harm is the deterministic first block. Builds without the OpenSSL compatibility layer do not include this code.

Affected Products and Versions

  • Component: wolfcrypt/src/evp.c, wolfSSL_EVP_CipherInit(), DES-CBC branch. The AES-CBC and DES-EDE3-CBC branches of the same function have the same shape and are described in BYTERAY-2026-0377.
  • Required build: the OpenSSL compatibility layer with DES enabled (NO_DES3 not defined).
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • Builds without the OpenSSL compatibility layer do not include the EVP API. Within wolfSSL, the one production EVP caller passes a random IV (src/pk.c:393). Other releases were not checked.

Technical Details

The DES-CBC branch (wolfcrypt/src/evp.c:8624-8644) sets the key and programs an IV only in the IV-without-key case:

            if (key) {
                ret = wc_Des_SetKey(&ctx->cipher.des, key, iv,
                          ctx->enc ? DES_ENCRYPTION : DES_DECRYPTION);
                if (ret != 0)
                    return WOLFSSL_FAILURE;
            }

            if (iv && key == NULL)
                wc_Des_SetIV(&ctx->cipher.des, iv);

What happens when the application passes a key and a NULL IV on a fresh context:

  1. EVP_des_cbc() (wolfcrypt/src/evp.c:6570) selects the branch.
  2. The context was zero-filled by wolfSSL_EVP_CIPHER_CTX_init() (wolfcrypt/src/evp.c:6661-6670), so ctx->ivSz is 0 on entry. The fallback if (!iv && ctx->ivSz) { iv = ctx->iv; } does not apply (wolfcrypt/src/evp.c:7622-7626). The branch sets ctx->ivSz only afterwards (wolfcrypt/src/evp.c:8632).
  3. wc_Des_SetKey() is called with iv == NULL (wolfcrypt/src/evp.c:8635-8640). It hands IV handling to wc_Des_SetIV() (wolfcrypt/src/des3.c:1692).
  4. wc_Des_SetIV() copies the IV when one is given and otherwise sets the register to zero. It returns success in both cases (wolfcrypt/src/des3.c:2029-2039).
  5. The second statement in the branch does not run, because a key was supplied (wolfcrypt/src/evp.c:8642-8643).
  6. evpCipherBlock() calls wc_Des_CbcEncrypt() or wc_Des_CbcDecrypt() with the register as it is (wolfcrypt/src/evp.c:699-704). wolfSSL_EVP_Cipher() does the same (wolfcrypt/src/evp.c:9154-9162). Neither path checks that an IV was ever set.

Reachability and Preconditions

  • Build: OpenSSL compatibility layer with DES.
  • An application calls EVP_EncryptInit_ex() or an equivalent with EVP_des_cbc(), a key and a NULL IV on a fresh context. Code written for a library that generates an IV on its own is the likely source.
  • The key is used for more than one message.
  • Attacker position: a passive observer of the ciphertexts, on the network or on a storage medium. The attacker cannot cause the condition. No authentication is involved.

Impact

The first block of every message is encrypted deterministically. Identical first plaintext blocks give identical first ciphertext blocks, and messages with a common prefix share ciphertext up to the first differing block. An observer can detect repeated content and recognize known first blocks. There is no key recovery from this issue and no ability to tamper. Single DES is weak on its own because of its 56-bit key. What the fixed IV adds is this equality leakage.

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 from the report: in the DES-CBC branch, fail the initialization when a key is supplied with a NULL IV, and apply the same rule in the other CBC branches. A flag in the cipher context that records whether an IV was programmed, checked before any CBC operation, would cover the data paths. If a missing IV must be tolerated, it should be replaced by a random IV stored in the context where the application can read it, never by a constant. Workaround: applications should pass a fresh random IV for every message at initialization, and should not use single DES for new data.

Timeline

  • 2026-09-28 — Reported to wolfSSL.
  • 2026-12-03 — Public disclosure.

Credits

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

References