wolfSSL — Nonce Reuse Across Messages in EVP ARIA-GCM Finalization
After each ARIA-GCM message, the EVP layer zeroes the context IV and then copies the unadvanced nonce from the cipher state back into it. A context reused for further messages without a new IV encrypts them under the first message's key and nonce, and every call returns success.
- Advisory
- BYTERAY-2026-0321
- 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 process more than one ARIA-GCM message on one EVP context
- Credit
- Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.
Executive Summary
In wolfSSL's OpenSSL compatibility layer, an ARIA-GCM message is buffered by the Update calls and encrypted or decrypted in one step by wolfSSL_EVP_CipherFinal(). The nonce for that step is the context's IV buffer, ctx->iv.
After the step, Final clears ctx->iv. The comment says IV reuse is not recommended. The next statement calls wolfSSL_StoreExternalIV(), and its ARIA case copies the nonce held in the cipher state back into ctx->iv. That nonce was loaded once, at init, and nothing has advanced it. The clear is undone immediately, and the context is left holding the nonce it has just used.
An application that sends another message on the same context without supplying a new IV therefore seals it under the same key and nonce as the first, with no error. An observer of two such messages learns the XOR of their plaintexts and can go on to forge tags. ARIA is not part of a default build, and wolfSSL's own TLS code does not use the EVP layer.
Affected Products and Versions
- Component:
wolfcrypt/src/evp.c, theWC_ARIA_128_GCM_TYPE,WC_ARIA_192_GCM_TYPEandWC_ARIA_256_GCM_TYPEcases ofwolfSSL_EVP_CipherFinal(); andsrc/ssl.c, the ARIA case ofwolfSSL_StoreExternalIV(). - 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:1474-1475). - Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
- A default
./configurebuild does not include this code. Other releases were not checked.
Technical Details
The end of the ARIA-GCM case in wolfSSL_EVP_CipherFinal() (wolfcrypt/src/evp.c:1514-1525):
if (ret == WOLFSSL_SUCCESS) {
if (ctx->authIncIv) {
ctx->authIncIv = 0;
}
else {
/* Clear IV, since IV reuse is not recommended for AES GCM. */
XMEMSET(ctx->iv, 0, ARIA_BLOCK_SIZE);
}
if (wolfSSL_StoreExternalIV(ctx) != WOLFSSL_SUCCESS) {
ret = WOLFSSL_FAILURE;
}
}
The ARIA case of wolfSSL_StoreExternalIV() (src/ssl.c:10907-10912):
case WC_ARIA_128_GCM_TYPE :
case WC_ARIA_192_GCM_TYPE :
case WC_ARIA_256_GCM_TYPE :
WOLFSSL_MSG("ARIA GCM");
XMEMCPY(ctx->iv, &ctx->cipher.aria.nonce, ARIA_BLOCK_SIZE);
break;
The only code that advances ctx->cipher.aria.nonce is an increment that runs when ctx->authIncIv is set (wolfcrypt/src/evp.c:1505-1509). That flag belongs to the EVP_CTRL_GCM_IV_GEN flow, which an application has to opt into. Without it the nonce in the cipher state is still the one from init.
The sequence for two messages:
- The application initialises ARIA-GCM with a key and a first IV.
EvpCipherInitAriaGCM()loads the IV intoctx->cipher.aria.noncewithwc_AriaGcmSetExtIV()(wolfcrypt/src/evp.c:7582-7585). - Message one: Update buffers the data.
wolfSSL_EVP_CipherFinal()(wolfcrypt/src/evp.c:1313) callswc_AriaEncrypt()orwc_AriaDecrypt()withctx->ivas the nonce (wolfcrypt/src/evp.c:1481-1490). - The nonce in the cipher state is not advanced, because
authIncIvis not set. - Final zeroes
ctx->iv(wolfcrypt/src/evp.c:1518-1521) and callswolfSSL_StoreExternalIV()(wolfcrypt/src/evp.c:1522-1524). wolfSSL_StoreExternalIV()copies the first IV back intoctx->iv(src/ssl.c:10911).- Message two repeats step 2 with the same key and the same
ctx->iv.
Reachability and Preconditions
- Build with
OPENSSL_EXTRAandHAVE_ARIA. - An application that processes two or more messages through one ARIA-GCM EVP context and does not set a fresh IV for each, relying on the library to manage the IV between messages. It has not opted into
EVP_CTRL_GCM_IV_GEN. - In ByteRay's test, calling Update and Final again directly after the first Final did not reach the reuse: the reset at the end of Final (
wolfcrypt/src/evp.c:1757) leaves the ARIA session without a key, and the second Final fails. The reuse was reached when the application re-initialised the context between messages with the key and a NULL IV, which makes the init code fall back to the storedctx->iv. - The attacker is a passive observer of the ciphertexts. They need two or more messages under the same key and supply no input to the context.
Impact
Every message after the first on such a context repeats the first message's key and nonce pair. The XOR of two ciphertexts is the XOR of their plaintexts, so one known plaintext exposes others. A repeated GCM nonce also lets an observer recover the authentication subkey from captured messages and tags, and then produce valid tags for other data under that key. An identical plaintext produces an identical ciphertext and tag, which an observer can recognise and replay. All calls return success.
ByteRay reproduced this through the public EVP API, with the external ARIA SDK replaced by a stub that records the nonce it is handed. Three messages on one context, re-initialised between messages with the key and no IV, all reached the cipher with the first message's nonce; a repeated plaintext gave an identical ciphertext and tag, and two different messages showed the same keystream.
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 advance the nonce on every message whatever the finalization path: increment ctx->cipher.aria.nonce after each one-shot encrypt or decrypt, so that the copy in wolfSSL_StoreExternalIV() puts the next nonce into ctx->iv and not the spent one. The alternative is to honour the clear: skip the ARIA restore after an intentional wipe and fail any later Final until the caller sets a new IV. Either way, a Final that would repeat the previous key and nonce pair should not proceed silently.
Applications can avoid the issue by passing an explicit, unique IV to the init call for every message on an ARIA-GCM context.
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.