Glitching is fault injection in practice: a brief voltage dip or a shortened clock pulse delivered at exactly the wrong moment makes a processor skip an instruction, corrupt a comparison, or pass a check it should have failed. The lab skill is parameter discipline. A random glitch that works once teaches nothing, while a sweep that records every parameter and every outcome can be repeated, narrowed, and defended against. This sub-skill covers safe lab setup, sweep method, result classification, and recovery. Targets are sacrificial boards you own or devices you are authorized to test. Never glitch a device that must keep working, a device holding data you cannot lose, or a device outside your authorization.
Quick Workflow
- Pick a sacrificial target with a known check to attack, such as a PIN comparison or a secure boot signature check in a lab build.
- Instrument the target: a trigger output marking the check, a serial log for outcomes, and a reset line for recovery.
- Establish the clean baseline: the check passes and fails exactly as expected with no glitch applied.
- Define the sweep space: glitch delay range, glitch width range, and step sizes, kept small enough to finish in reasonable time.
- Run the sweep automatically, classifying each attempt as normal, crash, reset, or fault of interest.
- Narrow around any fault of interest with finer steps and repeated attempts to confirm repeatability.
- Confirm the successful fault end to end, such as a skipped check with the device actually proceeding past it.
- Record the full parameter set, success rate, and recovery method for every confirmed result.
1. Setting up a safe lab target
The target must be replaceable, the setup must recover without hands on the board, and the glitch hardware must stay within the target voltage limits. A voltage glitch that dips below the absolute minimum rating can damage silicon permanently, so set hardware limits on the glitch supply before the first sweep.
# Baseline check: the target must behave deterministically with no glitch
# Run the check 20 times clean and confirm 20 identical outcomes
cat > baseline-check.sh <<'EOF'
#!/bin/bash
# Replace the trigger command with the actual lab target control
for i in $(seq 1 20); do
echo "baseline attempt $i - expected result: check fails with wrong PIN"
# trigger-target-check --pin 0000
done
EOF
chmod +x baseline-check.sh
./baseline-check.sh | sort | uniq -c
#!/usr/bin/env python3
"""Sweep plan - compute the attempt count before starting, so a sweep
that would take days is caught on paper instead of on the bench.
"""
delay_start_us, delay_end_us, delay_step_us = 100, 500, 5
width_start_ns, width_end_ns, width_step_ns = 50, 500, 25
delays = (delay_end_us - delay_start_us) // delay_step_us + 1
widths = (width_end_ns - width_start_ns) // width_step_ns + 1
total = delays * widths
print(f"delays - {delays}, widths - {widths}, total attempts - {total}")
print(f"at 2 seconds per attempt, about {total * 2 / 60:.1f} minutes")
if total > 5000:
print("WARNING - sweep is large, narrow the ranges or widen the steps")
2. Running a voltage glitch sweep
Drive the glitch from the trigger, not from a timer. The trigger marks a known point, such as the start of the check, and the delay counts from there. Log every attempt with its parameters and its outcome, so a success can be repeated exactly.
#!/usr/bin/env python3
"""Voltage glitch sweep driver with per-attempt logging.
The glitch hardware calls are placeholders for the API of the device
actually on the bench. The structure is what matters: one attempt,
one log line, automatic reset before the next attempt.
"""
import csv
import time
def apply_glitch(delay_us, width_ns):
"""Deliver one glitch. Replace with the bench hardware API."""
# glitcher.set_delay_us(delay_us)
# glitcher.set_width_ns(width_ns)
# glitcher.fire()
return "normal" # placeholder outcome for the template
results = []
with open("glitch-sweep.csv", "w", newline="") as fh:
writer = csv.DictWriter(fh, fieldnames=["delay_us", "width_ns", "outcome"])
writer.writeheader()
for delay_us in range(100, 501, 5):
for width_ns in range(50, 501, 25):
outcome = apply_glitch(delay_us, width_ns)
writer.writerow({"delay_us": delay_us, "width_ns": width_ns, "outcome": outcome})
results.append(outcome)
time.sleep(0.1) # let the target settle before reset
# reset_target()
from collections import Counter
print("sweep complete - outcome counts:")
for outcome, count in Counter(results).most_common():
print(f" {outcome} - {count}")
3. Classifying outcomes and confirming a fault
Most attempts do nothing, some crash the target, and very few do the interesting thing. Classify strictly, or crashes get mistaken for successes.
#!/usr/bin/env python3
"""Classify glitch sweep results and list candidates for confirmation."""
import csv
from collections import Counter
rows = list(csv.DictReader(open("glitch-sweep.csv")))
counts = Counter(row["outcome"] for row in rows)
print("outcome counts:")
for outcome, count in counts.most_common():
print(f" {outcome} - {count}")
print("\ncandidates for confirmation (fault of interest only):")
for row in rows:
if row["outcome"] == "fault-of-interest":
print(f" delay {row['delay_us']} us, width {row['width_ns']} ns")
print("\nconfirmation rule - repeat each candidate 20 times, require at")
print("least 3 identical faults before calling it repeatable")
# Confirm a candidate end to end: the check must actually be skipped,
# not just the target crashing past it in an unusable state
# 1. Apply the candidate parameters
# 2. Confirm the target proceeds past the check into normal operation
# 3. Confirm the target still responds to serial and debug afterwards
# 4. Record the success rate over 20 repeated attempts
echo "candidate confirmation checklist - see section 3 above"
4. Recovering a bricked-looking target
A target that stops responding after a glitch is usually not dead: it is crashed, stuck in a fault handler, or held in reset by the glitch hardware. Recover in order: release the glitch output, pulse the hardware reset line, power cycle the target, and only then consider reflashing. Keep a known good firmware image and a working debug connection for the target, so recovery by reflash is always available.
# Recovery sequence, least invasive first
# 1. Release glitch hardware output (stop driving the supply or clock)
# 2. Pulse hardware reset and watch the serial log for a boot
# 3. Power cycle the target and watch for a boot
# 4. If still silent, check the debug connection before assuming damage
openocd -f interface/cmsis-dap.cfg \
-c "transport select swd" \
-c "init" -c "dap info 0" -c "shutdown" 2>&1 | head -10
echo "if the DP IDCODE reads, the chip is alive and reflash can recover it"
Edge cases
- Sweep too large to finish: narrow the delay range around the check first with a coarse sweep, then refine only the promising region.
- Success rate near zero: a single success in thousands of attempts may be luck or a measurement artifact. Require repeats before reporting it.
- Target damaged by the glitch: stop immediately, check supply voltages and current draw, and compare against the baseline. A target that draws excessive current after a glitch may be permanently damaged.
- Clock glitch on a target with an internal oscillator: external clock glitches only work where the target actually uses an external clock. Check the clock source before sweeping clock parameters.
- Trigger jitter: a trigger that moves by microseconds between attempts smears the sweep. Fix the trigger source, such as using a GPIO toggle inside the check rather than a serial message, before sweeping.
- Fault passes the check but crashes later: a skipped instruction can corrupt state that fails elsewhere. A fault only counts when the device proceeds into usable operation past the check.
- Countermeasures present: redundant checks, fault detectors, and timing monitors are designed to catch exactly this. A clean failure to glitch a hardened target is a valid, reportable result.
Key references
- The parent glitching-attacks skill for voltage and clock glitch concepts and fault models.
- The parent side-channels skill for measurement setup discipline that also applies to glitch triggering and logging.
- Chip vendor datasheets for absolute maximum ratings, which set the hard limits for any glitch voltage.
- Published fault injection research on parameter sweep method and on defenses such as redundant checks and fault detectors.
