Posts Tagged ‘decode smartcard’

PostHeaderIcon The Smartcard Arms Race: Five Generations of Countermeasures

No other class of chip has been attacked as consistently, as publicly, or for as long, as the smartcard. The reason is structural: the card is physically in the hands of the person who wants to defeat it, it has no power source of its own, and it must reveal its answers to a reader that the attacker controls. Every defensive technique in modern embedded security was developed, tested, and broken on a card first.

The history is worth studying because it is a ladder. Each rung is a countermeasure, and each rung was climbed by an attack that then forced the next rung. The pattern repeats with enough regularity that it predicts where the current generation is vulnerable.

Generation one: secrecy of the algorithm

The first generation relied on the algorithm being unknown. A proprietary cipher implemented in a proprietary way, with the specification held by the issuer, was considered sufficient because an attacker who did not know the algorithm could not compute anything useful.

This generation lasted until the tooling for reading a die became affordable. Once the mask ROM could be imaged, the algorithm was a pattern on silicon, and recovered algorithms could be published. The lesson that survived is that an algorithm embedded in a device the attacker holds is not secret, regardless of how few people were told.

Cost of a break at this generation: one decapsulation and a microscope.

Generation two: storage protection and passwords

The second generation moved the defence from the algorithm to the data. The card refused to release its keys unless a password was supplied, and the password was compared in the card’s own logic.

This lasted until it became apparent that the comparison itself could be observed, and until the retry counter turned out to be a few bytes of EEPROM that could be reset by disturbing the supply at the right moment. A counter is a defence only if the state survives the attacker’s ability to cut power; on a card whose power is supplied by the attacker through two contacts, cutting power is trivial.

Defence What it assumed What broke it
Password check Attacker cannot observe the comparison Timing and power analysis
Retry counter Attacker cannot remove power Power cut at the counter write
Locked memory Lock cannot be removed Glitch on the lock check

Generation three: randomness in time

The third generation attacked the observability rather than the logic. If the leak is in the timing, then random delays and randomised clock should destroy the measurement.

Random delays do raise the required sample count, and that is a real cost. But averaging reduces random noise by the square root of the sample count, so a defence that multiplies the required samples by a hundred increases the attacker’s work by a hundred, which is a week rather than a year. The economics of the defence were wrong even though the mechanism worked as designed.

The lasting lesson is one that applies to any product, not just cards: a defence whose strength is a constant factor is a defence against amateurs only. Copy protection that adds a hundred to the attacker’s workload is defeated by anyone with patience, and patience is the one resource attackers have in abundance.

Generation four: environmental sensors

The fourth generation added sensors. Voltage detectors, frequency detectors, light detectors and temperature detectors watch for the conditions that fault injection requires, and the card resets or destroys its secrets when a condition is out of range.

This forced a shift in technique rather than ending the attack. A sensor is a comparator, and a comparator has a threshold, and a disturbance that stays just inside every threshold is still a disturbance. The result was a period in which attacks were characterised by careful shaping of the glitch to be invisible to each detector simultaneously — a multi-dimensional constraint problem rather than a single waveform.

The sensors also created a new failure mode, which is worth noting because it affects legitimate users: a card operating at the edge of its supply tolerance in a poorly designed reader can trigger its own protection and become unusable. Devices that destroy secrets on out-of-range conditions must be specified with margins that real readers satisfy, and many were not.

Generation five: shielding, self-destruction, and true randomness

The current generation combines a metal shield over the die with a tamper mesh that shorts the supply when cut, a light sensor under the shield, and a hardware random number generator whose output is not derived from any predictable source.

The mesh is the significant change, because it turns a physical attack into a destructive one: opening the package to reach the die breaks the mesh, and breaking the mesh destroys the state. The attack therefore has to be conducted without breaking the mesh, which means either from the front through the die’s own substrate, or by finding an electrical path that bypasses it.

Generation Primary defence Break cost Era
One Algorithm secrecy Hours of microscope work 1980s
Two Password and lock bits Days 1990s
Three Randomised timing Weeks Late 1990s
Four Environmental sensors Months 2000s
Five Shield, mesh, true RNG Years, or not at all 2010s onward

Why the newest generation is not the target

The economics of the arms race are decided by something other than the newest card. An attacker who wants to clone cards does not need to defeat the current generation; he needs to defeat the weakest generation still accepted by the system.

Card systems have long lifecycles. A scheme deployed in 2005 is still accepted in 2026 on some networks, and the cards issued in 2005 are generation three. The population of deployed cards is therefore a mixture, and the attacker’s problem reduces to finding a cohort whose defence is several rungs down the ladder and whose credentials are still valid.

That is why issuers who upgrade their newest cards while leaving old ones accepted have not improved their security at all. The security of a system is the security of its weakest accepted credential, and this is as true for a payment network as it is for a firmware update scheme.

The same ladder in ordinary products

The five generations map onto ordinary embedded products with uncomfortable accuracy.

A device whose protection is a password in the firmware is generation two. A device that adds random delays to its authentication is generation three. A device with a voltage detector that resets on out-of-range supply is generation four. Almost nothing in the consumer and industrial market reaches generation five, because a shield and a mesh cost more than the microcontroller.

This is not a criticism. It is a statement about what an assessment should expect, and about how much work a recovery job will take. A generation-two device is a side-channel job measured in days; a generation-four device may be a physical job measured in months; a generation-five device is usually declined.

Where an assessment fits

The service at this layer is a generation assessment: identify which rung a given product occupies, state what a break at that rung costs, and say whether the answer is economic. That assessment is made from the board and the firmware, not from the marketing material, and it takes a day.

The techniques that climb the lower rungs are the ones described in where timing leaks and glitch attacks as a search problem. The reason the ladder exists at all, and the specific conditions that made cards the first place it was climbed, is the subject of why side channels were born in set-top boxes. Where the rung is high enough that no economical route exists, the honest deliverable is that finding, and the alternative for the customer is usually a functional clone assembled from behaviour rather than a key recovery, as described in recovering an IC program.