Cypress/PSoC6 flash-map backend в boot/cypress/cy_flash_pal/cy_flash_map.c защищает каждый флэш-доступ с assert() против неправильного поля struct. flash_area_read(), flash_area_write(), и flash_area_erase() проверить assert(off < fa->fa_off) и assert(off + len < fa->fa_off), сравнивая область-относительный против абсолютного базового адреса раздела fa->fa_off вместо его длины fa->fa_size. Поскольку fa_off является большим абсолютным адресом, реалистичные смещения out-of-partition проходят проверку даже в отладочной сборке, а в NDEBUG утверждения полностью удаляются. Затем доступ продолжается как memcpy () (или флэш-строка op) в fa->fa_off + выключен без принудительного исполнения.
Ядро MCUboot не связывает область изображения; оно полагается на flash_area_read (), возвращая ошибку. Во время предварительной проверки аутентификации изображения bootutil_img_hash () в boot/bootutil/src/bootutil_img_hash.c циклы над ih_hdr_size + ih_img_size + ih_protect_tlv_size - все контролируемые злоумышленником поля заголовка все еще непроверенного изображения обновления - вызывает flash_area_read (), а итератор TLV в boot/bootutil/src/tlv.c читает смещение, полученное злоумышленником, таким же образом. Злоумышленник, который может создать изображение во вторичном / обновленном слоте (через OTA, DFU или последовательное восстановление, в зависимости от продукта), объявляет негабаритный ih_img_size, вызывая чтение далеко за пределами раздела.
Правильный бэкэнд отклоняет их и не проходит проверку чисто; бэкэнд Cypress этого не делает. Доступ out-of-bounds находится в исходном адресе копии — буфер назначения имеет правильный размер, поэтому нет повреждения памяти, нет раскрытия информации злоумышленнику (данные складываются только в хэш, который все еще не проходит проверку подписи), и нет обхода аутентификации. Реалистичным воздействием является ошибка шины или зависание, когда вычисленный абсолютный адрес попадает на неотображенную или периферийную область адресной карты PSoC6: загрузчик выходит из строя вместо того, чтобы отклонить плохое изображение, воздействие доступности (denial-of-service).
Дефект специфичен для порта Cypress/PSoC6; основные серверы Zephyr/sim/mynewt не затронуты. Идентичный сломанный охранник в примитивах записи / стирания - это латентный разрыв out-of-bounds-write, но не было обнаружено смещения out-of-bounds, контролируемого злоумышленником (загрузка последовательного восстановления ограничена ядром), поэтому достижимая ошибка безопасности памяти - чтение out-of-bounds.
Показать оригинальное описание (EN)
The Cypress/PSoC6 flash-map backend in boot/cypress/cy_flash_pal/cy_flash_map.c guards every flash access with assert() against the wrong struct field. flash_area_read(), flash_area_write(), and flash_area_erase() check assert(off < fa->fa_off) and assert(off + len < fa->fa_off), comparing the area-relative off against the partition's absolute base address fa->fa_off instead of its length fa->fa_size. Because fa_off is a large absolute address, realistic out-of-partition offsets pass the check even in a debug build, and under NDEBUG the asserts are removed entirely. The access then proceeds as memcpy() (or a flash row op) at fa->fa_off + off with no enforcement. The MCUboot core does not bound image-region offsets itself; it relies on flash_area_read() returning an error. During pre-authentication image validation, bootutil_img_hash() in boot/bootutil/src/bootutil_img_hash.c loops over ih_hdr_size + ih_img_size + ih_protect_tlv_size — all attacker-controlled header fields of the still-unverified update image — calling flash_area_read(), and the TLV iterator in boot/bootutil/src/tlv.c reads attacker-derived offsets the same way. An attacker who can stage a crafted image in the secondary/update slot (via OTA, DFU, or serial recovery, depending on the product) declares an oversized ih_img_size, causing reads far past the partition. A correct backend would reject these and fail validation cleanly; the Cypress backend does not. The out-of-bounds access is in the source address of the copy — the destination buffer is correctly sized — so there is no memory corruption, no information disclosure to the attacker (the data is only folded into a hash that still fails the signature check), and no authentication bypass. The realistic impact is a bus fault or hang when the computed absolute address lands on an unmapped or peripheral region of the PSoC6 address map: the bootloader crashes instead of rejecting the bad image, an availability (denial-of-service) impact. The defect is specific to the Cypress/PSoC6 port; mainline Zephyr/sim/mynewt backends are unaffected. The identical broken guard in the write/erase primitives is a latent out-of-bounds-write gap, but no attacker-controlled out-of-bounds offset was found to reach those (serial-recovery uploads are bounded by the core), so the reachable memory-safety bug is the out-of-bounds read.
Характеристики атаки
Последствия
Строка CVSS v3.1