Security

Secure Debug Infrastructure: Balancing Security and Debuggability

12 min read Security

Secure Debug Infrastructure: Balancing Security and Debuggability

Debug ports are an engineer's best friend during bring-up and a hardware attacker's favorite front door in the field. The same JTAG, SWD, and scan-chain interfaces that let you halt a CPU, dump memory, and trace execution also expose firmware extraction, key recovery, and fault-injection control to anyone with physical access. Designing a secure debug infrastructure means keeping a chip fully observable for trusted developers while making it opaque to everyone else.

Quick Summary

Threat Open debug ports allow firmware readout, key extraction, and fault injection
Defense Lifecycle-state gating, challenge-response authentication, and fuse/OTP locks
Goal Full debug for trusted parties, zero access for attackers, with auditable transitions

The Debug Attack Surface

Before locking anything down, you must enumerate exactly what a debug interface exposes. A modern SoC debug subsystem is far more than a CPU halt button.

  • Core debug: Halt, single-step, register read/write, and breakpoint control over every processor.
  • System memory access: AHB/AXI access ports (e.g., ARM MEM-AP) that read and write any address, often bypassing the MMU.
  • Boundary scan: IEEE 1149.1 scan chains that observe and force I/O pin states.
  • Internal scan and BIST: Test modes that shift out flip-flop contents, including key and state registers.
  • Trace: ETM/ITM instruction and data trace that leaks control flow and secrets in real time.

The key insight: protecting only the CPU debug while leaving a system memory access port or a scan chain open defeats the entire scheme. Secure debug must cover all of these access paths uniformly.

JTAG and SWD: Specific Risks

JTAG (IEEE 1149.1) and ARM Serial Wire Debug (SWD) are the dominant physical interfaces. Both terminate at a Debug Access Port that, once entered, grants deep control.

Common Attack Patterns

  • Firmware extraction: Reading flash or RAM through the memory access port to recover proprietary code or cryptographic keys.
  • Boot bypass: Halting the CPU during reset and overwriting the boot vector or secure-boot verdict.
  • Fault injection control: Using debug to single-step into a glitched state and capture intermediate secrets.
  • Scan-chain readout: Toggling into test mode to shift out the entire flip-flop state, including AES round keys.
  • Probing dormant ports: Unlabelled or undocumented test pads that remain electrically live on the production die.

SWD reduces the pin count to two (SWDIO, SWCLK) but carries identical security implications - fewer pins do not mean fewer privileges. Any security model must treat JTAG and SWD as equivalent attack vectors.

The Authentication Challenge: Challenge-Response

A simple "debug disable" fuse is binary and irreversible - it kills field debug entirely. The better approach is cryptographic authentication, where the chip only unlocks debug for a party that can prove possession of a secret.

A robust scheme uses asymmetric challenge-response so that no secret ever leaves the debug host and replay is impossible:

  1. The debugger requests access; the chip generates a fresh random nonce (challenge) from its TRNG.
  2. The host signs the nonce (plus a device identifier and requested debug scope) with its private key.
  3. The chip verifies the signature against a trusted public-key hash stored in OTP.
  4. On success, the debug controller opens the requested access level; on failure it stays locked and may rate-limit retries.

Challenge-Response Verification

Unlock condition: Verify( PubKey, Nonce || DevID || Scope, Signature ) == TRUE

Key anchoring: SHA-256( PubKey ) == OTP_KEY_HASH

The nonce guarantees freshness (anti-replay); binding DevID prevents one valid token from unlocking an entire fleet; binding Scope enforces least-privilege debug.

Storing only a hash of the public key in OTP (rather than the full key) saves fuse area and lets the same silicon trust different keys per customer, since the public key itself is delivered at authentication time and merely verified against the on-chip digest.

Lifecycle States and Debug Policy

Secure debug is meaningless without a notion of device lifecycle. The same silicon needs wide-open debug at the wafer test stage and near-total lockdown in a deployed product. Lifecycle states are stored in OTP and advance monotonically - they can move forward but never backward.

Lifecycle State Debug Access Typical Stage Authentication
Raw / Test Full (scan, JTAG, MEM-AP) Wafer sort, ATE None required
Manufacturing Full functional debug Provisioning, OTP write Optional token
Secured / Deployed Locked unless authenticated In-field product Challenge-response
RMA / Return Re-enabled after key erase Failure analysis Authenticated unlock
Decommissioned Permanently disabled End of life Irreversible fuse

The critical security property is the RMA transition: a returned part must scrub all device-unique secrets (keys, sensitive NVM) before debug is re-opened. This lets failure analysis proceed without exposing the keys that protected the product in the field.

Debug Access Port Locking

Once policy is decided, it must be physically enforced at the Debug Access Port (DAP). Locking is implemented as gating logic on the debug bus, controlled by lifecycle state and authentication status.

Granular Access Levels

Rather than a single on/off switch, well-designed infrastructure exposes multiple independently gated domains:

  • Non-secure invasive debug (DBGEN): Halt/step of non-secure code only.
  • Secure invasive debug (SPIDEN): Debug of TrustZone secure world.
  • Non-secure trace (NIDEN): Non-intrusive trace of non-secure execution.
  • Secure trace (SPNIDEN): Trace of secure-world execution.

Splitting these lets you, for example, ship a product where non-secure application debug is authenticated but the secure key store is never observable - even to an authenticated debugger. Each gating signal should be driven by registers that latch at reset and can only be opened (never spuriously) by the authentication block.

ARM CoreSight DAP Authentication

ARM's CoreSight architecture formalizes these gating signals into a standard authentication interface. The four signals - DBGEN, NIDEN, SPIDEN, and SPNIDEN - feed every processor and trace component, and define a strict privilege hierarchy.

  • DBGEN gates non-secure invasive debug; if low, no halting debug is possible at all.
  • NIDEN gates non-secure non-invasive (trace) debug and is implied by DBGEN.
  • SPIDEN additionally enables secure invasive debug; it requires DBGEN to also be asserted.
  • SPNIDEN enables secure trace and requires NIDEN.

These signals are typically driven by an on-chip Debug Access Controller or security subsystem rather than tied off in RTL. The controller evaluates lifecycle state plus authentication result, then asserts the minimum set of signals the authenticated party is entitled to. CoreSight also exposes a Device Authentication register and a debug Authentication Status register (DBGAUTHSTATUS) so software and tools can read back the current permission level - useful for verifying that production parts ship with secure debug genuinely disabled.

Fuses and OTP: The Root of Trust Storage

Authentication policy, lifecycle state, and key hashes are worthless if an attacker can rewrite them. One-time-programmable (OTP) memory and antifuse arrays provide tamper-evident, non-volatile, write-once storage that anchors the entire scheme.

What Lives in OTP

  • Lifecycle state field: Monotonic counter or thermometer-coded fuses that can only advance.
  • Public-key hash: SHA-256 digest of the authorized debug authority's key.
  • Device unique ID: Used to bind debug tokens to a single part.
  • Debug policy bits: Per-domain enable defaults and a permanent-disable fuse.

Antifuse-based OTP is preferred for security because programmed bits create a physical short that is difficult to reverse or read optically, unlike charge-storage flash. Critical fields should be redundantly coded (e.g., majority voting across triplicated fuses) so a single fault-injection bit flip cannot silently downgrade the lifecycle state and re-open debug.

Interaction with Secure Boot

Secure debug and secure boot are two halves of the same hardware root of trust, and they must be reasoned about together. A common mistake is hardening secure boot while leaving a debug path that bypasses it entirely.

  • Shared root of trust: Both rely on the same OTP key hashes and lifecycle state, so a single authority governs who may boot unsigned code and who may debug.
  • Debug-before-boot ordering: Authentication of debug should be evaluated at the earliest boot ROM stage, before any secrets are loaded, so an attacker cannot halt the CPU mid-boot to skip verification.
  • Measured debug state: The boot process should record whether debug was unlocked into attestation/measurement logs, so a remote verifier can refuse to release secrets to a debug-enabled device.
  • Key scrubbing on unlock: If debug is authenticated for a deployed part, the secure boot flow can withhold or wipe device-unique keys, preserving confidentiality even under legitimate debug.

The unifying principle is that debug authorization is just another input to the secure boot policy decision - never an independent backdoor around it.

Implementation Best Practices

  1. Gate every access path: Apply authentication uniformly to JTAG, SWD, scan, MEM-AP, and trace - not just CPU halt debug.
  2. Use asymmetric challenge-response: Avoid shared symmetric passwords; bind each token to a fresh nonce, the device ID, and a debug scope.
  3. Store only key hashes in OTP: Keep the full public key off-chip and verify it against an on-chip digest to save fuse area and allow per-customer keys.
  4. Make lifecycle transitions monotonic: Encode states so they can only advance; never allow a deployed part to regress to a test state.
  5. Scrub secrets before RMA unlock: Erase device-unique keys as a precondition to re-enabling debug on returned units.
  6. Harden against fault injection: Triplicate and majority-vote critical fuse fields; double-check authentication verdicts in redundant logic.
  7. Default to locked: Debug gating signals must reset to the disabled state and require explicit authentication to open.
  8. Provide auditable status: Expose an authentication-status register so production test can confirm secure debug is actually engaged.

Conclusion

Secure debug is fundamentally an exercise in conditional trust: the chip must remain fully transparent to its rightful owner and entirely opaque to an attacker, with the boundary enforced cryptographically rather than by obscurity. Achieving this requires coordinating lifecycle states, challenge-response authentication, per-domain access gating, and tamper-resistant OTP into a single coherent root of trust - and tying it directly to secure boot so no path circumvents the policy.

Done well, the result is a device that engineers can debug, analyze, and return for RMA throughout its life, while never surrendering its firmware or keys to a malicious actor with a probe.

Vcores offers silicon-proven secure debug and security IP - including authenticated CoreSight-compatible debug access controllers, lifecycle management, and OTP-anchored key storage - to help you ship designs that are both debuggable and defensible.

Tags: secure debug JTAG security debug authentication chip security secure ASIC

Need IP Cores for Your Design?

Vcores offers silicon-proven IP cores for ASIC and FPGA designs. Get high-quality, verified IP with comprehensive documentation and support.

Explore Products Contact Us