Section 17.11

Recovery and anti-rollback can conflict

Question

Can a system both revert a bad update and reject every old version?

Short answer

A system can do both, but only if it separates two rules that a single version check would merge. Reverting runs an older version, which a rule refusing every older version everywhere forbids. The goals fit together when the device keeps two records: a floor, the lowest version it accepts from any incoming update, which never decreases; and one retained copy of the previous version, which only the recovery path may start. “Reject every old version” then governs what arrives from outside; the revert uses only the copy already held.

Terms in the question

Full answer

Step 1: with one number, the conflict is real. A simple design stores one field, the current version CC, and accepts an incoming version vv only if v≥Cv \ge C. Reverting from version 8 to version 7 then breaks one goal or the other. If CC stays 8, and the bootloader §6.30 (the small program that runs first after a reset and starts the installed version) applies v≥Cv \ge C before starting a version, it refuses to start 7, so the revert is impossible. If the revert sets C=7C = 7, any signed copy of version 7 is accepted from outside again. Worse, a recovery path that rewrites CC, for example after erasing a damaged settings area, can set CC to a default and admit every old version.

Step 2: separate the two questions.

The running version RR may go down during a revert; the floor FF must not. FF is therefore stored apart from RR, in storage that no recovery path lowers.

Step 3: decide when the floor rises. There are two standard choices.

  1. Raise the floor only after confirmation. The new version first runs on trial. If it passes the success test within a fixed confirmation window §8.24, the device confirms it and only then raises FF to the new version. Until then FF still equals the old version, so the revert target satisfies the admission rule itself, and the bootloader can apply the single rule v≥Fv \ge F to everything. After confirmation, the old version is below FF and is refused everywhere, which is acceptable because the new version has proved itself. This scheme is a commit-confirmed update §8.23.

  2. Raise the floor at installation. This is needed when the new version fixes a security flaw in the old one, so that the old version must not be accepted from outside even during the trial. The retained old copy is then below FF. The recovery path may start that one copy and no other: the copy in a named slot whose digest, the output of a cryptographic hash function §5.1 over its bytes, was recorded when the new version was installed. An incoming copy of the same old version is still refused, because admission requires v≥Fv \ge F.

Step 4: state the price of raising the floor at installation. After a revert, the device runs a version with the flaw that the update was meant to remove. If an attacker can make the new version fail its success test, for example by blocking its network traffic so that it never reaches the update server, the attacker can push the device back to the flawed version without sending any old image. Where that is unacceptable, the recovery target must be a program without the flaw: a separate minimal recovery program whose only job is to fetch a corrected update, or the corrected update itself. That choice gives up some availability §1.10 to keep the security fix.

Step 5: state the retry rule. With F=8F = 8 after installation, an incoming copy of the failed version 8 still satisfies v≥Fv \ge F and would be installed again, possibly in an endless loop. The device should record the failed version, or its digest, and refuse it.

Many systems also give each image a security version number that is separate from its release number and is raised only by releases that fix a security flaw. Anti-rollback then applies to the security number alone, and a revert between two releases with the same security number never meets the floor at all. The answer is therefore yes, under three conditions: two records (the floor and the retained copy), two rules (admission and recovery), and a stated decision on whether the retained copy may still run when the update existed to fix a flaw in it.

Worked example

A device runs version 7, which has passed its success test. Slot A holds version 7, slot B is empty, and the floor is F=7F = 7. A signed version 8 arrives. Admission checks 8≥78 \ge 7: true, so version 8 is written to slot B and started on trial. Version 8 crashes on each of its first 3 starts, which is the limit for a trial, so the bootloader returns to slot A.

Floor raised after confirmation. The floor is still 7. Recovery starts version 7, and 7≥77 \ge 7 holds, so even the plain admission rule permits it. An attacker now sends a signed version 6 with a known flaw. Admission checks 6≥76 \ge 7: false, so version 6 is refused. A signed copy of version 7 would be accepted, but version 7 is what already runs, so nothing is downgraded. Later, version 9 passes its trial and is confirmed, and FF becomes 9. From then on, versions 8 and 7 are both refused.

Floor raised at installation. Version 8 fixes a flaw in version 7. Installing version 8 sets F=8F = 8 and records the digest D7D_7 of the bytes in slot A. After the failed trial, the bootloader computes the digest of slot A, finds that it equals D7D_7, and starts version 7. The running version is now R=7R = 7, below F=8F = 8, which only the recovery rule allows. An attacker sends a signed copy of version 7. Admission checks 7≥87 \ge 8: false, so the copy is refused.

One field for both jobs. The device keeps only CC. After the revert, C=7C = 7, and a signed copy of version 7 passes 7≥77 \ge 7. Later a recovery routine erases the damaged settings area that holds CC, and the code treats the missing record as C=0C = 0. An attacker sends a signed version 3 with a known flaw. Admission checks 3≥03 \ge 0: true. The device has been downgraded to version 3.

Follow-up questions and limits

What exactly authorizes the revert? The recovery rule authorizes it, together with whoever can set that rule in motion. The power to bring a device back after a failure is recovery authority §1.46, and it is a second way to control the device. The rule must name one copy (a slot and a digest), check that copy’s integrity at every start, and be reachable only through the defined failure path.

What if the floor is lost? If an erase of the whole chip through a debug port, or a storage fault, clears the floor, anti-rollback stops working until the floor is restored. The floor therefore belongs in storage that the normal recovery path cannot erase. Hardware monotonic counters built from one-time programmable bits, which can be set once and never cleared, allow only a fixed number of increases, often one per bit. This is another reason to raise the floor only for releases that fix a security flaw.

Is the check the same for software images and for numbered commands? It is similar but not identical. An image check usually accepts the version already installed (v≥Fv \ge F), which allows the current version to be installed again. A command check needs a strictly greater number (v>Fv > F), because a command accepted twice has its effect twice.

This answer does not cover how the switch between slots survives a power cut, which is a question of crash consistency §8.4, or how the success test is chosen.

Fullest treatment: Rollback versus anti-rollback (§8.26).

Related entries: Version high-water mark (§8.27), Last-known-good state (§8.25), Recovery authority (§1.46), Commit-confirmed update (§8.23), Monotonic counter (§8.28), Downgrade attack (§1.27), Recovery fallback (§8.29).