Skip to content

Signed updates and A/B slots

A device accepts an update when its signature checks against keys it already holds, writes it to the idle copy of the system, and keeps the old copy as a fallback until the new one proves it boots and works.

On this page

What it is

Signed updates answer the first question: did these bytes come from the company, and are they intact? The device holds a public key (or a set of them) from the factory, and an update carries metadata signed by the matching private keys. In The Update Framework, a role's metadata counts as properly signed when at least a threshold of that role's keys have signed it, and a key contributes one signature toward the threshold however many times it signs. Uptane, the automotive profile of that design, puts two repositories behind the update: an Image repository that signs with offline keys, and a Director that reads the vehicle's signed report of installed software and chooses what to install next. Checking an image means comparing its hash and size with the values in the signed metadata, so the transport (HTTPS, a CDN, a USB stick) doesn't have to be trusted.

On a car, one ECU, the Primary, verifies the signatures on all update metadata and downloads images on behalf of the smaller ECUs behind it. The Primary can be the same gateway ECU that talks to the server. The Uptane standard (version 2.1.0) requires the Primary to do full verification, while a smaller ECU that can't must at least do a partial one. The standard also asks that each ECU have a trustworthy source of the current time. Our advice: treat a verification failure as a reason to stop and report, not to install anyway; the ECU keeps running what it has and tries again on its next check-in.

Verification doesn't stop at install. Android Verified Boot checks the code and data of the version being booted before it runs: small partitions such as boot are typically loaded whole and hashed, and a mismatch stops the boot. A signature at download time protects against a bad download; verification at boot protects against anything that changed the bytes on disk afterwards. The two are independent: Verified Boot has required block-based updates, but not A/B slots.

Rollback protection closes a gap that signatures leave open. An older build is still validly signed, so an attacker with a temporary exploit could reinstall it, reboot into its known hole, and make the exploit permanent. The defense is a counter: the image carries a rollback index, the device keeps the highest index it has accepted in tamper-evident storage, and the bootloader rejects an image whose index is below the stored one. Advancing the index is a one-way door, which is why its timing matters (below).

A/B slots answer the second question: how do you install without risking a device that won't start? The disk holds two sets of the bootable partitions, called slot A and slot B. The running system uses the current slot and, in normal operation, leaves the unused one untouched. The updater writes the new image into the unused slot while the device keeps running, and in the AOSP design it writes blocks as they stream in, so the package doesn't need to be stored first. The rule that lowers the risk, though it does not remove it: the update writes only to the other slot, never to the running slot or the partition table. Each slot carries two flags: bootable (it holds a system the device can start) and successful (set by user space once it booted, ran, and could update itself).

MomentSlot A (old, running)Slot B (being updated)

Writing the update

Bootable, successful, active

Marked unbootable while blocks are written

Written, reboot pending

Still bootable and successful

Marked active and bootable, not yet successful; the bootloader allows a limited number of boot attempts

First boot of the new build

Still bootable and successful, the fallback

Active and bootable; a user-space checker marks it successful after its checks pass

Attempts used up

The bootloader boots A again

Left unsuccessful; the client can retry the update later

Boot attempts turn "it didn't come up" into a decision the bootloader can make without help. In RAUC, marking a slot active sets a boot-attempt count in the bootloader (3 by default on U-Boot and barebox, per the main-branch reference); Our advice: have the bootloader fall back to the other slot when the attempts run out without the mark-good command, and pair the counter with a hardware watchdog that the new build has to feed, and have the bootloader treat a watchdog reset as a failed attempt, because a system that hangs during boot can't report its own failure.

Confirming and reporting. The last step is user-space work: the new build decides it's healthy and says so. Mender's client commits the update on the first boot after the flip, which makes the bootloader configuration permanent; it rolls back on its own if it can't reach the update server after installing, so another update can still be deployed, and a commit-time script that returns non-zero triggers a rollback too. Once the slot is confirmed, the device reports what it runs; in Uptane that report is a signed vehicle version manifest covering each ECU, and the Director decides the next step from it.

Order matters at the finish. The AOSP boot-flow page for A/B devices says the slot must be marked successful before the rollback-protection metadata is updated. If the counter moves first and the new build then fails, the old slot is still bootable in the A/B sense, yet rollback protection refuses it because its index is now too low, and the fallback is gone.

When to use it

Use signed metadata plus on-device verification when the device, not a person, decides to install. That covers cars, phones, set-top boxes and anything in a fleet. Use two slots when a failed boot can't be fixed by hand: a car in a driveway, a sensor on a pole, a phone whose owner has no USB cable. The AOSP pages list the payoff: an update that fails to apply leaves the user on the old build, an update that applies but doesn't boot sends the device back to the old partition, and installation runs in the background with low I/O so the device stays usable, with the reboot as the one interruption. The same update engine runs on Chromebooks, and Pixel phones shipped with it from October 2016.

Two slots also change what the updater may do with time. Because nobody is waiting for a dark screen, the install is deliberately slow to keep the device responsive, and a post-install step can run from the new partition before the reboot, for example compiling apps ahead of time. Pair the slots with a persistent data partition: Mender describes the root filesystem as stateless so it can be replaced whole, with configuration and collected data kept on a separate partition that updates don't touch.

When not to

Full A/B doubles the space for the duplicated partitions. In Android's own example a non-A/B device needs a 4.5 GB super partition and an A/B device 9 GB. When storage is the constraint, Virtual A/B keeps the fallback with less: it duplicates the partitions the bootloader reads and snapshots the rest into copy-on-write space, merging after the reboot, which in the same example brings the total needed to apply an update down to 8.3 GB, or 6.6 GB compressed. Virtual A/B is now the main mechanism there, and the recovery-based non-A/B path is deprecated as of version 15.

Our advice: a change that doesn't touch the operating system rarely needs a slot swap. An application, a configuration file or a container image can be updated with a smaller fallback: back the file up before install, remove the backup on commit, restore it on rollback, as Mender's state scripts describe. And slots don't protect what sits outside them: a bootloader with a single copy, a partition table, or a change to the data partition's format. If the update has to change one of those, you need a separate plan for it (a dual-copy bootloader, a format that old and new builds both read), not a slot.

Rollback protection is a feature with a cost: once the stored index advances, a build below it is refused even when you want it back. A fleet that treats downgrade as a supported operation should advance the index rarely and deliberately, for security fixes, rather than with each release. And signatures don't make a bad build good: they prove origin, not correctness, so a signed update still goes through staged rollouts, health checks and a fallback slot.

Compared

ApproachHow it installsIf the new build won't bootWhen it's the right choice

Recovery-based (non-A/B)

Reboots into a recovery image that rewrites the one system copy while the user waits

A failed apply usually leaves the device unusable until reflashed

Storage is tight and a person with a cable is nearby; deprecated on that platform as of version 15

Full A/B slots

Writes the idle slot in the background, flips, reboots

Bootloader runs out of attempts and boots the old slot

Unattended devices where a brick is expensive and storage can be doubled

Virtual A/B (snapshots)

Duplicates bootloader-read partitions, snapshots the rest, merges after boot

Rolls back to the previous version if the new OS fails to boot

Same safety wanted with less storage; costs temporary space on the data partition and a merge after boot

File-level with backup

Copies the old file aside, installs, commits or restores

Not about boot: restores the file if a commit check fails

Application or configuration changes that don't touch the OS image

In a picture

metadata, imageinvalidvalidhealthyfailedUpdate serverVerify signatureReject, stay on AWrite idle slot BB active, 3 triesReboot into BB successfulFall back to AReport to serverRetry later
The device verifies before it writes, writes to the slot it isn't running, and keeps the old slot until the new one is confirmed. A confirmed slot is reported; a failed one leaves the device on the old slot, free to retry.

How to say it in an interview

The common mistake

Quiz

Updates are served over HTTPS from the company's own CDN. Why does the device still check a signature on the metadata and the hash of the image?
The new slot boots to the kernel, but the main application crashes within seconds on each boot. What should happen?
When should the device advance its stored rollback index after an update?
A device has room for one copy of the OS plus a modest margin. Which option still gives it a fallback if an update won't boot?

Questions that use this

Related

Sources

  1. Android Open Source Project: A/B (seamless) system updates
  2. Android Open Source Project: A/B updates, frequently asked questions
  3. Android Open Source Project: Virtual A/B overview
  4. Android Open Source Project: Use Verified Boot
  5. Android Open Source Project: Verified Boot, boot flow
  6. Android Verified Boot 2.0 README (external/avb)
  7. The Update Framework Specification
  8. Uptane Standard for Design and Implementation 2.1.0
  9. Uptane Standard for Design and Implementation 2.0.0
  10. Uptane: Securing delivery of software updates for ground vehicles (whitepaper)
  11. RAUC documentation: Reference (main branch)
  12. Mender documentation: Combining Operating System and Application updates
  13. Mender documentation: State scripts
Sign in to report a mistake