wolfSSL — Fixed All-Zero IV in EVP AES-CFB1, CFB8 and CFB128 Initialization Without an IV
In the wolfSSL EVP compatibility layer, the nine AES-CFB1, CFB8 and CFB128 initialization branches accept a key with a NULL IV on a fresh context and leave the IV register at zero. Every message under that key then starts from the same keystream, and no error is reported.
- Advisory
- BYTERAY-2026-0380
- 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 and WOLFSSL_AES_CFB where an application initializes an EVP AES-CFB 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 the EVP cipher API. It has nine branches for AES in CFB mode: CFB1, CFB8 and CFB128, each with 128, 192 and 256-bit keys. All nine accept a NULL IV together with a key and return success.
On a fresh 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. The CFB data paths then run with no check that an IV was ever set.
CFB derives its keystream from the IV register. With the register at zero, every message under the same key begins with the same keystream. An observer who sees several ciphertexts can tell when two messages begin with the same plaintext, and one known plaintext start recovers the fixed pad and with it the start of every other message. The condition is created by the application that omits the IV, not by a remote party. Builds without the OpenSSL compatibility layer do not include this code.
Affected Products and Versions
- Component:
wolfcrypt/src/evp.c,wolfSSL_EVP_CipherInit(), AES-CFB1, AES-CFB8 and AES-CFB128 branches. - Required build: the OpenSSL compatibility layer with
WOLFSSL_AES_CFB. The CFB1 and CFB8 branches also require thatWOLFSSL_NO_AES_CFB_1_8is not defined. - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- Builds without the OpenSSL compatibility layer do not include the EVP API. Other releases were not checked.
Technical Details
The CFB1 branches are at wolfcrypt/src/evp.c:7951-8040, the CFB8 branches at wolfcrypt/src/evp.c:8042-8130 and the CFB128 branches at wolfcrypt/src/evp.c:8134-8222. All nine follow one template, and none rejects a NULL IV when a key is supplied. The AES-128-CFB1 branch is representative (wolfcrypt/src/evp.c:7966-7976):
if (key) {
ret = AesSetKey_ex(&ctx->cipher.aes, key, (word32)ctx->keyLen,
iv, AES_ENCRYPTION, 0);
if (ret != 0)
return WOLFSSL_FAILURE;
}
if (iv && key == NULL) {
ret = wc_AesSetIV(&ctx->cipher.aes, iv);
What happens when the application passes a key and a NULL IV on a fresh context:
- The context is zero-filled, so
ctx->ivSzis 0 and the fallbackif (!iv && ctx->ivSz) { iv = ctx->iv; }does not apply (wolfcrypt/src/evp.c:7622-7626). AesSetKey_ex()is called withiv == NULL. It saves the IV register before key setup and restores it afterwards (wolfcrypt/src/evp.c:7159-7174). The saved register is zero, and the call returns success.wc_AesSetIV()does not run, because a key was supplied.evpCipherBlock()callswc_AesCfb1Encrypt(),wc_AesCfb8Encrypt()orwc_AesCfbEncrypt(), or the decrypt counterparts, with the register as it is (wolfcrypt/src/evp.c:654-684). The one-shot path inwolfSSL_EVP_Cipher()does the same (wolfcrypt/src/evp.c:9025-9058).
For CFB128 the first 16 bytes of every message are XORed with the same value, the AES encryption of the zero block. For CFB8 and CFB1 the fixed part is the first byte or bit, and later output depends on the ciphertext before it, so two messages stay aligned for as long as their plaintexts agree.
Reachability and Preconditions
- Build: OpenSSL compatibility layer with
WOLFSSL_AES_CFB. - An application calls
EVP_EncryptInit_ex()or an equivalent with an AES-CFB1, AES-CFB8 or AES-CFB128 cipher, 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 who knows or can guess the start of one plaintext. The attacker cannot cause the condition. No authentication is involved.
Impact
Loss of confidentiality at the start of each message, and equality leakage across messages. With CFB128, one known first plaintext block gives the fixed pad, and that pad decrypts the first block of every other message under the key. Messages that begin with the same plaintext produce the same ciphertext prefix. The leakage is limited to the start of each message. It is not full keystream reuse. Integrity and availability are not affected by this issue.
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 each of the nine CFB branches, fail the initialization when a key is supplied with a NULL IV on a fresh context. If a missing IV is to be tolerated, it should be replaced by a random IV stored in the context where the application can read it. A check on the CFB data paths in evpCipherBlock() and wolfSSL_EVP_Cipher() that an IV was programmed would stop any use of a context that never received one. 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
- AES-CFB1 branches of
wolfSSL_EVP_CipherInitat the tested commit - AES-CFB8 and AES-CFB128 branches at the tested commit
- Related advisories for other modes in the same function: BYTERAY-2026-0377, BYTERAY-2026-0378, BYTERAY-2026-0379, BYTERAY-2026-0381, BYTERAY-2026-0382, BYTERAY-2026-0383