CVE-2026-16666: MCUboot swap resume trusts a flash-resident swap_size, allowing pre-authentication out-of-bounds flash operations

Published Nov 24, 2026
·
Updated

When MCUboot resumes an interrupted image swap it takes the number of bytes to move straight from the flash-resident status trailer. In bootswapimage() (boot/bootutil/src/loader.c) the fresh-swap branch recomputes copysize from the image headers and is bounded — swaprun() in boot/bootutil/src/swapmove.c carries an explicit "not enough free space" check (lastidx >= firsttraileridx) — but that check runs only inside if (bootstatusisreset(bs)). On the resume branch the code instead does bootreadswapsize(fap, &bs->swapsize); copysize = bs->swapsize; and passes the value to swaprun() with no re-derivation and no bound.

swaprun() 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: findlastidx() in swapmove.c and swapoffset.c, and findlastsectoridx() in swapscratch.c, are all while (1) loops. The resulting index is fed to bootimgsectoroff() / bootimgsectorsize() (boot/bootutil/src/bootutilpriv.h), which index the fixed BOOTMAXIMGSECTORS sectors[] arrays with no bounds check. Past numsectors the loop reads zero-initialised — and past BOOTMAXIMGSECTORS, adjacent-struct — entries; a sector size of 0 makes the loop never terminate, and a bogus computed offset is handed to booteraseregion() / bootcopyregion() as an out-of-bounds flash erase or copy.

MCUboot itself only ever writes a validated, slot-bounded swapsize (swapmisc.c, fixuprevert()), 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/bootserial/src/bootserial.c, via flashareaidfrommultiimageslot()), bounded only by imgsize <= areasize, so it controls the whole trailer — magic, swapinfo, op/idx/state and swapsize. The resume gate bootstatusisreset() keys solely on those op/idx/state fields, and bootfindstatus() explicitly trusts valid magic as implying valid metadata. A forged in-progress status with an oversized swapsize 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 — MCUBOOTSWAPUSINGMOVE (the default for swap builds), MCUBOOTSWAPUSINGSCRATCH or MCUBOOTSWAPUSINGOFFSET; overwrite-only, direct-XIP and RAM-load builds are unaffected — together with MCUBOOTSERIALRECOVERY. 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 swapsize as untrusted: reject or clamp it in bootswapimage() before it becomes copysize, bounding it by the primary slot's usable image area (sector count x sector size, excluding the trailer) rather than the raw flashareagetsize(), and aborting recovery with a non-zero error on overflow. The same guard should cover the independent bootreadswapsize() reads in each backend's bootreadimageheader().

Affected Software

1 affected component
MCUboot MCUboot

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Compensating control

    Treat trailer swap_size as untrusted: in boot_swap_image(), reject or clamp it before assigning copy_size, bounding it by the primary slot’s usable image area (sector count × sector size, excluding the trailer), and abort recovery with a non-zero error on overflow. Apply the same bound to the independent boot_read_swap_size() reads in each backend’s boot_read_image_header().

Event History

Nov 24, 2026
CVE Published
via MITRE·11:37 PM
Data Sourced
via MITRE·11:37 PM
DescriptionSeverityWeakness
Nov 25, 2026
Data Sourced
via NVD·12:17 AM
DescriptionSeverityWeakness

Frequently Asked Questions

1

When is the affected code path reached?

It is reached when MCUboot resumes an interrupted image swap. The resume branch reads swap_size from the flash-resident status trailer instead of recomputing a bounded copy size from image headers.

2

What access does an attacker need?

The supplied vector rates the issue as local attack vector, high attack complexity, with no privileges or user interaction required. Exploitation depends on influencing the flash-resident swap status so that a resumed swap uses an unsafe swap_size value.

3

What is the practical impact of a malformed swap_size?

An oversized value can drive sector-index calculations beyond the actual image sector count and beyond the fixed sectors[] array bounds. This can cause out-of-bounds flash operations before image authentication, with integrity and availability impact indicated by the supplied vector.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203