Definition
Secure boot is a startup procedure in which each stage of software checks the next stage before starting it, and starts it only if the check passes. The chain starts with a protected first stage, such as code in read-only memory (ROM). It enforces the device’s boot policy. One policy accepts a signature from a trusted signer. Another accepts an image whose computed hash matches a digest enrolled in protected storage. In either case the authority that sets the policy decides which code may start.
The idea
Without secure boot, a processor runs whatever is at its start address. An attacker who can write flash memory §6.6 once, through an unlocked debug port, a flawed update path or a software bug, can install firmware that does anything and stays installed. If the first stage and its policy remain protected, writing an unauthorized image into the application slot leaves it stored there, but the first stage refuses to start it.
A relay of guards is a fair picture of the chain of checks. Each guard admits the next only after checking that guard’s pass against a list handed over by someone already trusted, and the first guard is built into the wall and cannot be replaced. The picture shows where the weak points are: the first guard, the list of acceptable keys, and the act of checking itself. An old image can still pass its cryptographic signature check after a vulnerability is found. A policy can revoke its digest or signing key, or enforce a minimum security version. The first two decide which images or keys remain trusted. The last prevents a return to an earlier security version.
How it works
Consider a bootloader §6.30 configured to require signed images and enforce a minimum security counter. It proceeds as follows.
At reset, the processor runs the first stage: code in ROM, or a bootloader in flash memory that the chip write-protects.
The first stage reads the next image’s header and checks every field it will use before using it: the declared image size must fit in the slot, and every offset must point inside the slot.
It computes a cryptographic hash §5.1, such as SHA-256 §5.2 (Secure Hash Algorithm with a 256-bit output), over the header, the image and the protected metadata, which includes the version and the security counter.
It identifies the public key and checks that the key is one it trusts.
It verifies the image’s signature over that hash with the public key. Common schemes are ECDSA (Elliptic Curve Digital Signature Algorithm) with the P-256 curve, Ed25519, a signature scheme §5.14 also based on an elliptic curve §19.1.5, and RSA (Rivest–Shamir–Adleman).
It compares the image’s security counter with the stored minimum.
If every check passes, it starts the image. Otherwise it tries another slot, waits in a recovery mode, or stops.
The started stage, if it starts further code, repeats the procedure for that code.
Key protection rests on a distinction between the two keys.
The private key makes signatures and must stay secret, so it never goes on the device. The developer keeps it on a signing server or in a hardware security module, a tamper-resistant device that signs without revealing the key.
The public key checks signatures. It need not be secret, but it must not be replaceable: an attacker who can substitute their own public key can sign their own images.
Devices protect the public key in one of two ways. It can be compiled into a first stage that sits in ROM or in write-protected flash memory. Or a hash of it can be written into OTP (one-time programmable) memory, such as fuses, bits that can be changed once and never changed back; the image then carries the full public key, and the first stage accepts that key only if its hash matches. A SHA-256 hash takes 32 bytes, whatever the size of the key. Some chips store several key hashes and support key revocation §5.32: programming one more fuse marks one key as revoked, so that the developer can move to a new key if a private key leaks. Debug access must be locked as well; otherwise an attacker rewrites the first stage or the flash memory through the debug port.
Rollback protection §8.26, also called anti-rollback, refuses images older than a minimum. Each image carries a security counter inside the signed region, so an attacker cannot edit it. The device keeps the minimum in a monotonic counter §8.28, a stored number that can only increase; a common form is a row of fuses whose value is the number of fuses programmed. At boot, an image whose counter is below the stored minimum is refused, however valid its signature. The stored minimum is raised only after the new image has proved itself and confirmed that it works. Raising it at the first start would make it impossible to return to the previous image if the new one fails. Because fuses run out, the security counter is raised only for releases that fix a vulnerability, not for every release.
Worked example
A device has 32 fuses reserved for its security counter. Five are programmed, so the stored minimum is 5. Three signed images exist:
image A, version 2.3 with security counter 5, which is installed;
image B, version 2.4 with security counter 6, which fixes a vulnerability;
image C, version 2.1 with security counter 4, older and with a known vulnerability.
An attacker installs image C. Its signature verifies, but , so the first stage refuses it. Image B passes, because its signature verifies and . It runs as a test and confirms itself, and the bootloader then programs a sixth fuse, so the minimum becomes 6. From then on image A is refused as well, although its signature is valid, because . The 32 fuses allow the counter to reach 32. This device has used 6, leaving raises. At one security release every three months, those last months, six and a half years.
A layout check comes before all of this. Image D declares a size of 20 KiB, while its slot holds 16 KiB. The declared size exceeds the slot by KiB. If the first stage trusted the size, the hash computation would read 4 KiB beyond the slot, into memory that does not belong to the image. The first stage must refuse image D before hashing it, whatever its signature. In summary, image C passes the signature and layout checks and fails the version check, image D fails the layout check, and image B passes all three; only an image that passes all three starts.
Stated precisely
Let be the bytes that the signature covers: the header, the image and the protected metadata. Let be the hash function, the signature carried with the image, the public key, the signature check for key , hash and signature , the security counter inside , and the stored minimum. The first stage starts the image only if all of the following hold:
every size and offset in the header lies inside the slot;
is trusted: it is compiled into the protected first stage, or its hash equals a hash in protected storage that has not been revoked;
is true;
;
the bytes that the processor executes are the bytes that were hashed.
In this design, every image it starts must pass the signature check under a trusted key and meet the minimum security counter. It depends on these assumptions: the first stage cannot be modified; the processor executes the checks as written, so no fault injection §10.28 skips them; the attacker cannot write the key storage; the private key stays secret; the signature scheme is unforgeable, meaning that nobody without the private key can produce a valid signature on a new message; the hash function is collision-resistant §5.5, meaning that nobody can find two inputs with the same hash; and the stored minimum never decreases.
Limits and common mistakes
A valid signature shows that the corresponding signing key authenticated the covered bytes. Whether its use was authorized depends on who controlled that key. A signer can also approve an image containing bugs. Secure boot starts a signed image that contains a buffer overflow §4.4, a write past the end of a memory area, as readily as a correct one.
Secure boot checks code once, at startup. An attacker who exploits a bug at run time and runs injected code from RAM is not stopped, and secure boot does not report what is running; the measured boot and attestation §6.32 entry describes how a device records and reports that.
Fault injection, such as a brief drop in supply voltage at the right moment, can make the processor skip the instruction that rejects an image. Hardened bootloaders repeat critical checks and use values that a single skipped instruction cannot turn into success.
A check on one copy does not protect another copy. If the first stage verifies an image in external flash memory and then copies it into RAM, an attacker who can change the external memory between the check and the copy defeats the check; this is a time-of-check to time-of-use §9.26 (TOCTOU) error. Copy first, then verify the copy that will run.
Checking an update when it arrives, called arrival authentication §8.30, is not secure boot. An image written to flash memory by any other path is caught only by boot validation, the check at every start.
Secure boot can lock out its owner. If a device trusts only one signing key and provides no way to change it, losing the private key prevents the owner from authorizing a new image. Exhausting the counter’s fuses prevents further increases to its minimum security version. A later image can still meet the existing minimum.
Questions answered
How are verification keys protected and rollback handled?
Verification keys are protected against replacement rather than against reading, and rollback is handled by a stored minimum security version that can only increase. The public key that checks signatures need not be secret, but an attacker who could swap it for their own key could sign their own firmware. The key, or a hash of it, is therefore stored where software cannot change it: compiled into a first-stage bootloader in read-only memory or in write-protected flash memory, or written as a hash into one-time programmable fuses, in which case the image carries the full key and is accepted only if the key’s hash matches. Debug access is locked, so that nobody rewrites flash memory or the bootloader through the debug port. The matching private key never goes on the device; the developer keeps it on a signing server or in a hardware security module. Some chips store several key hashes and can revoke one with a fuse, so that a leaked key can be retired.
For rollback, each image carries a security counter inside the region its signature covers, and the device keeps a minimum in a monotonic counter, for example a row of fuses that can only be programmed, never cleared. The bootloader refuses any image whose counter is below the minimum, even if its signature is valid. It raises the minimum only after a new image has confirmed that it works, so that a failed update can still return to the previous image.
Related entries: Digital signature (§5.14), Bootloader (§6.30), Rollback versus anti-rollback (§8.26), Boot validation versus arrival authentication (§8.30), Deserialization (§4.29), Root of trust (§1.33), Monotonic counter (§8.28), Measured boot and attestation (§6.32), Time-of-check to time-of-use (TOCTOU) (§9.26), Key revocation (§5.32). Further reading: [21, 529].