Posts Tagged ‘eeprom crack’
Brute Force on EEPROM: Unlimited Reads, Limited Writes
A serial EEPROM attached to a microcontroller looks like the least interesting component on the board. It holds a few kilobytes, it has three or four pins, and it costs less than a connector. It is also, in a large fraction of designs, where the calibration constants, the serial number, the feature flags and sometimes the credential live — and unlike the microcontroller, it usually has no protection at all.
The reason is an asymmetry in the device’s physics. An EEPROM cell can be read an unlimited number of times. It can be written perhaps a million times, and the manufacturer will tell you so in the datasheet. Reading costs nothing; writing costs endurance. Every attack on an EEPROM is shaped by that asymmetry.
What the cell actually is
An EEPROM cell is a floating-gate transistor with a thin tunnel oxide. Charge placed on the floating gate shifts the threshold voltage, and the sense amplifier reads the shift. Writing moves charge onto the gate through Fowler–Nordheim tunnelling, which requires about 10 V and damages the oxide slightly each time. Reading applies a few volts to the control gate and compares the resulting current against a reference; it moves no charge and damages nothing.
This is why the endurance limit exists and why it applies only to writes. A device rated for a million write cycles will survive a billion reads. The read path is effectively free, and an attacker who understands this stops thinking about the secret and starts thinking about the array.
The array is small enough to enumerate
Serial EEPROMs come in three interface families, and all three support a sequential read that walks the entire array without any further addressing.
| Family | Typical sizes | Read command | Full array read time |
|---|---|---|---|
| I²C, 24Cxx | 128 B – 512 KB | Random read, then sequential | 10 ms – 3 s at 400 kHz |
| SPI, 25Cxx | 512 B – 1 MB | READ 0x03 with 24-bit address | 1 ms – 2 s at 20 MHz |
| Microwire, 93Cxx | 64 B – 16 KB | READ with auto-increment | 1 ms – 100 ms |
Even the largest device in the table is read in a couple of seconds. The smallest is read in milliseconds. There is no meaningful cost to reading the whole thing, which means there is no reason to be selective: the entire contents are on the bench before any analysis starts.
The practical consequence is that the enumeration is trivially complete. A 24C02 with 256 bytes is read byte by byte in a single burst; a 24C512 with 64 KB is read in one sequential transfer that the master can clock out as fast as the bus allows. There is no rate limit, no lockout, no attempt counter, because the protocol has no concept of authentication.
Where the attempt counter actually lives
The one thing an EEPROM cannot do is count. It has no state machine beyond the address pointer, no write-protect logic beyond a pin, and no notion of who is asking. So if a system needs to limit attempts at a PIN, the counter cannot be in the EEPROM’s logic — it has to be in the microcontroller, stored either in RAM or back in the EEPROM as a data byte.
That placement is the weakness. A counter in RAM is cleared by a reset if the design does not persist it, and a counter in EEPROM is a byte that the attacker can also write if the bus is accessible. The two common implementations therefore both fail against an attacker with bus access: one loses the count on power cycle, the other allows the count to be rewritten.
| Counter location | Survives power loss | Attacker with bus access |
|---|---|---|
| RAM only | No | Reset clears it |
| EEPROM byte, written each attempt | Yes | Rewritable, and wears out |
| EEPROM byte, written on lockout only | Yes | Rewritable before lockout |
| MCU internal flash, protected | Yes | Requires MCU-level attack |
Only the last row moves the problem to the microcontroller, and that is where the work becomes an MCU attack rather than an EEPROM attack.
Enumeration is not guessing
There is a distinction worth making explicit, because it changes the equipment. Guessing a secret means generating candidates and testing them; enumerating an address space means reading every location once and looking at what is there.
The second is almost always the correct approach on an EEPROM, because the secret is usually present rather than derived. A PIN stored as four ASCII digits occupies four bytes, and those four bytes are readable. A calibration constant is two bytes. A feature flag is one bit. Nothing is hidden by computation, because the device has no compute to hide it with.
Where the data is obfuscated, the obfuscation is almost always trivial: a byte-wise XOR with a constant, a nibble swap, or a byte-reversal of a multi-byte value. Each of these is detectable from statistics alone. A constant XOR preserves the distribution of byte values and produces a flat histogram where the plaintext would have had structure; a nibble swap produces a histogram with peaks at the swapped positions; a byte reversal leaves multi-byte counters running backwards, which is visible in any region that increments over time.
Reading it without the bus
When the EEPROM is on a bus that cannot be reached — because the microcontroller holds it, or because the board is potted — the device can be read directly. An SOIC-8 clip over the package is enough on most boards, and reading it in circuit works as long as the microcontroller is held in reset so that it does not drive the bus.
Holding the MCU in reset is the step that is usually skipped, and the symptom of skipping it is a read that returns plausible but inconsistent data: the MCU and the clip driver contend for the bus, and the resulting waveform is a wired-AND of two masters. The data looks like real data because the pull-ups make the idle state look like erased bytes.
Where the package is a TSOP or a BGA, in-circuit clipping is not possible and the part is read after removal. Removal is destructive to the board but not to the device, and it is the standard route for a one-off recovery.
What brute force contributes
The honest summary is that brute force contributes little to an EEPROM attack where the bus is accessible, and a great deal where it is not.
With bus access, the work is a complete read, and the analysis is pattern recognition. Without bus access, and where the only interface is a keypad or a serial command that accepts a PIN, the situation becomes a genuine brute force problem — and there the arithmetic is unforgiving. A four-digit PIN is 10,000 attempts; at one attempt per second that is under three hours. A six-digit PIN is 1,000,000 attempts, which is eleven days at the same rate. An eight-character alphanumeric is 2.8 × 10^12, which is ninety thousand years.
| Secret | Space | At 1 attempt/s | At 100 attempts/s |
|---|---|---|---|
| 4-digit PIN | 10^4 | 2.8 hours | 100 seconds |
| 6-digit PIN | 10^6 | 11.6 days | 2.8 hours |
| 8-char alphanumeric | 2.8 × 10^12 | 89,000 years | 890 years |
Those numbers are why the counter matters more than the space, and why a design that limits attempts to three is not defeated by arithmetic at all.
Where this sits in the service
The work we do at this layer is mostly not brute force. It is a complete read of the device, a statistical pass to identify structure, and a report that separates what is certainly stored from what is inferred. On EEPROMs with a trivial obfuscation we decode it and say so; on EEPROMs holding a genuine cryptographic key we extract the key and let the customer decide what to do with it.
Where the EEPROM’s contents are protected because the microcontroller enforces a read protection that covers the external bus, the problem stops being an EEPROM problem, and the route becomes the MCU-level one described in breaking IC code. Where the secret turns out not to be in the EEPROM at all — which happens more often than customers expect — the search moves to the four physical locations described in where the secret key lives. The feasibility arithmetic above is the same one that governs any other guessing problem, and it is set out in when brute force works.