{"id":"CVE-2026-16665","summary":"MCUboot uses assert() as a security guard on the boot/swap/validation path; under NDEBUG (release builds) these checks are compiled out, so an inconsistent/attacker-influenced swap status is not aborted and the swap completes on bad state","details":"Summary\n\nMCUboot enforces several security-critical invariants on the boot, image-swap, and validation paths using assert(). In a standard release/production build (NDEBUG defined) assert() expands to a no-op, so an invariant the code intends to halt on instead falls through, and execution continues with the bad or inconsistent state. Where the guarded condition is attacker-influenceable through the flash-write boundary (serial-recovery / DFU), this is a security check that is simply absent in release builds.\n\nThis is one root cause (assert-as-security-guard, no-op under NDEBUG) with one fix approach (replace the security-critical asserts with real fail-closed checks), so it is filed as a single advisory covering the enumerated sites.\n\nWorst reachable instance — inconsistent swap status completes the swap without validation\n\nIn the swap-resume status read, an inconsistent status (erased_sections \u003e 1) is detected, logged, and — when MCUBOOT_VALIDATE_PRIMARY_SLOT is disabled — is meant to abort, because \"there is no way to be sure the swapped primary slot is OK.\" The abort is assert(0):\n\nboot/bootutil/src/swap_move.c:181-194 — if (erased_sections \u003e 1) { ... #if !defined(MCUBOOT_VALIDATE_PRIMARY_SLOT) / ... abort! / assert(0); #endif }, then execution falls through to compute bs-\u003eop/idx/state from the inconsistent status (lines 197-208) and return 0 (success).\nboot/bootutil/src/swap_offset.c:266-280 — identical pattern; falls through to bs-\u003eop/idx/state and return 0.\nboot/bootutil/src/swap_scratch.c:227-241 — same invalid/assert(0) pattern for the scratch backend.\n\nUnder NDEBUG with primary-slot validation off, the inconsistent status is neither aborted (assert is a no-op) nor re-validated (validation off), so boot_complete_partial_swap() finishes the swap on inconsistent metadata and the primary slot is booted without a signature check. An attacker who can write the swap-status trailer can craft the inconsistent status.\n\nReachability (threat model). Secondary slot + scratch trailers are A2-writable by definition (that is what a DFU upload is). Under MCUBOOT_SERIAL_RECOVERY the primary trailer is A2-writable too: boot/boot_serial/src/boot_serial.c:978 opens flash_area_id_from_multi_image_slot(img_num, 0) (== primary) and writes from offset 0 bounded by area_size, so it can paint the primary swap-status/magic. This is how the A2 (recovery/DFU, unauthenticated by design) attacker influences the guarded condition. Property violated: P1 (image authenticity / secure-boot bypass) when un-revalidated content is booted, and P6 (boot/recovery availability).\n\nSecond reachable instance — resume-path swap_size from an unguarded trailer\n\nboot/bootutil/src/loader.c:1190-1193: the swap resume branch does fap = boot_find_status(...); assert(fap != NULL); rc = boot_read_swap_size(fap, &bs-\u003eswap_size); assert(rc == 0);. boot_find_status() (boot/bootutil/src/bootutil_misc.c:166-204) searches {scratch, primary} and, on no-valid-magic-match, returns the last-iterated area (primary), not NULL — so assert(fap != NULL) cannot fire even in debug, and under NDEBUG neither assert fires. swap_size is then read from an A2-writable (serial-recovery primary, or scratch) trailer with no fail-closed handling. This is the same swap-metadata-trust family as the recorded resume/swap_size disclosure.\n\nReachable-security sites (center the fix here)\n\n1. boot/bootutil/src/swap_move.c:193 — inconsistent-status assert(0), falls through to complete swap. A2 + !VALIDATE_PRIMARY. [worst]\n2. boot/bootutil/src/swap_offset.c:278 — same, swap-offset backend.\n3. boot/bootutil/src/swap_scratch.c:239 — same, swap-scratch backend.\n4. boot/bootutil/src/loader.c:1191 and :1193 — resume assert(fap != NULL) / assert(rc == 0) guarding swap_size read from an A2-writable trailer; compounded by boot_find_status() never returning NULL.\n\n(Truncated. The full description is in the advisory: https://github.com/mcu-tools/mcuboot/security/advisories/GHSA-cr9j-p626-pwcc)","aliases":["GHSA-cr9j-p626-pwcc"],"modified":"2026-11-24T23:00:12.629010627Z","published":"2026-11-24T21:39:12.111Z","database_specific":{"cna_assigner":"zephyr","cwe_ids":["CWE-754"],"osv_generated_from":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/16xxx/CVE-2026-16665.json","unresolved_ranges":[{"extracted_events":[{"strategy":"StandardRange","range":[{"introduced":"1.1.0"},{"last_affected":"*"}],"source":"AFFECTED_FIELD"}]}]},"references":[{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/16xxx/CVE-2026-16665.json"},{"type":"PACKAGE","url":"https://github.com/mcu-tools/mcuboot"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/133148bd5d792f781b72b8fce933ab9117780978"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/18c4f19e2e0e457b86bd37274a2fef4c3e6d2850"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/2d74b30860ac97f764367f3a66dc3b274a672244"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/36e56d691f4e853f2f741309751b9611689f4197"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/3b9159e1e04c6a09c691bdf9140bf303e3718c68"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/43dc9d0d97656f1c08b2ffef2f0a3c1db62cba7e"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/442c86b2131c119aab06ad4dde18ec62954d2808"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/4d9424a747de9c5e74be601aebee5239e371e21c"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/8e8ce11487c83975755b6ddcad69f4f42ee28977"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/9365411227c79a944ee72407e51a07320489e424"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/ab3fd3d4d563e57303fd0720bc0f0a93f5c619d0"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/adc0e42effb9422659c9d2d63399cdce1f297648"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/b0047116aa2a2cfb18f3f1bc2bd286217bc22e5c"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/e0872142b9d734c116b0ed7b35657dc933c3888b"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/e52ced626dd0391a0b7f175adf84b748b8db8795"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/commit/ec006b882ce618e01e7bbddcb2e5e12cb6987e0a"},{"type":"FIX","url":"https://github.com/mcu-tools/mcuboot/pull/3012"},{"type":"ADVISORY","url":"https://github.com/mcu-tools/mcuboot/security/advisories/GHSA-cr9j-p626-pwcc"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-16665"}],"affected":[{"ranges":[{"type":"GIT","repo":"https://github.com/mcu-tools/mcuboot","events":[{"introduced":"0"},{"fixed":"36e56d691f4e853f2f741309751b9611689f4197"},{"fixed":"43dc9d0d97656f1c08b2ffef2f0a3c1db62cba7e"},{"fixed":"e0872142b9d734c116b0ed7b35657dc933c3888b"},{"fixed":"e52ced626dd0391a0b7f175adf84b748b8db8795"},{"fixed":"3b9159e1e04c6a09c691bdf9140bf303e3718c68"},{"fixed":"2d74b30860ac97f764367f3a66dc3b274a672244"},{"fixed":"133148bd5d792f781b72b8fce933ab9117780978"},{"fixed":"442c86b2131c119aab06ad4dde18ec62954d2808"},{"fixed":"9365411227c79a944ee72407e51a07320489e424"},{"fixed":"8e8ce11487c83975755b6ddcad69f4f42ee28977"},{"fixed":"18c4f19e2e0e457b86bd37274a2fef4c3e6d2850"},{"fixed":"ec006b882ce618e01e7bbddcb2e5e12cb6987e0a"},{"fixed":"4d9424a747de9c5e74be601aebee5239e371e21c"},{"fixed":"adc0e42effb9422659c9d2d63399cdce1f297648"},{"fixed":"b0047116aa2a2cfb18f3f1bc2bd286217bc22e5c"},{"fixed":"ab3fd3d4d563e57303fd0720bc0f0a93f5c619d0"}],"database_specific":{"extracted_events":[{"range":[{"fixed":"36e56d691f4e853f2f741309751b9611689f4197"}],"source":"REFERENCES_COMMIT"},{"source":"REFERENCES_COMMIT","range":[{"fixed":"43dc9d0d97656f1c08b2ffef2f0a3c1db62cba7e"}]},{"source":"REFERENCES_COMMIT","range":[{"fixed":"e0872142b9d734c116b0ed7b35657dc933c3888b"}]},{"source":"REFERENCES_COMMIT","range":[{"fixed":"e52ced626dd0391a0b7f175adf84b748b8db8795"}]},{"range":[{"fixed":"3b9159e1e04c6a09c691bdf9140bf303e3718c68"}],"source":"REFERENCES_COMMIT"},{"source":"REFERENCES_COMMIT","range":[{"fixed":"2d74b30860ac97f764367f3a66dc3b274a672244"}]},{"range":[{"fixed":"133148bd5d792f781b72b8fce933ab9117780978"}],"source":"REFERENCES_COMMIT"},{"range":[{"fixed":"442c86b2131c119aab06ad4dde18ec62954d2808"}],"source":"REFERENCES_COMMIT"},{"range":[{"fixed":"9365411227c79a944ee72407e51a07320489e424"}],"source":"REFERENCES_COMMIT"},{"range":[{"fixed":"8e8ce11487c83975755b6ddcad69f4f42ee28977"}],"source":"REFERENCES_COMMIT"},{"source":"REFERENCES_COMMIT","range":[{"fixed":"18c4f19e2e0e457b86bd37274a2fef4c3e6d2850"}]},{"source":"REFERENCES_COMMIT","range":[{"fixed":"ec006b882ce618e01e7bbddcb2e5e12cb6987e0a"}]},{"range":[{"fixed":"4d9424a747de9c5e74be601aebee5239e371e21c"}],"source":"REFERENCES_COMMIT"},{"source":"REFERENCES_COMMIT","range":[{"fixed":"adc0e42effb9422659c9d2d63399cdce1f297648"}]},{"source":"REFERENCES_COMMIT","range":[{"fixed":"b0047116aa2a2cfb18f3f1bc2bd286217bc22e5c"}]},{"range":[{"fixed":"ab3fd3d4d563e57303fd0720bc0f0a93f5c619d0"}],"source":"REFERENCES_COMMIT"}]}}],"versions":["v2.5.0","v2.5.0-rc2","v2.4.0","v2.4.0-rc1","v2.3.0","v2.3.0-rc2","v2.3.0-rc1","v2.2.0","v2.2.0-rc2","v2.2.0-rc1","v2.1.0","v2.1.0-rc1","v2.0.0","v2.0.0-rc1","v1.10.0","v1.10.0-rc1","v1.9.0","v1.9.0-rc2","v1.9.0-rc1","v1.8.0","v1.8.0-rc1","TF-Mv1.4-integ-rc2","TF-Mv1.4-integ","TF-Mv1.4-integ-rc1","v1.7.0","v1.7.0-rc2","1.7.0-rc1","TF-Mv1.2-integ","TF-Mv1.3-integ","v1.6.1-cypress","cypress-latest-v1.X","v1.6.0","v1.6.0-cypress","v1.6.0-rc2","v1.6.0-rc1","v1.5.0-cypress","v1.5.0","v1.5.0-rc2","v1.5.0-rc1","v1.4.0","v1.4.0-rc2","v1.4.0-rc1","v1.3.1-rc1","v1.3.1","v1.3.0","v1.3.0-rc3","v1.3.0-rc2","v1.3.0-rc1","v1.2.0-rc5","v1.2.0","v1.2.0-rc4","v1.2.0-rc3","v1.2.0-rc2","v1.2.0-rc1","v1.1.0-rc2","v1.1.0","v1.1.0-rc1","v1.0.0","v1.0.0-rc3","v1.0.0-rc2","v1.0.0-rc1","v0.9.0","v0.9.0-rc2","v0.9-rc1","v0.9-test1"],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-16665.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H"}]}