DEV Community

yutianle
yutianle

Posted on

MCUboot's PSoC6 backend checks the wrong flash boundary

MCUboot's PSoC6 backend checks the wrong flash boundary

A bounds-check bug in MCUboot's Cypress/PSoC6 flash backend can turn a malformed update image into a bootloader crash. CVE-2026-16667 is a moderate availability issue. The code compares an area-relative offset with fa_off, the partition's absolute base address, instead of fa_size, the partition length. In debug builds the assert can pass for an offset outside the partition; under NDEBUG, the assert is removed.

During pre-authentication image validation, bootutil_img_hash() reads sizes from the still-unverified image header. A crafted secondary-slot image can declare a large image size and cause reads far beyond the intended flash region. The Cypress backend is supposed to reject that access and make validation fail cleanly. Here it may compute an address in an unmapped or peripheral region and fault.

The impact is narrower than the bug class suggests

The GitHub advisory says the source address is out of bounds, while the destination buffer is correctly sized. The data is folded into a hash that still fails signature validation, so the issue does not disclose image data to an attacker or bypass authentication. The realistic availability impact is a bootloader hang or bus fault on affected PSoC6 hardware.

The same broken guard appears in the write and erase primitives, which is a latent out-of-bounds-write gap. The advisory says no attacker-controlled path to those primitives was found because serial-recovery uploads are bounded by core MCUboot. That distinction should remain visible during triage. A latent memory-safety bug still needs repair, but it should not be reported as an observed integrity compromise.

Test the backend, not only the generic parser

MCUboot has multiple flash backends. The advisory says mainline Zephyr, simulator, and Mynewt backends are unaffected. An update process that passes on a generic board image may never exercise the Cypress-specific path. Build a test for the PSoC6 port with an authenticated good image, an image with a valid signature but a malformed header, an oversized image length, invalid TLV offsets, and a deliberately truncated write.

Run the test in both debug and release builds. The assert must not be the only enforcement mechanism. A release build should return a clean validation error, not rely on a fault handler. Capture the bootloader's reset reason and any persistent error code so production recovery can distinguish a corrupt image from a failed power cycle.

Patch and revalidate update channels

Apply the corrected Cypress/PSoC6 backend from the vendor or MCUboot fix path used by the product. Rebuild the bootloader, sign the image with the existing release keys, and verify that the new bootloader still accepts legitimate updates. Do not reuse an old signed image as proof that the fix works unless the test specifically covers the malformed-header cases.

Check every route that can stage an image in the secondary slot: OTA service, USB or serial recovery, factory tools, and maintenance consoles. The attack requires the ability to place bytes in that slot, but the path may be available to a support workflow or a compromised update server. Record the expected firmware source and signing policy for each route.

Recovery and detection

Look for boot loops, repeated watchdog resets, and failures immediately after an update attempt. Preserve the secondary-slot hash before erasing it. A device that never establishes a network connection after an update may be failing in the bootloader before application logging starts. Field diagnostics should report bootloader stage and reset cause where the hardware supports it.

If a device is stuck, use the supported recovery mode to load a known-good signed image. Do not disable signature verification to make recovery easier. After recovery, audit the update server and the device's provisioning records for unauthorized images. Verify that the rejected image did not contain a valid signer that might indicate a compromised release process.

Design lesson

A bounds check is part of the parser contract. On flash-constrained devices, the error path deserves the same test coverage as the accepted path. An assert that disappears in production is not a security boundary. The PSoC6 issue shows how a small field mix-up can convert a signature failure into an availability event before the cryptographic decision is complete.

References

Top comments (0)