Обработчик MCUboot bs_upload() в boot/boot_serial/src/boot_serial.c объявляет const struct flash_area *fap NULL и назначает его только через flash_area_open() частично через функцию. Две ранние ошибки проверки (goto out_invalid_data) — карта CBOR, которая не декодируется, или пакет загрузки, в котором отсутствуют члены выключенных / данных, — ветвятся мимо открытого, в то время как fap все еще NULL, а затем попадают в общий эпилог. В MCUBOOT_ENC_IMAGES построен этот эпилог, безусловно называемый boot_handle_enc_fw(fap), который достигает boot_image_load_header() и flash_area_read() и отсылает NULL flash_area.
Дефект доступен для предварительной аутентификации: триггер является самой первой командой загрузки с последовательным восстановлением, несущей деформированную полезную нагрузку. Условия защиты по умолчанию верны на новом сеансе восстановления — img_num, curr_off и img_size являются статиками с нулевой инициализацией, поэтому curr_off img_size и тест с первичным слотом поддерживаются. Требуется сборка без дефолта: зашифрованные изображения (MCUBOOT_ENC_IMAGES / Zephyr CONFIG_BOOT_ENCRYPT_IMAGE) вместе с активным транспортом последовательного восстановления на порту Zephyr или Mynewt (два, которые строят оба boot/boot_serial/src/boot_serial.c и boot_serial_encryption.c с MCUBOOT_ENC_IMAGES).
Воздействие является временным отказом в обслуживании загрузчика во время восстановления. fap является жестким значением NULL, а не контролируемым злоумышленником, поэтому нет коррупции памяти или примитивной утечки информации, а аутентификация изображения не затрагивается. Независимо от того, зависят ли ошибки удаления от платформы — для целей, где адрес 0x0 отображается читаемой вспышкой, чтение просто возвращает ошибку, и выполнение продолжается, в то время как цели, которые ловят обнаружение NULL (MPU / null-pointer-exception), принимают жесткую ошибку. Поскольку последовательное восстановление не аутентифицировано по дизайну и уже позволяет консольному злоумышленнику писать вторичный слот, добавленная возможность представляет собой только малозначимый переходный сбой.
Связанный с ним безусловный вызов flash_area_close(fap) в том же эпилоге является безопасным no-op на портах, которые до него доходят, поэтому он не способствует дереференции. Затронутыми портами являются порт Zephyr — boot/zephyr/CMakeLists.txt компилирует boot_serial.c под CONFIG_MCUBOOT_SERIAL и boot_serial_encryption.c под CONFIG_BOOT_ENCRYPT_IMAGE — и порт Mynewt, чей mcuboot_config.h безоговорочно определяет MCUBOOT_SERIAL и MCUBOOT_ENC_IMAGES под любым BOOTUTIL_ENCRYPT_ syscfg, а boot/boot_serial/pkg.yml не объявляет явный список источников, поэтому весь каталог построен. Порт Espressif не затронут**: он компилирует boot_serial.c, но не boot_serial_encryption.c, и не определяет MCUBOOT_ENC_IMAGES, поэтому блок ifdef MCUBOOT_ENC_IMAGES, содержащий вызов, предварительно обрабатывается.
Порты NuttX, Cypress и Mbed вообще не строят boot_serial.c.
Показать оригинальное описание (EN)
MCUboot's serial-recovery image-upload handler bs_upload() in boot/boot_serial/src/boot_serial.c declares const struct flash_area *fap = NULL and assigns it only via flash_area_open() part-way through the function. Two early validation failures (goto out_invalid_data) — a CBOR map that fails to decode, or an upload packet missing the off/data members — branch past the open while fap is still NULL, then fall into the shared epilogue. In MCUBOOT_ENC_IMAGES builds that epilogue unconditionally calls boot_handle_enc_fw(fap), which reaches boot_image_load_header() and flash_area_read() and dereferences the NULL flash_area. The defect is reachable pre-authentication: the trigger is the very first serial-recovery upload command carrying a malformed payload. The guarding conditions are default-true on a fresh recovery session — img_num, curr_off and img_size are zero-initialized statics, so curr_off == img_size and the primary-slot test both hold. It requires a non-default build: encrypted images (MCUBOOT_ENC_IMAGES / Zephyr CONFIG_BOOT_ENCRYPT_IMAGE) together with an active serial-recovery transport, on the Zephyr or Mynewt port (the two that build both boot/boot_serial/src/boot_serial.c and boot_serial_encryption.c with MCUBOOT_ENC_IMAGES). The impact is a transient denial of service of the bootloader during recovery. fap is a hard NULL rather than an attacker-controlled value, so there is no memory-corruption or information-leak primitive and image authentication is unaffected. Whether the dereference faults is platform-dependent — on targets where address 0x0 is mapped readable flash the read merely returns an error and execution continues, while targets that trap NULL (MPU / null-pointer-exception detection) take a hard fault. Because serial recovery is unauthenticated by design and already permits the console attacker to write the secondary slot, the added capability is only a low-value transient crash. The related unconditional flash_area_close(fap) call in the same epilogue is a safe no-op on the ports that reach it, so it does not contribute to the dereference. The affected ports are the Zephyr port — boot/zephyr/CMakeLists.txt compiles boot_serial.c under CONFIG_MCUBOOT_SERIAL and boot_serial_encryption.c under CONFIG_BOOT_ENCRYPT_IMAGE — and the Mynewt port, whose mcuboot_config.h defines MCUBOOT_SERIAL unconditionally and MCUBOOT_ENC_IMAGES under any BOOTUTIL_ENCRYPT_ syscfg, with boot/boot_serial/pkg.yml declaring no explicit source list so the whole directory is built. The Espressif port is not affected**: it compiles boot_serial.c but not boot_serial_encryption.c, and defines no MCUBOOT_ENC_IMAGES, so the #ifdef MCUBOOT_ENC_IMAGES block containing the call is preprocessed away. The NuttX, Cypress and Mbed ports do not build boot_serial.c at all.
Характеристики атаки
Последствия
Строка CVSS v3.1