CVE-2026-16669 in MCUboot
Summary
by MITRE • 11/25/2026
MCUboot's Espressif port omits zeroization of two sensitive stack buffers in boot/espressif/hal/src/flash_encrypt.c. In check_and_generate_encryption_keys(), the freshly generated XTS-AES flash-encryption key is held in the stack array keys[BLOCKS_NEEDED][32] (flash_encrypt.c:216), written to eFuse via esp_efuse_write_keys(), and the function returns (flash_encrypt.c:243) without scrubbing it. In esp_flash_encrypt_region(), the plaintext flash sector buffer buf (flash_encrypt.c:454) retains the last sector's cleartext at both the success and flash_failed returns. Neither path performs a memset/bzero/mbedtls_platform_zeroize, even though the same port already does bzero for key digests in boot/espressif/hal/src/secure_boot.c.
The affected code runs only on the Espressif port with CONFIG_SECURE_FLASH_ENC_ENABLED, and only during the one-time first-boot provisioning pass when flash encryption is not yet enabled (boot/espressif/main.c); on subsequent boots the buffers are never created. Recovering the residue requires an out-of-band stack/RAM-disclosure primitive — JTAG/debug halt, UART ROM download, a core/crash dump, or a warm-boot RAM scrape — captured during that single provisioning boot. Under the recommended CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE plus secure boot, those channels are fused off and no exposure exists.
The practical impact is a low-severity, defense-in-depth hardening gap: a flash-encryption key (and last plaintext sector) may linger in bootloader stack memory. Because the eFuse key block is burned read+write-protected, the transient stack copy is the only readable copy, and only during one boot; in a development build where a disclosure channel is open, an attacker with that capability can usually already read the still-plaintext flash directly, so the marginal confidentiality gain is small. Confirming real-world recovery depends on a specific SoC/debug configuration not exercisable from source alone.
If you want to get best quality of vulnerability data, you may have to visit VulDB.
Analysis
by VulDB Data Team • 11/25/2026
The vulnerability identified in MCUboot's Espressif port represents a critical failure in secure memory management practices during the initialization of hardware-level encryption features. Specifically, two sensitive stack buffers are left unscrubbed after their contents have been utilized for cryptographic operations and eFuse programming. The first instance occurs within the check_and_generate_encryption_keys function, where an XTS-AES flash-encryption key is generated and stored in a local array before being written to the device's eFuses via esp_efuse_write_keys. Upon completion of this operation, the function returns without performing any zeroization of the stack memory containing the plaintext key material. Similarly, within the esp_flash_encrypt_region function, a buffer used for holding plaintext flash sector data retains its contents after both successful execution paths and error conditions involving flash failures. This lack of explicit memory clearing means that sensitive cryptographic secrets and potentially unencrypted user data remain resident in volatile RAM until overwritten by subsequent stack allocations or system resets.
This behavior constitutes a clear violation of established secure coding standards, most notably aligning with CWE-14: Compiler Removal of Code to Clear Buffers if compiler optimizations inadvertently strip explicit zeroization calls, though more directly mapping to CWE-226: Sensitive Information Not Removed Before Storage and CWE-358: Improperly Implemented Security Check for Credentials. The absence of memory scrubbing contradicts the principle that sensitive data must be explicitly destroyed immediately after use to prevent information leakage through side channels or physical access attacks. While other parts of the Espressif HAL, such as secure_boot.c, correctly implement bzero operations for key digests, this inconsistency highlights a gap in security hygiene within the flash encryption module. The failure to utilize robust zeroization functions like mbedtls_platform_zeroize leaves residual data that could theoretically be extracted by an attacker with physical access or debug privileges.
The operational impact of this vulnerability is constrained by specific environmental and configuration factors, resulting in what can be classified as a low-severity risk under standard deployment conditions. The affected code paths are exclusively executed during the one-time first-boot provisioning phase when flash encryption is not yet enabled. Furthermore, the practical exploitation requires an out-of-band disclosure primitive to access the stack memory residue. Potential vectors include JTAG debug halt capabilities, UART ROM download exploits, core crash dumps, or warm-boot RAM scraping techniques. In a properly secured production environment where CONFIG_SECURE_FLASH_ENCRYPTION_MODE_RELEASE and secure boot are enabled, these physical and logical attack channels are typically fused off or restricted by hardware security modules, thereby mitigating the risk of key extraction from stack memory.
However, in development builds or devices with debug interfaces left active, an attacker possessing the ability to halt execution or read RAM could potentially recover the transient copy of the flash-encryption key or plaintext sector data. It is important to note that if an attacker already has access sufficient to perform these low-level hardware attacks, they may also be able to read the still-unencrypted flash memory directly, which diminishes the marginal confidentiality gain from recovering this specific stack residue. Nevertheless, relying on the assumption that physical attack vectors are always blocked is a defense-in-depth failure. The presence of sensitive keys in unprotected RAM violates the principle of least privilege and minimal exposure time for cryptographic material.
To remediate this vulnerability, developers must ensure that all buffers containing sensitive cryptographic data or plaintext information are explicitly zeroized immediately after their use. This involves replacing standard return paths with calls to secure memory clearing functions such as mbedtls_platform_zeroize or equivalent platform-specific implementations that prevent compiler optimization from removing the clear operation. Additionally, integrating static analysis tools configured to detect CWE-14 and CWE-226 patterns can help identify similar oversights in other parts of the bootloader codebase. Ensuring consistent application of these hardening measures across all security-sensitive modules is essential for maintaining a robust security posture against physical extraction attacks during device provisioning phases.