GHSA-ffg5-m7vh-vwrp: Unchecked pointer vulnerabilities in ThreadX TrustZone-M entry functions

GHSA ID

GHSA‑ffg5‑m7vh‑vwrp

CVE ID

CVE‑2026‑102709

Severity

High

CWE

CWE-200, CWE-501, CWE-822

Published

2026‑11‑01

Last updated

2026‑11‑01

Affected packages

Package Vulnerable versions Patched versions

ThreadX

>= 6.0.1, ⇐ 6.5.2.202603

6.5.2.202603b

Description

Summary

ThreadX’s TrustZone-M ports expose four non-secure-callable (NSC) entry functions that take a TX_THREAD * from the non-secure world and dereference it in the secure world without checking that it points to non-secure memory. Non-secure code can therefore make the secure firmware read and write secure memory on its behalf: it can learn which secure bytes are zero, write chosen secure words, and fault the secure world. This breaks the isolation TrustZone-M is meant to provide and can lead to recovery of secure-world secrets such as cryptographic keys.

Details

The affected functions, declared with cmse_nonsecure_entry and callable directly from non-secure code, are _tx_thread_secure_mode_stack_allocate, _tx_thread_secure_mode_stack_free, _tx_thread_secure_stack_context_save and _tx_thread_secure_stack_context_restore. Each reads fields of the caller’s thread_ptr without first validating it with cmse_check_address_range() or cmse_check_pointed_object().

_tx_thread_secure_mode_stack_allocate branches on whether thread_ptr → tx_thread_secure_stack_context is zero, so the status it returns reveals whether a chosen secure location holds zero. Because the caller chooses thread_ptr freely, the probed field can be aligned on any address, including unaligned ones, which yields a map of zero bytes rather than only zero words. In the other three functions the dereference is in the variable initialiser, before both the check that the caller is a handler and the index range check, so any non-secure code can reach them from thread mode with no precondition.

The same functions write through thread_ptr. Calling _tx_thread_secure_mode_stack_allocate with thread_ptr set so that its tx_thread_secure_stack_context field overlays a secure word that reads zero stores a small integer there and records thread_ptr as the context’s owner; calling _tx_thread_secure_mode_stack_free with the same pointer then passes its ownership check, because the secure world itself stored that value, and writes zero back. A non-secure caller can thus write a small integer, then zero, to any secure word that currently reads zero. A thread_ptr naming an address that faults raises a secure fault from non-secure input.

The defect is present in every TrustZone-M port that carries these functions: 24 files in 18 distinct variants, covering Cortex-M23, M33, M52, M55 and M85 with the GNU, AC6 and IAR toolchains, including the Cortex-M23 and Cortex-M33 module manager ports.

Impact

An attacker running non-secure code obtains an oracle on secure memory that reveals the position of zero bytes, a primitive shown in published research (A Tale of Two Worlds, CCS 2019) to be sufficient to recover AES keys; a write primitive that sets a chosen zero-valued secure word to a small integer and back to zero, enough to alter a flag, a counter or a pointer; and a denial of service by triggering a secure fault, which on most designs resets or halts the secure world.

Affected configurations

Systems built with a ThreadX TrustZone-M port whose secure image exposes these entry functions to non-secure software (neither TX_SINGLE_MODE_SECURE nor TX_SINGLE_MODE_NON_SECURE defined, and the secure image built with the CMSE extension). Non-TrustZone builds are not affected.

Cortex-M33 (AC6, IAR) from ThreadX 6.0.1; Cortex-M33 (GNU) and Cortex-M23 (all toolchains) from 6.1.1; the Cortex-M33 module manager port from 6.1.5 and the Cortex-M23 module manager port from 6.1.6; Cortex-M55 and Cortex-M85 from 6.1.12; Cortex-M52 in 6.5.2.202603. Affected versions: [6.0.1, 6.5.2.202603], each port from the release that introduced it.

Severity

CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:L/SC:N/SI:N/SA:N, CVSS-B 8.4 (High). CWE-822: Untrusted Pointer Dereference; CWE-200: Exposure of Sensitive Information to an Unauthorized Actor; CWE-501: Trust Boundary Violation.

VC:H for the zero-byte oracle leading to key recovery, VI:H for the write to a chosen secure word, VA:L for the secure fault. Both the flaw and its impact are in the secure firmware, so the subsequent-system metrics are None.

Patches

Fixed in ThreadX 6.5.2.202603b. Each of the four functions now validates thread_ptr with cmse_check_address_range(thread_ptr, sizeof(TX_THREAD), CMSE_NONSECURE | CMSE_MPU_READWRITE) before any access; _tx_thread_secure_mode_stack_allocate and _tx_thread_secure_mode_stack_free return TX_PTR_ERROR, and the context save and restore functions return without acting. The initialiser dereferences now follow the check. The check is compiled whenever the secure image is built with the CMSE extension, which every image exposing these functions requires. The change is made in all 24 files. A regression test on QEMU’s MPS2 AN505 model (Cortex-M33 with TrustZone) shows the oracle and both writes with the original code and none with the fix, while a genuine non-secure thread still allocates, saves, restores and frees its secure stack; reverting the check in any one function fails it. The IAR sources were changed identically but not compiled.

Credits

Reported by the research team from DistriNet, KU Leuven: Tijs Bellefroid, Antonis Louka, Marton Bognar, Jo Van Bulck. Fixed by Frédéric Desbiens.

The fix and regression test were produced with AI assistance under human review, in accordance with the Eclipse Foundation’s Generative AI Usage Guidelines.