Posts Tagged ‘fpga program hack’
Tampering Needs Rewritable Memory: Why OTP Ends the Conversation
A request to change a device’s behaviour is a request to change the bytes it executes. Whether that is possible is decided by the storage technology before any consideration of protection, because a technology that cannot be rewritten cannot be modified no matter how accessible it is.
This is the first question to settle, and it splits requests into two groups that need different answers.
The storage question
Four storage technologies appear in programmable devices, and only two of them can be rewritten.
| Technology | Rewritable | Modification possible |
|---|---|---|
| Flash | Yes, thousands of cycles | Yes |
| EEPROM | Yes, millions of cycles | Yes |
| OTP fuse or antifuse | No | Only in one direction |
| Mask ROM | No | No |
The first two rows are the cases where modification is a technical exercise. The last two are the cases where it is impossible in the ordinary sense, and the work becomes either a replacement or an exploitation of something outside the storage.
Why OTP is not entirely absolute
OTP is one-time in the sense that a bit can be moved from its unprogrammed state to its programmed state once. That is a direction, not an absolute.
On most OTP technologies the unprogrammed state reads as one and programming moves it to zero. A bit that is already zero cannot be moved back. So a modification is possible only if it consists of changing ones to zeros in a location that is still programmable.
| Change | Possible in OTP | Why |
|---|---|---|
| 1 to 0 at a programmable location | Yes | The remaining budget |
| 0 to 1 anywhere | No | Irreversible |
| A branch opcode rewritten | Only if the new encoding is a subset | Encoding dependent |
| A constant reduced | Possibly, by clearing bits | Value dependent |
| A constant increased | No | Requires setting bits |
The third row is the interesting one and it is occasionally exploitable. Some instruction encodings allow a conditional branch to be changed into an unconditional one by clearing a bit, because the condition field is a small number of bits and the unconditional encoding is a special case of it. Where that is true, a single bit clears a check on a device that was supposedly unmodifiable.
The fourth row is the same idea in data: a limit that is a power of two minus one can be reduced by clearing bits, which is why the choice of a limit value matters on a one-time device.
Mask ROM
Mask ROM has no programmable state at all. The pattern is fixed at fabrication.
A mask ROM device cannot be modified by any means that operates on the device’s contents. What can be done is to replace the device with an equivalent that behaves differently, which is the reconstruction work described in recovering an IC program, or to change the system around it so that the unmodified behaviour is no longer the limiting factor.
| Approach | Modifies the device | Effort |
|---|---|---|
| Emulator in place of the device | No, substitutes | Days to weeks |
| Replacement with new logic | No | Weeks |
| System-level workaround | No | Variable |
| Modification of the ROM | Not possible | — |
The third row is worth considering before the first two, because it is frequently cheaper. A device whose behaviour is fixed can often be accommodated by changing the board, the host or the surrounding logic, and that is an engineering solution rather than a reverse engineering one.
What modification requires beyond rewritable storage
Rewritable storage is necessary and not sufficient. Three further conditions have to hold.
The image has to be understood well enough to locate the change, which is the boundary and function work in MCU break. The integrity mechanism has to be satisfiable, which is the recomputation problem in patching IC code. And the device has to be re-programmable in the field or on the bench, which requires access to the programming interface.
| Condition | If absent |
|---|---|
| Rewritable storage | Not possible |
| Located change point | The patch cannot be placed |
| Satisfiable integrity check | The device refuses the image |
| Programming access | The patch cannot be written |
The fourth row is the one that is overlooked in a design that is otherwise modifiable. A device whose flash is rewritable but whose programming interface is locked has storage that can change and no way to change it.
The two directions of a modification request
Requests arrive in two forms, and they have different difficulty.
Removing a restriction is the common case, and it is usually a branch. The change is small, its location is findable, and its effect is immediate.
Adding a feature is the harder case, because it requires code that was never written. The space for it has to be found, which is the placement problem in minimal firmware injection.
| Request | Change | Difficulty |
|---|---|---|
| Skip a check | One branch | Low |
| Change a limit | One constant | Low |
| Enable an unused feature | A branch plus configuration | Medium |
| Add a new behaviour | New code plus a hook | High |
| Change an algorithm | Many locations | High |
What to tell a customer before quoting
The storage question is answerable from a part number in ten minutes, and it prevents the most wasteful category of engagement.
| Storage | Answer to a modification request |
|---|---|
| Flash or EEPROM | Feasible; cost depends on the change |
| OTP with remaining budget | Possibly feasible; depends on the specific change |
| OTP fully programmed | Not feasible by modification |
| Mask ROM | Not feasible; consider substitution or system change |
The second row is the one that requires care, because “possibly” is not a useful answer to a customer who needs a decision. The way to resolve it is to check the specific change against the encoding: a branch that can be made unconditional by clearing a bit is feasible, and a constant that has to increase is not.
What the service covers
For a modification request we establish the storage technology, the remaining programmable budget if the technology is one-time, the location of the change, and the integrity mechanism. The quotation follows from those four, and it is either a patch or a refusal with an alternative.
| Finding | Deliverable |
|---|---|
| Flash, no integrity check | A patched image |
| Flash with a CRC | A patched image and a recomputed value |
| OTP with a bit-clearing patch available | A patched image, tested |
| Mask ROM | A statement, plus a substitution or system route |
The alternative for a device that cannot be modified is the substitution route in behavioural reconstruction, which is more expensive and does not require the device to change. The protection that would have to be defeated on a rewritable device is a separate question, and it is set out in three protection layers.