The vulnerability stems from an incorrect error-checking logic in the CreateCounter() function (in…
eclipse·CWE-253·Published 2026-01-27
The vulnerability stems from an incorrect error-checking logic in the CreateCounter() function (in threadx/utility/rtos_compatibility_layers/OSEK/tx_osek.c) when handling the return value of osek_get_counter(). Specifically, the current code checks if cntr_id equals 0u to determine failure, but @osek_get_counter() actually returns E_OS_SYS_STACK (defined as 12U) when it fails. This mismatch causes the error branch to never execute even when the counter pool is exhausted. As a result, when the counter pool is depleted, the code proceeds to cast the error code (12U) to a pointer (OSEK_COUNTER *), creating a wild pointer. Subsequent writes to members of this pointer lead to writes to illegal memory addresses (e.g., 0x0000000C), which can trigger immediate HardFaults or silent memory corruption. This vulnerability poses significant risks, including potential denial-of-service attacks (via repeated calls to exhaust the counter pool) and unauthorized memory access.
The vulnerability stems from an incorrect error-checking logic in the CreateCounter() function (in threadx/utility/rtos_compatibility_layers/OSEK/tx_osek.c) when handling the return value of osek_get_counter(). Specifically, the current code checks if cntr_id equals 0u to determine failure, but @osek_get_counter() actually returns E_OS_SYS_STACK (defined as 12U) when it fails. This mismatch causes the error branch to never execute even when the counter pool is exhausted. As a result, when the counter pool is depleted, the code proceeds to cast the error code (12U) to a pointer (OSEK_COUNTER *), creating a wild pointer. Subsequent writes to members of this pointer lead to writes to illegal memory addresses (e.g., 0x0000000C), which can trigger immediate HardFaults or silent memory corruption. This vulnerability poses significant risks, including potential denial-of-service attacks (via repeated calls to exhaust the counter pool) and unauthorized memory access.
La vulnerabilidad se deriva de una lógica incorrecta de comprobación de errores en la función CreateCounter() (en threadx/utility/rtos_compatibility_layers/OSEK/tx_osek.c) al manejar el valor de retorno de osek_get_counter(). Específicamente, el código actual comprueba si cntr_id es igual a 0u para determinar un fallo, pero @osek_get_counter() en realidad devuelve E_OS_SYS_STACK (definido como 12U) cuando falla. Esta discrepancia hace que la rama de error nunca se ejecute, incluso cuando el pool de contadores está agotado. Como resultado, cuando el pool de contadores se agota, el código procede a convertir el código de error (12U) a un puntero (OSEK_COUNTER *), creando un puntero salvaje. Las escrituras posteriores a miembros de este puntero conducen a escrituras en direcciones de memoria ilegales (por ejemplo, 0x0000000C), lo que puede desencadenar HardFaults inmediatos o corrupción de memoria silenciosa. Esta vulnerabilidad plantea riesgos significativos, incluyendo posibles ataques de denegación de servicio (mediante llamadas repetidas para agotar el pool de contadores) y acceso no autorizado a la memoria.
| Version | Type | Source | Base | Exp | Impact | Vector |
|---|---|---|---|---|---|---|
| 3.1 | Primary | cve.org | 7.8 | — | — | CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H |
| 3.1 | Primary | NVD | 6.3 | 1.0 | 5.2 | CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:N/A:H |
| 3.1 | Secondary | NVD | 7.8 | 1.1 | 6.0 | CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:H |