Skip to content

Lesson 3 of 9 · 28m

JTAG and SWD: When You Control the Processor

Understand debug-port power, enumerate JTAG or SWD safely, connect OpenOCD, and evaluate what debug access means for product security.

UART lets you talk to software that chose to listen. JTAG and SWD let you talk to the processor whether the software approves or not. That is why product teams lock debug ports and why attackers spend hours looking for them. A working debug connection can halt the CPU, inspect memory, patch execution, extract secrets, and rewrite flash. Treat it as root over physics.

Know the interface families

ARM-class devices commonly expose JTAG (TCK TMS TDI TDO TRST), two-wire SWD (SWDIO SWCLK), compact JTAG, or a vendor factory-test mode. Production boards rarely label these pads. They can be scattered, shared with GPIO, or hidden under shields. Use schematics, platform documentation, continuity tracing, and known adapter pinouts to form a hypothesis.

Do not brute force live pins casually

Tools such as JTAGulator exist because pin identification is tedious, but brute force is not risk-free. Driving the wrong pad can reset the board, erase state, activate test modes, or damage low-voltage logic.

1. identify ground and target voltage
2. locate reset candidates
3. scan impedance and boot behavior
4. test likely combinations at low speed
5. stop when the scan chain responds

Debug discovery is not a race. Every false pin combination is wear on the evidence.

Connect with OpenOCD

Once the interface is identified, use an adapter supported by OpenOCD, such as a CMSIS-DAP probe, J-Link, ST-Link, or FTDI-based adapter:

openocd -f interface/cmsis-dap.cfg -f target/stm32f4x.cfg -c 'adapter speed 100'

For an unknown ARM core, use the closest target configuration and expect iteration. Lower the clock speed before assuming the port is locked. Long wires, poor ground, and marginal voltage make fast debug unreliable.

What a successful halt proves

Test read capability before trying writes:

halt
reg
mdw 0x08000000 16
mww 0x20000000 0x41424344
mdw 0x20000000 4
resume

Memory reads can reveal bootloader code, keys in RAM, configuration blobs, and runtime secrets. Writes can patch authentication checks, disable signature validation, or alter boot flow. In a product assessment, the mere fact that unauthenticated debug can halt the production CPU is already a major result; you do not need to weaponize it fully to establish impact.

Debug access depends on lifecycle state

Modern silicon often implements a lifecycle rather than a simple on/off switch: development or manufacturing may be open, production should be restricted or authenticated, RMA may allow controlled re-entry, and end-of-life may lock permanently. The important question is not just whether JTAG exists. It is whether an attacker in the field can use it to reach assets that matter.

Glitching changes the conversation

Even a locked debug port can sometimes be bypassed with voltage or clock fault injection, but that is a separate attack class with specialized equipment and uncertain repeatability. Do not claim resistance to glitching merely because the port is closed in normal operation. State what was tested: electrical access, protocol authentication, lifecycle enforcement, and fault-injection scope.

Field notes

  • SWD needs only two signal lines, but short wires and solid ground are non-negotiable.
  • Detecting one TAP is not proof that the CPU core is accessible; boundary-scan devices can sit ahead of it.
  • connect under reset can help when firmware reconfigures or disables debug pins immediately after boot.
  • Never confuse a vendor unlocking procedure with a security boundary. Fleet-shared unlock secrets are effectively forums.
  • Preserve exact adapter configuration, target configuration, speed, and output. Debug results are environment-sensitive.

Was this lesson helpful?

Sign in to rate