wolfSSL — All-Zero Data-Unit Tweak in EVP AES-XTS Initialization Without an IV
In the wolfSSL EVP compatibility layer, the AES-XTS initialization branches write sixteen zero bytes into the tweak when the IV argument is NULL and return success. Every data unit under the key is then encrypted with tweak zero, so equal plaintext units give equal ciphertext units.
- Advisory
- BYTERAY-2026-0382
- 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 WOLFSSL_AES_XTS where an application initializes EVP AES-XTS with 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. For AES-128-XTS and AES-256-XTS the IV argument is the tweak, the data-unit number that makes each sector or record encrypt differently.
When the IV argument is NULL, the two XTS branches fill the context's IV buffer with sixteen zero bytes and return success. They do not report an error. The data paths then pass that buffer to the XTS routines as the tweak and do not check that a tweak was ever supplied.
With the tweak fixed at zero, every data unit under the same key is processed with the same tweak schedule. Identical plaintext units produce identical ciphertext units, wherever they are stored. An observer of the ciphertext learns where content repeats. Plaintext and keys are not recovered. Correct XTS use always supplies the data-unit number, so the condition is created by an application that omits it. ByteRay's report to wolfSSL notes that the behaviour matches how OpenSSL handles a NULL IV with XTS. Builds without the OpenSSL compatibility layer do not include this code.
Affected Products and Versions
- Component:
wolfcrypt/src/evp.c,wolfSSL_EVP_CipherInit(), AES-128-XTS and AES-256-XTS branches. - Required build: the OpenSSL compatibility layer with
WOLFSSL_AES_XTS. - 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 AES-128-XTS branch handles a NULL IV with a zero-fill (wolfcrypt/src/evp.c:8331-8336):
if (iv != NULL) {
if (iv != ctx->iv) /* Valgrind error when src == dst */
XMEMCPY(ctx->iv, iv, (size_t)ctx->ivSz);
}
else
XMEMSET(ctx->iv, 0, WC_AES_BLOCK_SIZE);
The AES-256-XTS branch is identical (wolfcrypt/src/evp.c:8372-8377). Both then set the key and return success.
What happens when the application omits the tweak:
- The application selects the cipher with
EVP_aes_128_xts()orEVP_aes_256_xts()(wolfcrypt/src/evp.c:6426,wolfcrypt/src/evp.c:6434) and initializes it with a key and a NULL IV. - On a fresh context
ctx->ivSzis 0, so the fallbackif (!iv && ctx->ivSz) { iv = ctx->iv; }does not apply (wolfcrypt/src/evp.c:7622-7626).ivstays NULL. - The XTS branch takes the
elsearm and writes sixteen zero bytes toctx->iv(wolfcrypt/src/evp.c:8336,wolfcrypt/src/evp.c:8377). evpCipherBlock()passesctx->ivandctx->ivSztowc_AesXtsEncrypt()orwc_AesXtsDecrypt()as the tweak (wolfcrypt/src/evp.c:686-695).wolfSSL_EVP_Cipher()does the same (wolfcrypt/src/evp.c:9074-9085). Neither checks that a tweak was set.- Every data unit is encrypted with tweak zero. Unlike the other modes handled by this function, the zero value here is written by the branch itself. It is not a leftover of a zero-filled context.
Reachability and Preconditions
- Build: OpenSSL compatibility layer with
WOLFSSL_AES_XTS. - An application uses
EVP_aes_128_xts()orEVP_aes_256_xts(), for example for disk or record encryption, and supplies the key but no tweak. - The same key protects more than one data unit.
- Attacker position: an observer of stored or transmitted ciphertext units. The attacker cannot cause the condition. No authentication is involved.
Impact
The per-data-unit variation that XTS exists to provide is gone. Equal aligned plaintext blocks in different data units give equal ciphertext blocks, so the observer can compare and fingerprint content across the encrypted volume or stream, and known content such as file headers can be located. Ciphertext units can also be moved between positions and still decrypt to their original content. There is no key recovery and no plaintext disclosure. Supplying the data-unit number is standard XTS usage, so the precondition is an application error that correct XTS code does not make.
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: return an error from the XTS branches when the IV is NULL instead of zero-filling it. The data-unit number is a required parameter and has no safe substitute. A flag that records whether a real tweak was provided, checked in evpCipherBlock() and wolfSSL_EVP_Cipher(), would stop a context without a tweak from encrypting. If rejecting the call is not acceptable for compatibility, the data-path check and clear documentation are the minimum. Workaround: applications should pass the data-unit number as the IV for every data unit.
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-XTS branches of
wolfSSL_EVP_CipherInitat the tested commit - XTS data path in
evpCipherBlockat the tested commit - Related advisories for other modes in the same function: BYTERAY-2026-0377, BYTERAY-2026-0378, BYTERAY-2026-0379, BYTERAY-2026-0380, BYTERAY-2026-0381, BYTERAY-2026-0383