Section 1.32

Physical versus logical access

Definition

Physical access and logical access are two kinds of attacker capability in a threat model §1.2, the written description of what an attacker can do. Logical access reaches a system only through interfaces that its software provides, such as network messages, commands or files, so every request passes the software’s checks. Physical access means handling the hardware itself: connecting to debug pins, reading or replacing memory chips, interrupting power or measuring electrical signals. Physical access can reach data without passing through the software’s checks at all.

The idea

A sensor device keeps a secret key in its flash memory §6.6, the memory in which a microcontroller §6.1, a small computer on a single chip, stores its program and data while power is off. The device obeys a command only if the command carries a valid tag from a MAC (message authentication code §5.7): a short value that only a holder of the key can compute over exactly that command. Against an attacker who can only send radio messages, this design holds: without the key, the attacker cannot compute a valid tag. Now the attacker steals one device and connects a debugger, a tool that attaches to a dedicated hardware port on the chip and can stop the processor and read or write any memory. The debugger copies the key out of flash. From then on the attacker computes a valid tag for any command. No software check failed, and the MAC algorithm was not broken. The design’s argument assumed that the key is unreadable, and physical access made that assumption false.

A bank gives a fair picture. A customer at the counter has logical access: the customer can only make requests, and the clerk applies the bank’s rules to each one. A burglar inside the vault after closing time has physical access: the clerk’s rules are not in the way. The picture fails in two respects. First, physical access is not all or nothing: the vault may contain a locked safe, just as a device may keep its key in a separate protected chip. Second, logical access also comes in grades: an attacker who has found a bug that lets them run their own code on the device can read memory almost as freely as a debugger can.

How it works

Analyze access as a list of separate powers, not as a single label. Logical access comes in grades such as these, each adding interfaces that the software defines:

  1. sending messages over a network or radio link without any credential;

  2. sending requests with a valid credential, such as a user’s password or key;

  3. running code on the device with limited privilege, meaning that the processor or the operating system restricts which memory and hardware the code may use;

  4. running code with full privilege, which can read and write all memory that the processor can address.

Physical access comes in grades that reach past the software:

  1. Existing ports and parts. Connecting a debugger to the chip’s debug port, such as JTAG §6.26 (named after the Joint Test Action Group, which defined it [398]) or SWD §6.25 (Serial Wire Debug, a two-wire debug port defined by Arm [397]); pressing reset or cutting power at chosen moments; removing a memory card or reading an external memory chip directly.

  2. Observation. Measuring power consumption, electromagnetic emission or timing while the chip computes, and inferring secrets from the measurements. Such an unintended source of information is a side channel §1.29.

  3. Fault attacks, also called glitching. Briefly disturbing the supply voltage or the clock, or shining a laser on the chip, so that the processor skips or corrupts an instruction, for example the instruction that checks a signature.

  4. Invasive attacks. Removing the chip’s package and probing its internal wires or memory cells with fine needles under a microscope.

The grades need increasing amounts of equipment, skill and time. The first three leave the chip intact; an invasive attack usually destroys it.

For each protected item, ask three separate questions about each grade of access.

A secure element §5.38, a separate chip that keeps keys inside itself and returns only results, is a common way to deny read while still allowing invoke. An attacker who controls the main processor cannot copy the key out of the secure element, but can ask the secure element to use the key for anything the secure element permits.

Many microcontrollers offer readout protection §16.5: a setting that stops the debug port from reading memory. On many such chips, the only way to reopen the debug port is a command that first erases all of flash, so an attacker regains the port only by destroying the secrets it would have revealed. Readout protection closes one path, the debug port, and only that path.

Worked example

A vendor runs a fleet of 10,000 identical devices. Each device holds three items in flash:

An attacker steals one device. Its debug port is unprotected, so a debugger reads all of flash.

Take the items one at a time.

  1. The MAC key KK. Before the read, the attacker could only guess the key, and each guess at a uniformly random 256-bit key is right with probability 2−2562^{-256}. After the read, the attacker knows KK and computes a valid tag for any command on the first attempt. If all 10,000 devices share KK, the attacker can now command all 10,000. If each device has its own key, the read exposes 1 key of 10,000, and commands to the other 9,999 devices stay protected.

  2. The public key PP. PP was never secret, so reading it gives the attacker nothing. Signing an update needs the private key, which is not on the device, so the attacker still cannot produce an update that any device accepts.

  3. The firmware. The attacker can now read the program, study it at leisure and look for bugs that can be triggered over the radio. Every device runs the same program, so the confidentiality §1.8 of the firmware, its secrecy, is lost for the whole fleet.

Now suppose the debugger can also write flash. On the stolen device, the attacker replaces PP with a public key of their own and then installs any firmware signed with the matching private key. The integrity of that one device is lost. The other 9,999 devices are unaffected, because writing one device’s flash changes nothing on the others.

Finally, suppose readout protection is enabled, and the only way to reopen the debug port is an erase of all flash. The erase removes KK together with the firmware. The confidentiality of KK survives, but the device stops working until someone reprograms it, so its availability §1.10, its readiness to provide its service, is lost. The attacker can then load firmware of their own, but that firmware does not hold KK, so it cannot produce reports that the server accepts as coming from the original device. One physical operation, the erase, keeps one property, gives up another and leaves a third partly intact, so each property must be judged separately.

Stated precisely

Call an asset any item that a security claim depends on, such as a key, a program or a stored public key. Call a capability one grade of access from the lists above. For each asset and each capability, record three yes-or-no answers: whether the capability lets the attacker read the asset, modify it, or invoke its use. Then:

The guarantee of a MAC, for example, reads: an attacker who does not know the key, even after seeing valid tags on messages the attacker chose, cannot produce a valid tag for any other message, except with negligible probability, a probability so small, such as 2−1282^{-128}, that it can be ignored. “Does not know the key” is a premise of that guarantee. A capability that can read the key removes the premise; it does not break the MAC. A key copied out of a device and then used is a key compromise, not a forgery in the cryptographic sense, and should be reported as such.

Whether a given physical path exists, and what it costs to use, depends on the specific chip, its configuration and the tests of its resistance; a general description of a chip family does not settle it.

Limits and common mistakes

Physical access does not automatically mean that everything is lost. A key inside a secure element, or a design in which reopening the debug port erases all secrets, can keep particular secrets even from someone holding the device. Each such claim needs evidence for the specific hardware, including its resistance to fault attacks and invasive probing.

Logical access is not automatically the weaker threat. An attacker who exploits a bug to run code with full privilege can read flash through ordinary memory reads, which gives much of what a debugger gives, and can do it to many devices over the network at once. Physical access usually reaches one device at a time.

Network protection cannot repair a physical extraction. Once a key has been copied out of one device, message authentication §1.6 with that key protects nothing against the holder of the copy. The remedies are key revocation §5.32, telling every party that relies on the key to stop accepting it, followed by a new key, and, decided in advance, per-device keys, so that one extraction exposes one device.

Reading a public key is not a compromise. Replacing a stored public key is, because it changes whose signatures the device accepts.

Readout protection is not physical security. It closes the debug read path only. It does not by itself resist fault attacks or invasive probing, and published attacks have bypassed the readout protection of several microcontroller families by disturbing the supply voltage. It also does nothing for data that crosses an external bus between chips or leaks through a side channel.

Erasing protects secrecy at the cost of availability. A design that erases everything when the debug port is reopened accepts that anyone holding a device can destroy it.

A threat model that leaves out physical access must say so explicitly. Without that statement, a reader cannot tell whether physical attacks were considered and resisted or simply excluded.

Questions answered

What changes when a debugger can read all flash?

When a debugger can read all flash, every value stored in flash must be treated as known to whoever holds the device, so every security claim that relied on the secrecy of a value in flash no longer holds for that device. A debugger is a tool that attaches to a hardware port on the chip and can stop the processor and read memory without going through the device’s software checks. Concretely:

If the debugger can also write flash, integrity is lost as well: the attacker can replace the program or the stored public key on that device. No cryptographic algorithm §14.1 is broken in either case. What changed is that the premise “the attacker does not know the key” became false. The usual responses are to keep secrets out of readable flash, for example in a secure element (a separate chip that keeps keys inside itself); to enable readout protection, a chip setting that stops debug reads; to give every device its own key, so that one read exposes one device; and to be able to revoke an exposed key.

Related entries: APPROTECT and debug access protection (§16.4), Readout protection (§16.5), Secure element (§5.38), UICR (User Information Configuration Registers) (§16.1), Threat model (§1.2), Side channel (§1.29), SWD (§6.25), JTAG (§6.26), Message authentication code (MAC) (§5.7), Per-device key derivation (§5.24), Key revocation (§5.32), Assumption versus guarantee (§1.36). Further reading: [397, 398].