← ALL ADVISORIES

MEDIUM BYTERAY-2026-0377Disclosed

wolfSSL — Fixed All-Zero IV in EVP AES-CBC and Triple-DES CBC Initialization Without an IV

In the wolfSSL EVP compatibility layer, initializing AES-CBC or DES-EDE3-CBC with a key and a NULL IV on a fresh context succeeds and leaves the IV register at zero. Every message under that key is then encrypted with the same all-zero IV, and no error is reported.

Advisory
BYTERAY-2026-0377
CWE
CWE-329
CVSS
5.9 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N)
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 where an application initializes an EVP AES-CBC or DES-EDE3-CBC cipher 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 EVP_EncryptInit_ex(), EVP_CipherInit_ex() and related calls. For AES-128/192/256-CBC and DES-EDE3-CBC it accepts a NULL IV together with a key and returns success.

On a freshly created context nothing supplies an IV in that case. The context is zero-filled, the key setup keeps the zeroed IV register, and the fallback that reuses a stored IV only applies to a context that was initialized before. No error is raised and no random IV is generated. The CBC data paths then encrypt with whatever the register holds.

Every message encrypted under that key uses the same all-zero IV. The first ciphertext block becomes a fixed function of the first plaintext block. Equal first blocks are visible to an observer, and an observer who knows the plaintext behind one first block recognizes that block wherever it recurs. The condition is created by the application that omits the IV. wolfSSL's own EVP caller always supplies a random one. ByteRay's report to wolfSSL notes that accepting a NULL IV mirrors OpenSSL's compatibility semantics. Builds without the OpenSSL compatibility layer do not include this code.

Affected Products and Versions

  • Component: wolfcrypt/src/evp.c, wolfSSL_EVP_CipherInit(), AES-CBC and DES-EDE3-CBC branches.
  • Required build: the OpenSSL compatibility layer with AES-CBC or Triple-DES enabled.
  • 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), so the library's own use is not affected. Other releases were not checked.

Technical Details

The AES-128-CBC branch sets the key with whatever IV pointer it was given (wolfcrypt/src/evp.c:7647-7652):

            if (key) {
                ret = AesSetKey_ex(&ctx->cipher.aes, key, (word32)ctx->keyLen,
                            iv, ctx->enc ? AES_ENCRYPTION : AES_DECRYPTION, 0);
                if (ret != 0)
                    return WOLFSSL_FAILURE;
            }

The AES-192 and AES-256 branches are the same (wolfcrypt/src/evp.c:7661-7682, wolfcrypt/src/evp.c:7707-7713). The DES-EDE3-CBC branch calls wc_Des3_SetKey() with the same pointer (wolfcrypt/src/evp.c:8677-8682).

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

  1. wolfSSL_EVP_CIPHER_CTX_init() has zero-filled the context (wolfcrypt/src/evp.c:6661-6670). ctx->ivSz is 0 and the cipher's IV register is zero.
  2. The fallback if (!iv && ctx->ivSz) { iv = ctx->iv; } does not apply, because ctx->ivSz is still 0 (wolfcrypt/src/evp.c:7622-7626). iv stays NULL.
  3. AesSetKey_ex() saves the IV register before key setup and restores it afterwards when iv is NULL (wolfcrypt/src/evp.c:7155-7176). Its comment says this keeps the IV for OpenSSL compatibility. The saved register is zero.
  4. For DES-EDE3-CBC, wc_Des3_SetKey() does not program an IV when none is given (wolfcrypt/src/des3.c:677-681). In both cases initialization returns success. There is no branch that rejects a NULL IV.
  5. evpCipherBlock() calls wc_AesCbcEncrypt() or wc_Des3_CbcEncrypt() with the register as it is (wolfcrypt/src/evp.c:618-624, wolfcrypt/src/evp.c:705-710). wolfSSL_EVP_Cipher() does the same (wolfcrypt/src/evp.c:9009-9020, wolfcrypt/src/evp.c:9163-9171). Neither path checks that an IV was ever set. For a fixed key, the first ciphertext block of every message is the block cipher applied to the first plaintext block alone.

Reachability and Preconditions

  • Build: OpenSSL compatibility layer with the CBC cipher in question.
  • An application calls EVP_EncryptInit_ex() or an equivalent with an AES-CBC or DES-EDE3-CBC cipher, a key and a NULL IV, on a context that has not held an IV before. 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. The attacker cannot cause the condition. No authentication is involved.

Impact

The first block of every message is encrypted deterministically, which is a confidentiality failure for that block and leaks equality across messages. Identical first plaintext blocks give identical first ciphertext blocks, and messages with a common prefix share ciphertext up to the first differing block. Repeated content can be detected, known first blocks can be recognized, and a dictionary can be built where the attacker can also submit plaintext. There is no key recovery and no ability to tamper.

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: fail the initialization when a CBC cipher gets a key and a NULL IV on a context with no stored IV, or generate a random IV and store it in the context where the application can read it. A check on the CBC data paths that an IV was programmed would close the same gap for all CBC ciphers. The compatibility-layer documentation should describe the behaviour. Workaround: applications should pass a fresh random IV for every message at initialization.

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