GHSA-423V-C2RC-FJ96
Vulnerability from github – Published: 2026-11-25 00:36 – Updated: 2026-11-25 00:36When MCUboot resumes an interrupted image swap it takes the number of bytes to move straight from the flash-resident status trailer. In boot_swap_image() (boot/bootutil/src/loader.c) the fresh-swap branch recomputes copy_size from the image headers and is bounded — swap_run() in boot/bootutil/src/swap_move.c carries an explicit "not enough free space" check (last_idx >= first_trailer_idx) — but that check runs only inside if (boot_status_is_reset(bs)). On the resume branch the code instead does boot_read_swap_size(fap, &bs->swap_size); copy_size = bs->swap_size; and passes the value to swap_run() with no re-derivation and no bound.
swap_run() turns that byte count into a sector index by summing sector sizes until it reaches the count, with no ceiling on the real sector count: find_last_idx() in swap_move.c and swap_offset.c, and find_last_sector_idx() in swap_scratch.c, are all while (1) loops. The resulting index is fed to boot_img_sector_off() / boot_img_sector_size() (boot/bootutil/src/bootutil_priv.h), which index the fixed BOOT_MAX_IMG_SECTORS sectors[] arrays with no bounds check. Past num_sectors the loop reads zero-initialised — and past BOOT_MAX_IMG_SECTORS, adjacent-struct — entries; a sector size of 0 makes the loop never terminate, and a bogus computed offset is handed to boot_erase_region() / boot_copy_region() as an out-of-bounds flash erase or copy.
MCUboot itself only ever writes a validated, slot-bounded swap_size (swap_misc.c, fixup_revert()), so reaching the defect requires writing the trailer from outside. Serial recovery provides exactly that: an upload writes attacker bytes contiguously from offset 0 of the primary slot (boot/boot_serial/src/boot_serial.c, via flash_area_id_from_multi_image_slot()), bounded only by img_size <= area_size, so it controls the whole trailer — magic, swap_info, op/idx/state and swap_size. The resume gate boot_status_is_reset() keys solely on those op/idx/state fields, and boot_find_status() explicitly trusts valid magic as implying valid metadata. A forged in-progress status with an oversized swap_size therefore drives the unbounded walk during swap setup — before the primary image's signature is validated, and serial recovery is unauthenticated by design.
The outcome is an out-of-bounds flash erase or copy, or a non-terminating loop, inside the bootloader: an unbootable or bricked device, with the possibility of bootloader memory corruption. That exceeds what serial recovery is designed to grant, which is only the ability to stage an image that must still pass signature verification.
Exposure requires a swap-based update backend — MCUBOOT_SWAP_USING_MOVE (the default for swap builds), MCUBOOT_SWAP_USING_SCRATCH or MCUBOOT_SWAP_USING_OFFSET; overwrite-only, direct-XIP and RAM-load builds are unaffected — together with MCUBOOT_SERIAL_RECOVERY. Without serial recovery the path is only reachable by an attacker who can already write flash directly, which is outside the threat model.
The fix is to treat the trailer's swap_size as untrusted: reject or clamp it in boot_swap_image() before it becomes copy_size, bounding it by the primary slot's usable image area (sector count x sector size, excluding the trailer) rather than the raw flash_area_get_size(), and aborting recovery with a non-zero error on overflow. The same guard should cover the independent boot_read_swap_size() reads in each backend's boot_read_image_header().
{
"affected": [],
"aliases": [
"CVE-2026-16666"
],
"database_specific": {
"cwe_ids": [
"CWE-129"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-11-25T00:17:11Z",
"severity": "MODERATE"
},
"details": "When MCUboot resumes an interrupted image swap it takes the number of bytes to move straight from the flash-resident status trailer. In boot_swap_image() (boot/bootutil/src/loader.c) the fresh-swap branch recomputes copy_size from the image headers and is bounded \u2014 swap_run() in boot/bootutil/src/swap_move.c carries an explicit \"not enough free space\" check (last_idx \u003e= first_trailer_idx) \u2014 but that check runs only inside if (boot_status_is_reset(bs)). On the resume branch the code instead does boot_read_swap_size(fap, \u0026bs-\u003eswap_size); copy_size = bs-\u003eswap_size; and passes the value to swap_run() with no re-derivation and no bound.\n\nswap_run() turns that byte count into a sector index by summing sector sizes until it reaches the count, with no ceiling on the real sector count: find_last_idx() in swap_move.c and swap_offset.c, and find_last_sector_idx() in swap_scratch.c, are all while (1) loops. The resulting index is fed to boot_img_sector_off() / boot_img_sector_size() (boot/bootutil/src/bootutil_priv.h), which index the fixed BOOT_MAX_IMG_SECTORS sectors[] arrays with no bounds check. Past num_sectors the loop reads zero-initialised \u2014 and past BOOT_MAX_IMG_SECTORS, adjacent-struct \u2014 entries; a sector size of 0 makes the loop never terminate, and a bogus computed offset is handed to boot_erase_region() / boot_copy_region() as an out-of-bounds flash erase or copy.\n\nMCUboot itself only ever writes a validated, slot-bounded swap_size (swap_misc.c, fixup_revert()), so reaching the defect requires writing the trailer from outside. Serial recovery provides exactly that: an upload writes attacker bytes contiguously from offset 0 of the primary slot (boot/boot_serial/src/boot_serial.c, via flash_area_id_from_multi_image_slot()), bounded only by img_size \u003c= area_size, so it controls the whole trailer \u2014 magic, swap_info, op/idx/state and swap_size. The resume gate boot_status_is_reset() keys solely on those op/idx/state fields, and boot_find_status() explicitly trusts valid magic as implying valid metadata. A forged in-progress status with an oversized swap_size therefore drives the unbounded walk during swap setup \u2014 before the primary image\u0027s signature is validated, and serial recovery is unauthenticated by design.\n\nThe outcome is an out-of-bounds flash erase or copy, or a non-terminating loop, inside the bootloader: an unbootable or bricked device, with the possibility of bootloader memory corruption. That exceeds what serial recovery is designed to grant, which is only the ability to stage an image that must still pass signature verification.\n\nExposure requires a swap-based update backend \u2014 MCUBOOT_SWAP_USING_MOVE (the default for swap builds), MCUBOOT_SWAP_USING_SCRATCH or MCUBOOT_SWAP_USING_OFFSET; overwrite-only, direct-XIP and RAM-load builds are unaffected \u2014 together with MCUBOOT_SERIAL_RECOVERY. Without serial recovery the path is only reachable by an attacker who can already write flash directly, which is outside the threat model.\n\nThe fix is to treat the trailer\u0027s swap_size as untrusted: reject or clamp it in boot_swap_image() before it becomes copy_size, bounding it by the primary slot\u0027s usable image area (sector count x sector size, excluding the trailer) rather than the raw flash_area_get_size(), and aborting recovery with a non-zero error on overflow. The same guard should cover the independent boot_read_swap_size() reads in each backend\u0027s boot_read_image_header().",
"id": "GHSA-423v-c2rc-fj96",
"modified": "2026-11-25T00:36:26Z",
"published": "2026-11-25T00:36:26Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/mcu-tools/mcuboot/security/advisories/GHSA-ggxc-7xvp-98v3"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-16666"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:H",
"type": "CVSS_V3"
}
]
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.