Lesson 6 of 13 · 18m
JTAG and SWD: Owning the Die
JTAG halts cores and reads memory through a debug state machine; readout protection slows a patient attacker by hours, not forever.
The debug port is a debugger
UART gives you what the firmware chose to print. JTAG gives you the CPU. The JTAG TAP is a state machine with four or five lines — TCK, TMS, TDI, TDO, optionally TRST — that shifts instructions and data through registers the silicon designer put there for exactly this: halt the core, single-step it, read and write registers, and on most SoCs reach the entire memory map through a debug access port without the core's cooperation. ARM's two-wire SWD (SWDIO, SWCLK) does the same job with fewer pins; on Cortex parts the MEM-AP can walk physical address space while the CPU keeps running.
Chips are daisy-chained on one TAP — SoC behind FPGA behind CPLD — each identified by an IR length and an IDCODE, and the hardware that talks to the chain is a J-Link, a Tigard, or a Bus Pirate. Finding the pins on an unlabeled board is what JTAGenum exists for: a script that brute-forces pin combinations on an Arduino or Pi header until an IDCODE answers — the 32-bit register encoding manufacturer, part, and revision that every TAP is required to expose. From there the tooling is OpenOCD: openocd -f interface/jlink.cfg -f target/stm32f1x.cfg opens a GDB server on 3333 and a telnet console on 4444. reset halt, mdw 0x08000000 64, dump_image flash.bin 0x08000000 0x100000 — that is the entire workflow. With GDB attached to port 3333 (target extended-remote localhost:3333) you get breakpoints, watchpoints, and load/mon dump_image on top. Firmware extraction without touching the flash chip, RAM dumps containing keys the software thought were memory-only, single-stepping through a secure-boot verification to watch it decide. Two different powers ride the same pins: boundary scan — the original JTAG purpose, driving and sampling device pins for board test — and core debug. Audits use both; dump_image against a halted core is the one that ends engagements — time the halt before software scrubs its buffers, because peripherals and DMA do not stop just because the core did.
The wrong mental model
"Readout protection means the flash is safe." RDP is a flag checked by code — and code executes on hardware that glitches. On STM32F1, RDP1 disables debug access, but voltage fault injection timed to the clock edge where the protection check runs skips it (LimitedResults' chip.fail work demonstrated this in 2019; a ChipWhisperer does it on a bench in an afternoon). Nordic's APPROTECT on the nRF52 was the same shape — a UICR flag, not a lock — and their 2020 debug-resurrection glitch re-opened it on shipping parts. RDP2 is marketed as permanent because the flag is one-way. It is an inconvenience, not a proof — the fault-injection literature keeps lengthening, and the honest model is "extraction requires a motivated attacker with modest equipment," not "extraction is impossible." Modern silicon answers differently where debug authentication exists (ARM ADIv6 debug authentication, NXP secure debug): the port stays physically live but opens only to a challenger holding the right credential — the model to ask for when a vendor insists they need JTAG in production.
The other direction is just as wrong: assuming JTAG is disabled because the header is unpopulated. The TAP is inside the die. Production eFuses are what disable it — a blown fuse, not a missing header.
What to actually do
As an auditor: enumerate the chain, dump flash via the core or the memory-mapped SPI window, dump RAM for keys, and treat every discovered TAP as an open door the vendor left.
As someone shipping product: blow the debug eFuse on production units and test that it took — this is a QA step, not a hope. If field debug is genuinely needed, use the silicon's authenticated debug (ARM DAP authentication, NXP secure debug) rather than leaving the port open and unauthenticated. And internalize the consequence for key management: anything readable by dump_image is readable by an attacker with the same four wires. Long-lived secrets belong in a secure element or fused key vault, not in flash the debug port can walk.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Januscape: A 16-Year-Old Linux KVM Escape Bug
CVE-2026-53359 lets a guest VM crash or potentially root your Proxmox host, and it hid in KVM's shared code for 16 years. What to patch and how to check.
The CPU-ocalypse Is Here, and the AI Industry Walked Right Into It
For three years the AI industry watched GPUs. Nobody was watching the CPU. Now Intel is warning of six-month lead times, AMD has blown past expectations, and the chip everyone assumed would always be available has become the new bottleneck in the biggest infrastructure buildout since the internet.
The RAMpocalypse! How AI Companies Are Destroying the Hosting Industry and Your Wallet
How AI infrastructure demand is driving up VPS and dedicated server costs — and why your hosting bill is going up even though you haven't changed anything.
Getting Started with Embedded C
The Goal By the end of this tutorial, you will be able to compile a binary written for the avr instruction set targeting the AtMega328P microcontroller on an Arduino Nano or Arduino Uno R3 form factor. Needed Documentation * Arduino Nano PCB design * Atmega328P datasheet Materials used * Arduino Nano * Arduino Uno R3 * Relevant cable * Computer Software Used * make (for easy of compiling and building) * avr-gcc (our compiler for avr ISA) * binutils-avr * avr-libc * avrdude (