← ALL ADVISORIES

LOW BYTERAY-2026-0527Disclosed

wolfSSL — AES Key Material Not Cleared by wc_AesFree in the TI Crypto Port

In builds with WOLFSSL_TI_CRYPT, wc_AesFree is an empty function. The TI key setup copies the raw AES key into the Aes context, so the key stays in memory after the context is freed. The generic implementation clears the same context with ForceZero.

Advisory
BYTERAY-2026-0527
CWE
CWE-733
CVSS
2.5 (CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/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 WOLFSSL_TI_CRYPT (Texas Instruments hardware crypto port)
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

When wolfSSL is built for Texas Instruments parts with WOLFSSL_TI_CRYPT, the generic AES implementation is replaced by a TI-specific port. That port supplies its own wc_AesFree(), and the function does nothing. It takes the context pointer and discards it.

The TI key setup copies the raw AES key into that context. Every AES key used on such a build, including TLS record keys, therefore stays in heap or stack memory after the context is freed. No wipe is attempted. The generic wc_AesFree() clears the whole context with ForceZero(), so the two implementations of the same function differ.

Recovering a key needs a separate way to read that memory. Default builds do not compile the TI port.

Affected Products and Versions

  • Component: wolfcrypt/src/port/ti/ti-aes.c, wc_AesFree().
  • Required build: WOLFSSL_TI_CRYPT with AES enabled.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default build does not define WOLFSSL_TI_CRYPT and is not affected.
  • Other releases were not checked.

Technical Details

The TI teardown is the whole of wolfcrypt/src/port/ti/ti-aes.c:1135-1138:

void wc_AesFree(Aes* aes)
{
    (void)aes;
}

How key material ends up in a context that is never cleared:

  1. With WOLFSSL_TI_CRYPT, wolfcrypt/src/aes.c includes the TI port in place of its own body (wolfcrypt/src/aes.c:191-198). The generic wc_AesFree(), which ends in ForceZero(aes, sizeof(Aes)) (wolfcrypt/src/aes.c:16353), is in the #else branch and is not compiled.
  2. The TI key setup stores the raw key in the context with XMEMCPY(aes->key, key, len) (wolfcrypt/src/port/ti/ti-aes.c:109).
  3. The TLS layer or the application calls wc_AesFree() when it is done with the context. The call returns without touching it.
  4. The Aes structure is freed or goes out of scope with aes->key, aes->reg and aes->tmp intact.

This is not a case of a wipe that a compiler might remove. On this configuration there is no wipe in the source.

Reachability and Preconditions

  • Build: WOLFSSL_TI_CRYPT, used on TI microcontrollers with hardware crypto. Off by default.
  • Any AES use is enough: TLS record protection, wc_AesGcmFree and CBC teardown paths, and direct wc_AesFree() calls by the application.
  • The attacker needs an independent memory-disclosure primitive against the device or process, such as a heap over-read, a memory dump, or physical recovery of RAM contents.
  • No protocol input changes whether the key persists. It always does on this build.

Impact

AES keys and cipher state remain in memory after their context is released. An attacker who can later read that memory can recover the keys, including record-protection keys of TLS connections. The impact is limited to confidentiality and depends on a second bug or on physical access.

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 is for the TI wc_AesFree() to clear the whole context with ForceZero(aes, sizeof(Aes)), as the generic function does. Sharing one teardown helper between the generic and TI implementations would keep the two from diverging again. As a workaround, an application on a WOLFSSL_TI_CRYPT build can zero its own Aes objects after calling wc_AesFree(), with a wipe the compiler cannot remove. That does not cover contexts owned by the TLS layer.

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