wolfSSL — All-Zero Nonce on NULL IV in EVP ARIA-GCM Initialization
In the OpenSSL-compatible EVP layer, ARIA-GCM initialisation accepts a NULL IV and returns success without setting a nonce. The context then encrypts and decrypts every message with its zero-filled IV buffer as the GCM nonce, so all messages under one key share a keystream.
- Advisory
- BYTERAY-2026-0320
- CWE
- CWE-323
- CVSS
- 7.4 (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N)
- Vendor
- wolfSSL
- Product
- wolfSSL
- Reported
- 2026-09-27
- Disclosure
- 2026-12-03
- Affected
- wolfSSL 5.9.2 (tested at master commit d95483f), builds with OPENSSL_EXTRA and HAVE_ARIA (--enable-opensslextra --enable-aria) whose applications use ARIA-GCM through the EVP API
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
wolfSSL's OpenSSL compatibility layer offers ARIA-GCM through the EVP cipher API. EvpCipherInitAriaGCM() sets up the context: cipher type, key, nonce length and, if the caller supplied one, the nonce.
When the caller passes a NULL IV, the function sets no nonce and still returns success. The context was zero-filled when it was created, and nothing else writes its IV buffer. Each later Final call passes that buffer to the ARIA-GCM encrypt or decrypt call as a 12-byte nonce. The nonce is therefore twelve zero bytes for every message, and no call reports an error.
GCM gives no protection when a key and nonce pair is used twice. An observer who captures two ciphertexts from such a context learns the XOR of the plaintexts, and can go on to forge tags for that key. ARIA support is not part of a default build, and wolfSSL's own TLS code does not use the EVP layer, so only applications that call the EVP API are exposed.
Affected Products and Versions
- Component:
wolfcrypt/src/evp.c,EvpCipherInitAriaGCM(), reached fromwolfSSL_EVP_CipherInit()and theEVP_EncryptInit_exfamily. - Required build:
OPENSSL_EXTRA(--enable-opensslextra) andHAVE_ARIA(--enable-aria). ARIA support also needs the external MagicCrypto SDK. The ARIA-GCM EVP code is compiled for non-FIPS builds and for FIPS version 2 and later (wolfcrypt/src/evp.c:7514-7515). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild does not include this code. ARIA is disabled by default (configure.ac:4846). - Other releases were not checked.
Technical Details
EvpCipherInitAriaGCM() defaults the nonce length to 12 when none was set (wolfcrypt/src/evp.c:7548-7550). Its last steps are (wolfcrypt/src/evp.c:7578-7587):
if (key && wc_AriaSetKey(&ctx->cipher.aria, (byte *)key)) {
WOLFSSL_MSG("wc_AriaSetKey() failed");
return WOLFSSL_FAILURE;
}
if (iv && wc_AriaGcmSetExtIV(&ctx->cipher.aria, iv, ctx->ivSz)) {
WOLFSSL_MSG("wc_AriaGcmSetIV() failed");
return WOLFSSL_FAILURE;
}
return WOLFSSL_SUCCESS;
With iv == NULL the second condition is false and the function returns success. No flag records that a nonce is still missing.
The data flow for a context that never receives an IV:
- The application creates a context.
wolfSSL_EVP_CIPHER_CTX_init()clears the whole structure, includingctx->iv(wolfcrypt/src/evp.c:6665). - The application calls
EVP_CipherInit(ctx, EVP_aria_128_gcm(), key, NULL, 1), which enterswolfSSL_EVP_CipherInit()(wolfcrypt/src/evp.c:7593) and dispatches toEvpCipherInitAriaGCM()(wolfcrypt/src/evp.c:8413). ctx->ivSzbecomes 12. The nonce step is skipped becauseivis NULL (wolfcrypt/src/evp.c:7582-7585).- The end of
wolfSSL_EVP_CipherInit()copies the cipher's IV intoctx->ivonly when an IV was supplied (wolfcrypt/src/evp.c:8730-8736), soctx->ivstays zero. - For each message,
wolfSSL_EVP_CipherFinal()(wolfcrypt/src/evp.c:1313) callswc_AriaEncrypt()orwc_AriaDecrypt()withctx->ivandctx->ivSzas the nonce (wolfcrypt/src/evp.c:1481-1490). - Every ciphertext and tag the application sends was produced under the same key with a nonce of twelve zero bytes.
The streaming AES-GCM API in wolfCrypt handles the same situation by returning MISSING_IV (wolfcrypt/src/aes.c:14775). The EVP ARIA-GCM path has no equivalent check. The SM4-GCM and SM4-CCM branches of wolfSSL_EVP_CipherInit() also copy the IV only when it is not NULL (wolfcrypt/src/evp.c:8588-8590, wolfcrypt/src/evp.c:8618-8620); BYTERAY-2026-0323 and BYTERAY-2026-0324 cover those ciphers.
Reachability and Preconditions
- Build with
OPENSSL_EXTRAandHAVE_ARIA. - An application that initialises an ARIA-GCM EVP context with a NULL IV and never supplies one before it encrypts. OpenSSL's EVP contract allows the key and the IV to arrive in separate init calls, so code ported from OpenSSL can pass NULL here. The defect is that wolfSSL then encrypts instead of failing.
- The attacker is a passive observer of the ciphertexts the application produces. They need at least two messages under the same key.
- The attacker supplies no input to the context and needs no access to the process.
Impact
Every message from such a context is sealed under the same key and nonce. The XOR of any two ciphertexts is the XOR of their plaintexts, and one known plaintext gives the keystream for all other messages up to its length. Repeating a GCM nonce also lets an observer recover the authentication subkey from captured messages and tags, and then produce valid tags for data of their choosing under that key. The application sees success at every step.
ByteRay reproduced this through the public EVP API, with the external ARIA SDK replaced by a stub that records the nonce it is handed. Initialisation with a NULL IV returned success, the stub received a 12-byte all-zero nonce, and two messages encrypted this way had ciphertexts whose XOR equalled the XOR of their plaintexts.
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 make the IV mandatory for ARIA-GCM in the EVP layer. If compatibility requires that init accepts a deferred IV, the context should track whether an IV has been set and fail the first Update or Final that runs without one, as the streaming AES-GCM API does. A constant nonce should never stand in for a missing one. The same rule applies to the other AEAD init paths in this file.
Applications can protect themselves by always passing an explicit, unique IV for each message when they initialise an ARIA-GCM context, and by treating a NULL IV at init as an error in their own code.
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
EvpCipherInitAriaGCMat the tested commit- ARIA-GCM case of
wolfSSL_EVP_CipherFinalat the tested commit - BYTERAY-2026-0321, nonce reuse across messages in EVP ARIA-GCM finalization
- BYTERAY-2026-0322, nonce reuse across messages in EVP AES-CCM finalization
- BYTERAY-2026-0323, all-zero nonce after the first message in EVP SM4-GCM
- BYTERAY-2026-0324, all-zero nonce after the first message in EVP SM4-CCM