← ALL ADVISORIES

HIGH BYTERAY-2026-0320Disclosed

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 from wolfSSL_EVP_CipherInit() and the EVP_EncryptInit_ex family.
  • Required build: OPENSSL_EXTRA (--enable-opensslextra) and HAVE_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 ./configure build 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:

  1. The application creates a context. wolfSSL_EVP_CIPHER_CTX_init() clears the whole structure, including ctx->iv (wolfcrypt/src/evp.c:6665).
  2. The application calls EVP_CipherInit(ctx, EVP_aria_128_gcm(), key, NULL, 1), which enters wolfSSL_EVP_CipherInit() (wolfcrypt/src/evp.c:7593) and dispatches to EvpCipherInitAriaGCM() (wolfcrypt/src/evp.c:8413).
  3. ctx->ivSz becomes 12. The nonce step is skipped because iv is NULL (wolfcrypt/src/evp.c:7582-7585).
  4. The end of wolfSSL_EVP_CipherInit() copies the cipher's IV into ctx->iv only when an IV was supplied (wolfcrypt/src/evp.c:8730-8736), so ctx->iv stays zero.
  5. For each message, wolfSSL_EVP_CipherFinal() (wolfcrypt/src/evp.c:1313) calls wc_AriaEncrypt() or wc_AriaDecrypt() with ctx->iv and ctx->ivSz as the nonce (wolfcrypt/src/evp.c:1481-1490).
  6. 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_EXTRA and HAVE_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