Clock Glitches in Practice: Hitting the Path With the Least Margin
A clock glitch is the cleanest fault injection technique available on a microcontroller, and the reason is that it changes only one variable. The supply stays at nominal, the temperature stays where it was, and no analog node is disturbed. What changes is that a clock edge arrives earlier than the design expected, and a register somewhere samples a value that has not finished arriving.
This is why clock glitching is the first technique taught in every hardware security course and the last one that works on a real protected product. It is clean in the laboratory and awkward in the field, because the injection has to reach the clock input, and modern designs increasingly generate their clock internally.
Why an extra edge is enough
Synchronous logic is built on a promise: every path between two flip-flops settles within one clock period. The synthesis tool guarantees this by computing the longest path and choosing a period longer than it. The margin, the difference between the longest path and the period, is what keeps the chip working across temperature, voltage and process variation.
A clock glitch shortens one period. If the shortened period is still longer than the longest path, nothing happens. If it is shorter, the flip-flop at the end of that path samples a value that is still changing, and the sampled value is unpredictable but not random: it is biased towards whichever value was present earlier, because the input has had time to move partway.
That bias is important. It means a glitched comparison usually resolves one way, not fifty-fifty. Repeated identical glitches produce repeated identical failures, which is exactly what makes the technique usable: an attacker can learn the behaviour of one specific decision and then reproduce it on demand.
The margin is not uniform
The critical path that synthesis reports is the single worst path in the whole design. It is almost never the path that matters to an attacker. The paths that matter are the ones with the smallest margin among those that carry security-relevant decisions, and those are usually short, fast structures with plenty of slack.
| Structure | Typical slack | Why it is reachable |
|---|---|---|
| Byte comparison loop | Large | Loop increments dominate, so the compare can be shortened |
| Flag test after a crypto block | Moderate | Depends on the block’s last round |
| Branch on a status register | Large | Set by an earlier long operation |
| Address decode for a protected region | Small | Combinational, deep, and on the critical path already |
The fourth row is the interesting one. Address decoders and protection-state comparators are combinational logic in the middle of the memory path, and they are frequently close to the timing limit because the designer wanted the access fast. They are therefore the easiest targets, and they are also the least likely to be mentioned in a design review.
The practical implication is that an attacker does not need to know the netlist. Sweeping the offset of the glitch across an instruction boundary produces a map of which offsets produce a fault, and the shape of that map identifies the structure: a one-instruction-wide response is a flag test, a three-instruction-wide response is a comparison loop, and a broad response across many instructions is a clock domain problem rather than a targeted fault.
What an extra edge does to the pipeline
A pipeline complicates the model. In a three-stage pipeline, shortening one period corrupts the instruction in the execute stage, but the instruction in the fetch stage may also be affected if the fetch happens on the same edge. The result is that a single glitch can corrupt two instructions that are adjacent in time but not in program order, which produces failures that look incoherent until the pipeline is drawn.
On parts with a prefetch buffer the situation is worse, because the buffer decouples fetch from execute by several cycles. A glitch that lands on a fetch fills the buffer with a wrong instruction, and that instruction executes two or three cycles later, long after the glitch has ended. The symptom is a fault that appears several instructions after the injection point, and the offset has to be corrected by the buffer depth. Getting this wrong produces a sweep that finds nothing, because the operator is looking in the wrong window.
Determining the pipeline depth and prefetch behaviour is therefore part of the setup, not an optimisation. It is usually visible from the datasheet’s instruction timing table, and it can be confirmed by injecting a fault at a known instruction and observing where the failure appears.
Voltage and clock are not interchangeable
It is tempting to treat power and clock glitching as two ways of doing the same thing. They are not, and the difference is what each one can reach.
A voltage dip slows every path in the design at once, so the first path to fail is the one with the least absolute slack. A clock glitch shortens the window for every path at once, so the first path to fail is again the one with the least slack. The difference is in the side effects: a voltage dip disturbs the analog blocks, the oscillators, the ADC references and the brown-out detector, while a clock glitch disturbs none of them.
That makes the clock glitch preferable when the target involves an analog measurement or a clock-derived delay. It makes the voltage glitch preferable when the clock is generated internally and cannot be reached. The choice is a topological one, decided by the board, not by preference.
The offset is more important than the width
In a clock glitch the width parameter is the position of the extra edge relative to the nominal edge, and the useful range is narrow: a few nanoseconds on either side of the point where the target register would have sampled.
| Offset relative to nominal edge | Effect |
|---|---|
| Earlier than the previous edge | Two full periods collapse; usually a reset or a hang |
| Just after the previous edge | Previous instruction’s result corrupted |
| Just before the nominal edge | Target register samples early; the useful case |
| After the nominal edge | No effect on this cycle |
The third row is where the work happens, and it is a window of a few nanoseconds that moves with temperature. A rig that cannot resolve a one-nanosecond step cannot do this reliably, and a rig that can is usually a programmable delay line rather than a function generator.
Reading the failure
The output of a clock glitch attempt is one of four things, and each points at a different correction.
A clean reset means the glitch hit the reset logic or corrupted the stack badly enough to trigger a watchdog. Move the offset later.
A hang with the clock still running means the program counter reached an invalid address. Move the offset earlier and check whether the target instruction was the one that got corrupted.
A single wrong decision with no other symptom is the target outcome. Record the offset, the temperature and the clock setting, because the same numbers will be needed to repeat it.
A device that stops responding to the programmer entirely means the glitch corrupted the debug interface’s own state machine. Power cycle before concluding anything, and if the condition persists, the part may have entered a state that only a mass erase clears, which is a data-loss event rather than a setback.
Where this fits in recovery work
A clock glitch is used in recovery work for one purpose: to make a device accept an operation it would otherwise refuse, without erasing what it holds. That means landing a fault on the branch that evaluates read protection, or on the check that gates a debug command.
The boundary is firm. A glitch can corrupt a decision; it cannot create data that was never programmed, and it cannot defeat a protection enforced by a physical barrier rather than a conditional branch. Where the barrier is physical, the route is the one described in extracting IC flash. Where the decision is reached through a supply-sensitive path, the complementary technique is in power glitches.
The service we provide at this layer is characterisation rather than magic. We measure the offset window on the customer’s actual board, identify the pipeline depth that shifts the observed fault, and report whether the target decision is reachable from the clock input at all. On boards where the clock is generated internally and no clock pin is exposed, the answer is no, and saying so early is more useful than a long attempt. The injection-point question itself is treated separately in clock glitch injection points.