Simvik

Anti-rollback with one-time fuses

Refuse old, vulnerable firmware by its security version, counted in one-time-programmable fuses. A medium embedded C problem (OTA updates and rollback), run…

medium · OTA updates and rollback · ota · security · otp · secure-boot

An attacker who can install a signed but old firmware can reopen a vulnerability that was already fixed. To prevent that, each image carries a security version, and the chip records the lowest one it will accept in fuses that can never be un-burned.

Write:

  • image_allowed(img): true if img->security_version is at least the number of burned fuses, and at most 32.
  • image_confirmed(img): called once a new image has booted and confirmed itself. Burn fuses so that the number burned equals the image's security version. Burn the lowest unburned bits, never more than needed, and do nothing if enough are burned already.

Use otp_burn as few times as you like, but never burn a bit that is not needed.

Starter code

bool image_allowed(const img_t *img) {
  return img->version >= otp_read();
}

void image_confirmed(const img_t *img) {
  otp_burn(img->security_version);
}

Example tests

Updates, then a downgrade attempt

try_image(500, 1);
try_image(503, 1);
try_image(600, 3);
try_image(503, 1);

Expected output:

v500 (security 1): allowed, fuses 0x00000001
v503 (security 1): allowed, fuses 0x00000001
v600 (security 3): allowed, fuses 0x00000007
v503 (security 1): refused

Learn it first

More OTA updates and rollback problems