CVE-2024-28183 OTA Anti-Rollback Bypass via TOCTOU in ESP-IDF
The ESP-IDF bootloader performs anti-rollback checks on an application image before loading it, but the image is re-read from flash after the check, creating a time-of-check-time-of-use (TOCTOU) flaw. An attacker with physical access and precise control over flash contents could replace the checked image with an older, vulnerable version, bypassing anti-rollback protections.
github.com
Published on github.com
History
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The bootloader checks the anti-rollback version of an application image, but then re-fetches the image from flash before loading it, allowing the image to be swapped between check and use.
Impact
An attacker with physical access and precise control over flash could bypass anti-rollback protections and boot an older, potentially vulnerable firmware version.
What the attacker needed
Physical access to device; precise control over flash contents
How it was found
- Set up a QEMU environment with ESP-IDF and build a bootloader and application with anti-rollback enabled.
- Build an application image with a secure version higher than the eFuse value to pass the anti-rollback check.
- Use nbdkit to simulate flash and replace the application image with an older version after the anti-rollback check but before the image is loaded.
- Run QEMU with the nbdkit-backed flash and observe that the older application boots despite the eFuse anti-rollback version.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Anti-rollback is a security feature that stops a device from running older, less secure firmware. The bootloader checks the firmware version, but then reads the firmware again from storage; an attacker who can change the storage between the check and the read can trick the device into running an old version. This requires physical access to the device's flash memory.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.