Definition
A recovery fallback is a defined alternative that a system switches to when its normal state cannot be used, together with the rule that decides when to switch. Typical fallbacks are the previous firmware image in a second slot, a separate recovery image, factory default settings and a recovery mode that waits for a new image. A fallback helps only if, at the moment it is needed, it is present, undamaged, still allowed by the device’s current security rules and able to work with the data it finds.
The idea
A new firmware image fails at start-up, and the bootloader §6.30, the small program that runs first after every reset, switches to the previous image. That is the plan. The previous image was put in place weeks earlier, and the device has changed since. The update may have used the old image’s storage for something else. A flash fault may have damaged it. The new image may have converted the stored settings into a format the old image cannot read, or the device may no longer trust the key that signed the old image. The fallback was arranged at one time and is called on at a later time, and every change in between can break it.
A spare wheel is a fair picture. It helps only if it is in the car, holds air and fits the car as it is now; a spare kept for the old wheels does not fit once the car has wheels of a different size. The picture stops at security. A spare wheel is never refused for being old, whereas a device’s fallback must still pass checks that may have become stricter since it was stored, and a fallback that is let through without those checks becomes a way around them.
How it works
A recovery fallback is specified by five parts.
Triggers: the conditions that count as failure, such as an image that fails its check, a new image that resets a set number of times without confirming that it works, a watchdog timer §6.16 (a hardware timer that resets a device that stops responding) that keeps expiring, or stored data that fails its check.
Candidates in order: what to try, for example first the last-known-good state §8.25 (the most recent image and settings known to have worked), then a separate recovery image, then a recovery mode in the bootloader or in read-only memory that waits for a new image.
A usability check at the moment of use: each candidate is checked when it is about to be used, not when it was stored.
A final safe state: what to do when no candidate passes. The safe choice is to stop in a recovery mode that runs only checked code and accepts only authenticated images, the choice called fail closed §1.13. Running bytes that failed their checks is never a fallback.
A limit on attempts: a bound on how often each candidate is tried, so that a fallback that also fails leads to the final safe state, not to an endless cycle of restarts.
The usability check has four conditions, and all four must hold.
Present: the candidate’s bytes are still stored. An update may have erased them to make room, or used their storage to receive the next image.
Intact: the bytes are unchanged. Comparing their cryptographic hash §5.1, a short fixed-length digest of the bytes, with a reference value kept in protected storage shows this.
Authorized: the current security rules permit the candidate. Its digital signature §5.14 verifies under a key the device still trusts, and its version is not below the device’s version floor, the minimum version it accepts.
Compatible: the candidate can work with the device as it is now. It can read the stored data in its current format, it holds credentials that the other parties still accept, and it fits the hardware and the memory available.
Keeping the fallback usable. Every update step that could falsify one of the four conditions for the current fallback must wait until a new fallback exists. The order is: install the new image; during its trial, keep the old key trusted, keep the old data format readable and keep the floor at the old version; let the new image confirm itself; only then retire the old key, discard the old data and raise the floor; finally, name the new fallback, which may be the confirmed new image itself or a refreshed recovery image signed with the current key. The rule is make before break: never remove the last usable fallback before its replacement is confirmed.
Independence. A fallback that shares the cause of the failure is no fallback. A recovery image in the flash sector that the update erases, or a recovery mode in a bootloader that the update replaces, fails together with what it was meant to replace. Code in read-only memory, which no update can change, is the most independent fallback, and for the same reason it can never be repaired.
Testing. Fallback paths run rarely, so their faults stay hidden until the moment they are needed. They are tested on purpose, by forcing each trigger, for example with reset injection §8.37 and power-loss injection §8.38, and checking that the expected candidate starts or that the device stops in its safe state.
Worked example
A device has two slots. Image A, version 8, is signed with key and reads its settings in format 1. Image B, version 9, is signed with key . When image B first starts, it converts the stored settings to format 2 and tells the bootloader to stop trusting . Image B then crashes at its third start, before confirming itself, and the bootloader falls back to slot A. Check the four conditions for image A.
Present: yes. The update did not touch slot A.
Intact: yes. Its hash matches the reference.
Authorized: no. Image A is signed with , which is no longer trusted, so the bootloader refuses it. Neither slot may start, and the device stops in recovery mode, or does not run at all if it has none.
Compatible: no. Even if were still trusted, image A would find settings in format 2, which it cannot read. It would crash, which starts a cycle of restarts, or discard the settings and lose, for example, its network credentials.
The repair is to reorder the steps. During the trial, image B writes the format 2 settings next to the format 1 copy instead of over it, and the instruction to stop trusting waits. If image B fails, image A starts with still trusted and its format 1 settings intact. If image B confirms itself, it then retires and discards the format 1 copy. From that moment image A fails the authorized condition, and correctly so, because the old key was retired on purpose. The fallback is now the confirmed image B, and any separate recovery image must be re-signed with or replaced.
Stated precisely
For a candidate fallback at time , write where means and, and each condition is evaluated against the device’s state at time , not at the time was stored. Contract: when a trigger occurs at time , the device starts the first candidate in its list for which holds. If there is none, it enters a recovery mode that runs only code whose authenticity it has checked and accepts only authenticated images.
The contract gives two guarantees.
Safety: nothing that fails is ever started. This holds provided that the code evaluating the conditions, normally the bootloader, is itself intact and trusted, and that every path that starts code goes through it.
Recovery: a usable candidate exists whenever a trigger occurs. This holds only under an invariant, a condition that remains true at every instant: at least one candidate satisfies . The invariant is kept if every step that can falsify for the current fallback, such as erasing it, retiring its key, raising the version floor above its version or converting data it needs, runs only after another candidate satisfies and has been confirmed.
Limits and common mistakes
Falling back to old code does not bring back old data. Stored data that a new image converted stays converted; the Schema migration §8.36 entry treats how to keep the old format readable until the new image is confirmed.
A fallback that skips checks in order to recover more often becomes a way around them. An attacker who can make the normal image fail, for example by sending it input that crashes it, then reaches the weaker path. Every path that starts code must apply the same authenticity and version checks.
A strict security rule can make a fallback unusable on purpose. After a key is retired or the version floor is raised, the old image is refused, and that is correct. The design must then say what the new fallback is, rather than discover the gap after a failure.
A fallback to an older version reopens that version’s known flaws for as long as it runs. The Rollback versus anti-rollback §8.26 entry treats how long an old version may stay permitted.
Factory default settings as a fallback restore operation but may discard what the device received after manufacture, such as keys and network credentials. The device may then need to be provisioned again before it can do its job.
A fallback that has never been exercised should be assumed broken. Recovery code runs least often and is tested least.
Questions answered
Can fallback itself be missing, corrupted, or incompatible with current keys?
Yes. A recovery fallback can be missing, corrupted or incompatible with the keys the device currently trusts, so each of these must be checked at the moment the fallback is used, not assumed from the time it was stored. A recovery fallback is the alternative, such as the previous firmware image or a separate recovery image, that a device switches to when its normal image or state cannot be used.
Missing: an update may have erased it to make room, or written the next incoming image over it; some designs never keep one.
Corrupted: an interrupted write, a storage fault or an attacker who can write storage may have changed its bytes. Comparing its cryptographic hash with a reference value kept in protected storage detects this.
Incompatible with current keys: it may be signed with a key the device has since retired, so the signature check refuses it; it may hold credentials that servers or peers no longer accept; and its version may be below the device’s current version floor. It may also be unable to read data that a newer image converted to a new format.
The defense has three parts. Check that the fallback is present, intact, authorized and compatible each time it is about to be used. Order every update so that the old key, the old data format and the old version floor are retired only after the new image has confirmed that it works, so that a usable fallback exists at every instant. And define a final safe state for the case where no fallback passes: a recovery mode that runs only checked code and accepts only authenticated images.
Related entries: Last-known-good state (§8.25), Rollback versus anti-rollback (§8.26), Schema migration (§8.36), Bootloader (§6.30), Key revocation (§5.32), A/B update (§8.10), Power-loss injection (§8.38).