Posts Tagged ‘chip attack flash’

PostHeaderIcon Block-Level Protection: Why Some Blocks Are Always Open

A datasheet describes flash protection as a feature of the device. The silicon implements it as a feature of each block, and the distinction matters because blocks are configured independently and often are not configured uniformly.

The result is that devices described as fully protected frequently have one or more blocks that are readable, and those blocks are usually the most informative ones.

Why block granularity exists

Flash is erased in blocks because the erase mechanism operates on a region. A block is the smallest unit that can be erased, so it is the natural unit for protection as well: a bootloader that must never be overwritten, a parameter block that must survive a firmware update, a calibration region that must not be touched.

Region Typical protection Why
Boot block Write-protected, readable Must load the updater
Application Read and write protected The product
Parameter block Write-protected Must survive updates
Calibration Read and write protected Per-unit data
Option bytes Fully protected Configuration

The first row is the one that creates the opportunity. A bootloader has to run before any protection check, so it must be executable; on many parts it is also readable, because the protection bit for that block is separate and defaults to open.

What a readable boot block gives you

A bootloader is small and it is not the product, so a readable boot block sounds like a small win. In practice it is frequently decisive.

It gives the update protocol. A bootloader implements the commands that program and verify memory, which means it documents the memory map, the command set and the verification procedure.

Boot block content What it discloses
Command handler The programming protocol
Memory map table Region addresses and sizes
Version string The build and the vendor
Verification routine The integrity mechanism
Jump target Where the application begins

The fourth row is the most valuable. A bootloader that verifies a signature tells you the integrity mechanism, and a bootloader that verifies a CRC tells you that a patch is feasible. The distinction determines whether the application can be modified at all.

The usual configuration errors

Three configuration errors appear repeatedly, and each one leaves more open than the designer intended.

The first is a protection applied to the application block only. The designer’s intent was to protect the product, and the boot block was considered harmless because it contains no secrets. It contains the protocol, which is the means to everything else.

Error Left open Consequence
Protect the application only Boot block Protocol and memory map disclosed
Protect read but not debug Debug port Full access despite the read lock
Protect by region but not by page Unlisted pages A page of the application readable
Set the protection after the first boot The first boot A window at production

The third row is the one that requires reading the memory map carefully. Many devices offer both a coarse protection covering a range and a finer one per page, and a design that sets only the coarse one leaves any page outside the range readable.

Enumerating what is open

The practical approach is to assume nothing and to read the entire address space, block by block, recording for each block whether it returned data.

Read result Meaning
Data returned, plausible Block is readable
All zeros or all ones, with an error status Block is protected
All ones, no error status Block is erased, or readable and empty
Data returned, implausible Block is remapped or returns a stub

The third row is the ambiguity that has to be resolved, because a protected block that returns all ones is indistinguishable from an erased block by content alone. The resolution is the error status: a device that reports success on a read of a protected block is a device that is returning something rather than refusing.

The fourth row is the case of a part that returns a fixed pattern for protected regions. Some devices return zeros, some return a stub of a few bytes, and some return the last value on the bus. In each case the content is meaningless and the error status is the only signal.

What partial read means for the engagement

A partial read changes the deliverable and it changes what can be concluded.

If the boot block is readable and the application is not, the engagement can produce the protocol, the memory map and the integrity mechanism, and cannot produce the application. That is often enough to plan a follow-on attack: the integrity mechanism tells you whether a physical read will produce something usable, and the protocol tells you whether an update path exists.

Open region Deliverable Next step
Boot only Protocol, map, integrity mechanism Plan the physical or fault route
Application only The product code The bootloader may be absent entirely
Both Everything Analysis
Neither A statement about protection Physical route

The second row is a real configuration and it is an odd one: an application that is readable while the bootloader is not happens when the protection was applied in the wrong order, which is the failure described in three protection layers.

Where the block map comes from

The map is in the datasheet, and the datasheet is not always available for a part that has been customised.

Where it is unavailable, the map can be inferred by reading. A scan of the address space in block-sized steps, recording which reads succeed and which fail, produces a map of open and closed regions. The block size is the granularity of the transitions: a transition that occurs at a multiple of four kilobytes indicates a four-kilobyte block.

Inference Evidence
Block size Transitions occur at multiples of the size
Region boundaries A change in readability or content type
Erased versus protected Error status on the read
Remapped regions Identical content at two addresses

The fourth row is worth checking deliberately, because a remapped region produces a map that appears complete and contains duplicates.

What the service delivers

The deliverable is a block map: every block in the address space, its readability, its content classification, and the error status observed.

That map is more useful than a partial image because it tells the customer what is knowable and what is not. A customer who receives half an image does not know whether the other half is protected or empty; a customer who receives a map knows exactly.

The physical route that bypasses block protection entirely is in cracking IC flash, and the coupling that makes an unprotect operation destructive is in breaking IC flash. Where the readable block is a bootloader, its verification logic is the chain described in secure boot.

What we will not do is report a protected block as empty. The two look identical in a hex viewer and they are entirely different facts.