/

CVE-2026-45328

Severity:

CRITICAL RISK

(9.3)

Input Validation Flaws (CWE-20) in ESP-IDF TEE Services

CVE-2026-45328

Analyzed

Vulnerability type

Category:

Improper Input Validation

CWE:

CWE-20, CWE-787

Impact:

Privilege Escalation and Secure Hardware Misuse

Severity:

CRITICAL RISK

(9.3)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Certain secure-service wrappers in the ESP-IDF esp_tee component insufficiently validate requests crossing from the Rich Execution Environment (REE) into TEE-protected peripherals and security features.

Under specific conditions, malformed or unexpected inputs can drive protected hardware blocks or services in unsafe ways, potentially leading to privilege escalation, data compromise, or device takeover.

Affected context

The vulnerability arises in ESP-IDF projects that rely on the esp_tee component to access TEE-protected hardware peripherals and security features via esp_secure_services.c and esp_secure_services_iram.c.

It is most relevant where untrusted or partially trusted application code in the REE can invoke these secure-service wrappers without additional mediation, or where the trust boundary between normal-world firmware and TEE calls is not narrowly scoped.

Actual impact depends on how the application exposes these capabilities (for example, through network endpoints, IPC, or plugin modules) and what security assumptions are made about code running in the REE.

Exploit preconditions

  • Attack surface: Interfaces in the Rich Execution Environment that ultimately invoke esp_secure_services TEE wrappers (e.g., driver APIs, IPC handlers, or remotely reachable services).
  • Required access: Ability to execute or influence REE-side code that calls into the esp_tee secure-service functions, such as compromising application logic, abusing APIs, or controlling input parameters.
  • Trigger point: Invocation of TEE service wrappers with crafted or out-of-spec arguments that the esp_secure_services layer does not rigorously validate.
  • Why exploitation is possible: The boundary between REE and TEE relies on wrapper functions that insufficiently validate parameters and state, allowing malformed inputs to reach privileged hardware peripherals or sensitive security routines.

Why this happens

This issue stems from improper validation of inputs at a critical trust boundary between the non-secure REE and the trusted execution environment services.

Secure-service wrappers are responsible for checking lengths, ranges, pointers, and allowed operations before passing requests into privileged hardware blocks such as AES, SHA, ECC, HMAC, SPI, MMU, and WDT, as well as security features like attestation, OTA, and secure storage.

When these wrappers assume that REE inputs are well-formed or trustworthy, they may forward unexpected parameters or buffer specifications into low-level routines, mapping to CWE-20 (Improper Input Validation) and opening the door to memory mismanagement patterns associated with CWE-787 (Out-of-bounds Write).

Abstractly, the insecure pattern is: treating boundary-crossing calls from less-trusted code as trusted, without enforcing strict argument validation, bounds checking, and state verification before performing privileged operations.

Potential impact

  • Attackers may abuse TEE-protected cryptographic engines (AES, SHA, ECC, HMAC) to perform unauthorized operations or manipulate keys and cryptographic workflows.
  • Malicious inputs could cause out-of-bounds memory accesses in secure-service code paths, potentially leading to code execution or corruption of critical state.
  • TEE-backed security features like attestation, secure storage, or OTA update mechanisms could be misused to bypass integrity checks or exfiltrate sensitive data.
  • Device-level privilege escalation may occur, enabling takeover of the system, disabling watchdogs, or altering MMU settings to weaken isolation.
  • Compromise of one device could be leveraged as a foothold to attack a broader IoT deployment if shared keys or update channels are affected.

General mitigation guidance

Effective mitigation focuses on hardening the REE-to-TEE boundary and treating all cross-world inputs as untrusted:

  • Apply strict input validation in secure-service wrappers, including bounds checking on buffers, pointer validation, operation whitelists, and argument range enforcement before touching hardware peripherals.
  • Enforce clear trust boundaries so that only well-defined, minimal, and authenticated APIs in the REE can invoke esp_tee services, rather than exposing low-level wrappers broadly.
  • Use defensive coding patterns around TEE interfaces, such as validating state transitions, limiting side effects for each call, and rejecting unexpected or unsupported parameter combinations by default.
  • Minimize privileges of REE components that can reach secure services, reducing the number of code paths that can generate TEE calls and constraining the damage if one path is compromised.
  • Centralize security-critical logic (attestation, key management, OTA control) in hardened modules, so application-level code cannot directly orchestrate complex sequences of TEE operations without policy checks.

How teams detect issues like this

Organizations can pursue several high-level strategies to discover similar weaknesses:

  • Employ static analysis to flag functions that cross from REE to TEE or other privileged layers where input validation is missing, incomplete, or dependent on caller-side checks.
  • During code review, treat esp_secure_services and similar boundary modules as high-risk: reviewers should verify that all external parameters are validated, that error handling is strict, and that no direct access to hardware registers or sensitive services occurs without prior checks.
  • Introduce coding guidelines and linting rules requiring centralized validation logic for TEE calls, and prohibit bypass patterns where raw user-controlled buffers or numeric parameters are forwarded to privileged routines.
  • Use dynamic testing and fuzzing targeted at the REE APIs that map into esp_tee services, focusing on malformed sizes, unexpected sequences of operations, and boundary-condition inputs.
  • Integrate automated security review tools into CI pipelines to flag changes touching TEE interfaces, secure storage, OTA, and cryptographic services for mandatory security sign-off.

Sources

SourceLink
github.comgithub.com/espressif/esp-idf/commit/145ba4c42dc8283054cfde9a1c3470db7399192f
github.comgithub.com/espressif/esp-idf/commit/440a5d1906502023f2a0fb0aecbdf0602d14acbf
github.comgithub.com/espressif/esp-idf/commit/764626a1b7c85b943d207da08a2f8f7d7f3def4d
github.comgithub.com/espressif/esp-idf/commit/7867f4a57560bf9fc4a931e37ba02b7a3e9f406b
github.comgithub.com/espressif/esp-idf/commit/afd14ab113acd0ca369965404c99ac42e74d4fcd
github.comgithub.com/espressif/esp-idf/commit/eebabaff2fdc273b1530fe66e55fb3bcd181dfd6
github.comgithub.com/espressif/esp-idf/security/advisories/GHSA-mmgp-73p4-92xp

Frequently asked

questions

Exploitability depends on how the firmware exposes esp_tee services; if untrusted data or remotely reachable interfaces can influence parameters to secure-service wrappers, the vulnerability can be remotely exploitable and affect many deployed devices.

Not necessarily. Physical access is not a strict requirement if the attacker can control or compromise REE-side interfaces such as network services, IPC endpoints, or extensible application modules that invoke TEE services.

The safest pattern is to treat all REE-to-TEE calls as untrusted, perform comprehensive validation of all arguments within the secure-service layer itself, and reject any call that does not strictly match expected sizes, types, and operation sequences before interacting with hardware or sensitive security features.

Future designs should define explicit security boundaries, centralize TEE access through a minimal and audited API, enforce least privilege on REE components that can reach it, and mandate security-focused reviews, static checks, and fuzzing for all code that mediates access to cryptographic engines, secure storage, and OTA mechanisms.

Find out what's already
exploitable in your codebase.