CVE-2024-28183: Insufficient Information (NVD-CWE-noinfo)
value: ESP-IDF is the development framework for Espressif SoCs supported on Windows, Linux and macOS. A Time-of-Check to Time-of-Use (TOCTOU) vulnerability was discovered in the implementation of the ESP-IDF bootloader which could allow an attacker with physical access to flash of the device to bypass anti-rollback protection. Anti-rollback prevents rollback to application with security version lower than one programmed in eFuse of chip. This attack can allow to boot past (passive) application partition having lower security version of the same device even in the presence of the flash encryption scheme. The attack requires carefully modifying the flash contents after the anti-rollback checks have been performed by the bootloader (before loading the application). The vulnerability is fixed in 4.4.7 and 5.2.1.
CWE description: There is insufficient information about the issue to classify it; details are unkown or unspecified.
Published: 2024-03-25T15:15Z
Repository: https://github.com/espressif/esp-idf
Language: C
Files changed: components/bootloader_support/src/esp_image_format.c
Commit date: 2024-02-19 14:54:17 +0530
Commit message: fix(bootloader_support): check the secure version only for app image

Secure version in the image header is only available for the application
image. However, for certain security workflows, bootloader verifies
itself (own image) and hence the secure version check during that must be
avoided.

Regression introduced in recent commit-id: 3305cb4d

Tested that both secure boot and flash-enc workflows work correctly
with the anti-rollback scenario.

Diff: diff --git a/components/bootloader_support/src/esp_image_format.c b/components/bootloader_support/src/esp_image_format.c
index 9016ae296d..0a26247b56 100644
--- a/components/bootloader_support/src/esp_image_format.c
+++ b/components/bootloader_support/src/esp_image_format.c
@@ -686,16 +686,20 @@ static esp_err_t process_segment_data(int segment, intptr_t load_addr, uint32_t
         ram_obfs_value[0] ^= 0x33;
         ram_obfs_value[1] ^= 0x66;
 #endif
     }
     uint32_t *dest = (uint32_t *)load_addr;
-#endif
+#endif // BOOTLOADER_BUILD
 
     const uint32_t *src = data;
 
 #if CONFIG_BOOTLOADER_APP_ANTI_ROLLBACK
-    if (segment == 0) {
+    // Case I: Bootloader verifying application
+    // Case II: Bootloader verifying bootloader
+    // Anti-rollback check should handle only Case I from above.
+    if (segment == 0 && metadata->start_addr != ESP_BOOTLOADER_OFFSET) {
+        ESP_LOGD(TAG, "additional anti-rollback check 0x%"PRIx32, data_addr);
         // The esp_app_desc_t structure is located in DROM and is always in segment #0.
         size_t len = process_esp_app_desc_data(src, sha_handle, checksum, metadata);
         data_len -= len;
         src += len / 4;
         // In BOOTLOADER_BUILD, for DROM (segment #0) we do not load it into dest (only map it), do_load = false.

Vulnerable code: #endif
    if (segment == 0) {
Fixed code: #endif // BOOTLOADER_BUILD
    // Case I: Bootloader verifying application
    // Case II: Bootloader verifying bootloader
    // Anti-rollback check should handle only Case I from above.
    if (segment == 0 && metadata->start_addr != ESP_BOOTLOADER_OFFSET) {
        ESP_LOGD(TAG, "additional anti-rollback check 0x%"PRIx32, data_addr);