← ALL ADVISORIES

LOW BYTERAY-2026-0485Disclosed

wolfSSL — Mutable Global Callback Context Exported by Renesas FSPSM Port Header

A public header of the Renesas port declares the hardware crypto callback context, guser_PKCbInfo, as a non-const extern global, and the port's context registry gCbCtx also has external linkage. Any code linked into the firmware can overwrite the wrapped-key selection state that later hardware crypto operations use.

Advisory
BYTERAY-2026-0485
CWE
CWE-500
CVSS
3.0 (CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:U/C:L/I:L/A:N)
Vendor
wolfSSL
Product
wolfSSL
Reported
2026-09-28
Disclosure
2026-12-03
Affected
wolfSSL 5.9.2 (tested at master commit d95483f), Renesas FSPSM and TSIP port builds with HAVE_RENESAS_SYNC
Credit
Mehrun P. Hunter and Shahriyar Jalayeri, ByteRay Ltd.

Executive Summary

The Renesas SCE, RSIP and TSIP ports of wolfSSL route crypto operations to the secure hardware through crypto callbacks. The callbacks share a context structure, FSPSM_ST. It holds the device id the callbacks are bound to, the wrapped AES-128 and AES-256 keys, the wrapped RSA key indices, the flags that record which keys are installed, and a pointer to an internal per-callback instance.

With the synchronous callback design enabled, a shipped header declares one such context as a plain global, extern FSPSM_ST guser_PKCbInfo;. It is not const and has no accessor. Any code linked into the same binary can read or overwrite it, which changes the wrapped keys and the callback instance that later hardware operations use. The port's registry of contexts, gCbCtx, is also defined with external linkage.

The practical exposure is small. The library does not define guser_PKCbInfo; the application does, and it is the application's context by design. Access to the registry inside the library is serialized by a hardware lock. Abuse needs a local, privileged component in the same firmware image. This is a hardening issue. The port is not part of a default build.

Affected Products and Versions

  • Component: wolfssl/wolfcrypt/port/Renesas/renesas_sync.h and wolfcrypt/src/port/Renesas/renesas_common.c.
  • Required build: a Renesas FSPSM or TSIP port build with HAVE_RENESAS_SYNC.
  • Tested: wolfSSL master d95483fff72d6e987394b72edca433d4b580a0f4 (version string 5.9.2).
  • A default build does not include the Renesas port.
  • Other releases were not checked.

Technical Details

The declaration is at wolfssl/wolfcrypt/port/Renesas/renesas_sync.h:29, inside the HAVE_RENESAS_SYNC guard. The layout of FSPSM_ST is at wolfssl/wolfcrypt/port/Renesas/renesas-fspsm-crypt.h:48-78.

How the context is used:

  1. The application defines guser_PKCbInfo and fills in the wrapped keys. In the tree the definitions are in sample projects, for example IDE/Renesas/e2studio/RA6M4/test/src/test_main.c:35.
  2. The application passes it to wc_CryptoCb_CryptInitRenesasCmn() (wolfcrypt/src/port/Renesas/renesas_common.c:453). The function writes into the caller's structure and allocates cbInfo->internal only when it is NULL (wolfcrypt/src/port/Renesas/renesas_common.c:477-495).
  3. Under the hardware lock, the function stores the pointer in a free slot of gCbCtx and derives the device id from the slot (wolfcrypt/src/port/Renesas/renesas_common.c:496-511).
  4. Later operations look the context up by device id (wolfcrypt/src/port/Renesas/renesas_common.c:438) and take their key material from it.

The registry is defined as FSPSM_ST *gCbCtx[MAX_FSPSM_CBINDEX]; without static (wolfcrypt/src/port/Renesas/renesas_common.c:74), although it is used only in that file. Any linked code can enumerate or repoint the registered contexts.

Because step 2 allocates the internal instance only when the pointer is NULL, registering one context for two objects makes both share one internal instance. The port's samples use separate per-task contexts for concurrent use.

Reachability and Preconditions

  • Renesas port build with HAVE_RENESAS_SYNC.
  • A component linked into the same binary writes to guser_PKCbInfo or gCbCtx, or an integrator registers one context for more than one TLS or crypto object.
  • No remote path reaches these objects. The attacker position is local and privileged.

Impact

A context that is overwritten or registered twice makes hardware crypto operations use the wrong wrapped keys or share one internal instance across sessions. The affected properties are confidentiality and integrity of operations that depend on that key selection. The in-tree consumers of the global on the library side are test, benchmark and sample code.

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 to remove the extern declaration of guser_PKCbInfo from the shipped header, or restrict it to the sample builds; to declare gCbCtx static; and to have wc_CryptoCb_CryptInitRenesasCmn() reject a context that is already registered for another object. The lock on the registry should stay on every access, including slot release.

Integrators should keep callback contexts file-local, use one context per TLS or crypto object, and register each context once.

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