UART, JTAG, SWD and Secure Boot
Open almost any consumer device and you find a row of unpopulated pads near the processor. They are the debug ports the engineers used during development, and on many shipped products they still work: one gives a serial console with a root shell, another lets a debugger halt the processor and read its memory. Physical access is part of the IoT threat model because devices are cheap to buy and open, and what one teardown learns (a key, a password, a bootloader bypass) often applies to every unit. This lesson explains the three common debug interfaces as concepts, how a vendor finds them open on its own product, and the controls that close them: locked debug and secure boot.
Scope: these are concepts and a vendor's own test. Opening and probing hardware you own is legal in most places; probing devices of others, or circumventing protections of a product you don't own, is not.
The three interfaces
| Interface | Signals | Gives a tester | Typical finding |
|---|---|---|---|
| UART (serial console) | TX, RX, GND (often 3.3 V logic), usually 115,200 baud | boot messages, the bootloader prompt, often a login or a shell | bootloader that can be interrupted; root shell without a password |
| JTAG (IEEE 1149.1) | TCK, TMS, TDI, TDO (+ TRST) | boundary scan, halting the CPU, reading and writing memory and flash | debug left enabled: full memory read, including keys |
| SWD (Arm Serial Wire Debug) | SWDIO, SWCLK (+ GND) | the same as JTAG on Arm Cortex-M microcontrollers, with two wires | flash read-out protection not set |
Engineers find the pads by looking (labels like TX, RX, TP12; a row of four pads near the SoC), measuring voltages, and reading the chip's datasheet. None of that needs special skill, which is why "nobody will open it" is not a control.
What an open console looks like
A vendor's own product-security test of the LabHome Hub (lab session, a USB-to-serial adapter on the hub's UART pads, 115,200 baud; the transcript is synthetic):
tester@bench:~$ screen /dev/ttyUSB0 115200
U-Boot 2019.07 (Jan 15 2026 - 10:00:00 +0000) labhome-hub-v2
DRAM: 128 MiB
Hit any key to stop autoboot: 0
## Booting kernel from Legacy Image at 82000000 ...
Verifying Checksum ... OK
[ 0.000000] Linux version 4.14.180 (builder@lab.test)
[ 2.481000] Run /sbin/init as init process
LabHome Hub 1.4.2
/ # id
uid=0(root) gid=0(root)Three findings in eleven lines: the bootloader can be interrupted (a one-second window to change boot arguments, for example to start a shell instead of init); the bootloader verifies only a checksum, not a signature; and the console drops straight into a root shell without a login. The kernel version (4.14, end of life since January 2024) is a fourth.
Secure boot
Secure boot makes the device run only code signed by the vendor. It is a chain of trust:
- Boot ROM: code burned into the chip, unchangeable. It holds or reads the hash of the vendor's root public key from one-time-programmable (OTP) fuses written at the factory.
- The ROM loads the bootloader, checks that its public key matches the fused hash and that its signature is valid, and only then runs it.
- The bootloader verifies the kernel (or the next stage) with a key it carries, and so on to the root filesystem (dm-verity on Linux).
- Any failure halts the boot or falls back to a recovery image.
The program models the chain with Ed25519 (Ed25519); keys come from fixed labels so the output is stable, while real signing keys are generated and kept in an HSM:
import hashlib
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
from cryptography.exceptions import InvalidSignature
def key(label): # deterministic lab keys; real signing keys live in an HSM
return Ed25519PrivateKey.from_private_bytes(hashlib.sha256(label.encode()).digest())
def raw(pub): return pub.public_bytes(Encoding.Raw, PublicFormat.Raw)
vendor_root = key("labhome root signing key")
FUSE_ROOT_KEY_HASH = hashlib.sha256(raw(vendor_root.public_key())).digest() # burned into OTP fuses at the factory
def stage(name, code, signer, next_pub=None):
"""A boot stage: its code, the public key it embeds for the next stage, and a signature over both."""
body = code + (raw(next_pub) if next_pub else b"")
return {"name": name, "body": body, "sig": signer.sign(body), "pub": raw(signer.public_key()), "next": next_pub}
def boot(chain, secure_boot_enabled=True):
if not secure_boot_enabled:
return "booted WITHOUT checks (secure boot fuse not set): any code runs"
# The ROM trusts only a key whose hash matches the fuses; every stage then vouches for the next one's key
if hashlib.sha256(chain[0]["pub"]).digest() != FUSE_ROOT_KEY_HASH:
return f"HALT in ROM: {chain[0]['name']} signed by a key the fuses don't know"
trusted = chain[0]["pub"]
for st in chain:
if st["pub"] != trusted:
return f"HALT: {st['name']} signed by an untrusted key"
try:
Ed25519PublicKey.from_public_bytes(trusted).verify(st["sig"], st["body"])
except InvalidSignature:
return f"HALT: signature of {st['name']} doesn't match its contents"
trusted = raw(st["next"]) if st["next"] else None
return "booted: " + " -> ".join(st["name"] for st in chain)
kernel_key = key("labhome kernel signing key")
good = [stage("bootloader", b"BL2 v2.1", vendor_root, kernel_key.public_key()),
stage("kernel", b"Linux 6.6 lab build", kernel_key)]
print("genuine image: ", boot(good))
tampered = [dict(good[0]), dict(good[1])]
tampered[1]["body"] = b"Linux 6.6 lab build + telnetd backdoor"
print("modified kernel: ", boot(tampered))
attacker = key("someone else's key")
resigned = [stage("bootloader", b"BL2 v2.1 patched", attacker, attacker.public_key()),
stage("kernel", b"Linux 6.6 + backdoor", attacker)]
print("re-signed by others:", boot(resigned))
print("fuse not set: ", boot(resigned, secure_boot_enabled=False))genuine image: booted: bootloader -> kernel
modified kernel: HALT: signature of kernel doesn't match its contents
re-signed by others: HALT in ROM: bootloader signed by a key the fuses don't know
fuse not set: booted WITHOUT checks (secure boot fuse not set): any code runs
- The genuine chain boots.
- A modified kernel fails its signature check, so the backdoor never runs.
- An attacker who re-signs everything with their own key fails in the ROM: the fuses know only the vendor's key.
- Without the fuse set, nothing is checked. Many products ship with secure boot supported by the chip but never enabled, which a lab test like the console above reveals ("Verifying Checksum").
Secure boot's guarantees depend on details: the ROM must have no bugs (several boot-ROM vulnerabilities were found in phones and consoles, unfixable because the ROM can't be updated), every later stage must check the next one, and the signing keys must be protected.
How open debug and missing secure boot are detected
- Product security tests on your own units: UART console behaviour (bootloader interruptible? shell without login?), JTAG/SWD connectivity, read-out of flash and memory through debug.
- Boot tests: boot a modified image in the lab. If it runs, secure boot is off or incomplete.
- Fuse and lock state read through the vendor's tools during manufacturing quality checks; a production unit with debug unlocked is a manufacturing defect.
- Firmware review: bootloader configuration (boot delay, console settings, environment write access).
How they are fixed
- UART: no console in production builds, or a console that requires authentication; boot delay 0 and bootloader interruption disabled; no shell bound to the console.
- JTAG/SWD: disable or lock them with the chip's mechanism (debug-disable fuses, read-out protection levels, or authenticated debug where a signed token re-enables debugging for returned units).
- Secure boot: enable it (fuse the root-key hash, set the secure-boot fuse), sign every stage, verify the root filesystem, and protect the signing keys in an HSM with separation of duties.
- Storage: encrypt sensitive data with device-unique keys held in hardware, so a flash dump is useless.
- Accept the limits: a determined attacker with lab equipment (fault injection, chip decapping) can defeat many protections on one unit. The design goal is that one broken unit doesn't break all others: no shared secrets.
Pitfalls
- "The pads aren't populated, so it's safe": soldering four pins takes minutes.
- Enabling secure boot for the bootloader but not the kernel or filesystem.
- Shipping with the chip vendor's development keys, or the same signing key for test and production.
Practice
1. In the program, what happens if the attacker keeps the vendor's genuine bootloader but replaces only the kernel with one signed by their own key?
The ROM accepts the genuine bootloader, which carries the vendor's kernel public key. The attacker's kernel is signed by a different key, so the chain reports that the kernel is signed by an untrusted key and halts. The bootloader's embedded key is what binds the next stage.
2. Name two lines of the console transcript that each justify a finding, and the fix for each.
"Hit any key to stop autoboot" (interruptible bootloader: set the delay to 0 and disable interruption); "Verifying Checksum ... OK" (no signature verification: enable secure boot); "/ # id → uid=0(root)" (root shell without login: remove the console shell in production).
3. Why are boot-ROM bugs so serious?
The ROM is the root of the chain and is burned into the chip; it can't be updated. A bug there breaks secure boot for every device with that chip, permanently, and the only fix is new hardware.
Test yourself
Which interface typically gives a serial console with boot messages?
- JTAG
- UART
- SWD
- SPI
Where does the boot ROM get the trusted root public key (or its hash)?
- From the Internet
- From one-time-programmable fuses written at manufacturing
- From the kernel
- From the user
An attacker re-signs the whole image with their own key. Why does secure boot still stop it?
- Their signature is invalid
- The ROM accepts only a bootloader key matching the fused hash
- The kernel is encrypted
- The CRC fails
What does 'Verifying Checksum ... OK' in a boot log tell a tester?
- Secure boot is on
- The bootloader checks integrity against accidents, not authenticity
- The flash is encrypted
- JTAG is locked