Need To Dump A Protected STM32F0x? Use Your Pico!

Dumping script window, showing the bytes being dumped one by one from the STM chip

Sometimes, security mechanisms can be bypassed if you just do things slightly out of the ordinary. For instance, readout protection on microcontrollers is a given nowadays, to the point where it’s intentionally enabled and relied upon as a major technical measure to protect intellectual property. The gist is — when you connect to a microcontroller over its debug interface and then ask to read its flash memory, it will politely refuse. However, [Racerxdl] shows us that in practice, it’s not flawless protection – for certain chips, you just need to be a little quicker than usual.

Usually, flashing and debugging software will chat with the microcontroller for a bit, and probe parameters before going for any direct requests. However, if you skip the courtesy and bluntly get to the point immediately right after power is applied to the microcontroller, you can intimidate them just enough to give you one byte of its memory before it refuses to cooperate further. Since that can be any byte you wish, you can read the entire flash — one byte at a time.

You need to power cycle the chip before you can progress, so the hardware does involve a bit more than just an SWD interface, and it will take a fair bit more time than reading out a non-protected chip the usual way; plus, of course, the debugging interface needs to be active for this in the first place, which isn’t always the case. However, it still beats paying a few thousand dollars for a factory in China to decap your chip and read it out using a fancy machine.

[Racerxdl] didn’t just write a proof-of-concept for this attack – they implemented it for one of our favourite chips, the RP2040. As such, you no longer need an unobtainium STM32 to dump an unobtainium STM32.

To be clear, [Racerxdl] didn’t design this attack — it’s been around for some time now. Credit for that goes to Johanes Obermaier. All in all, this is a wonderful reminder that seemingly reliable security mechanisms can be foiled by the simplest tricks. For instance, if your chip erases the flash when you unlock its protection, you can just tell it not to.

21 thoughts on “Need To Dump A Protected STM32F0x? Use Your Pico!

    1. Right to repair, for instance. Here, just downstairs, you can see [CJay] talking about repairing their 3D printer that the company won’t provide controller chip images for. You just know the printer’s running slightly modded open-source software, possibly even under GPL – but that won’t stop the company from not providing you with sources! Extra points because in [CJay]’s situation, the fault is caused by the manufacturer’s bad design decisions, too.

  1. There actually is an exploit against those chips (for the CC2510 at least), I’m writing a blog post about this, please remind me in about a week if I forget to post here.

      1. Trivially – the reason they’ve been out of stock is because demand has far outstripped supply. Making a new design? Sure, stick a different chip in it. But reworking an existing design often costs far more than just paying the premium.

      2. Because it’s not quite as easy as ‘just use an alternative’ when you have an existing codebase, hard earned knowledge, significant investment in toolchain, range of products etc. which use one particular processor line.

        Sure, it’s possible but it’s not a fast process and what’s to say the PADAUK or Pi chips won’t dry up in the exact same way?

        Plus, PADAUK chips, RP2040 etc. don’t have anywhere near the performance of some of the STM32 chips, nor do they have the IO capability so it’s not a trivial drop in replacement, it’s a considerable investment in engineering and re-design for, potentially, much lower performance which all costs a *lot* of money.

  2. I spent far too long wondering when ST had introduced FOX chips and how I’d missed the announcements before I realised the headline should probably say F0x.

    Nice collection of hacks though, I have a use for one of them to recover firmware for a bricked, closed source 3d printer where the careless replacement of a hot end has cooked a GD32F103 chip and the manufacturer’s solution is ‘buy a new board’.

    I’d consider just replacing it with an open source alternative but it’s not my machine.

      1. It’s actually a GD from the factory but not the usual F103C8T6, it’s a slightly larger variant with 64 pins, I’ve already got a replacement part (tacked it onto a larger LCSC order) but obviously need the code which I’m going to try and extract from a working printer.

    1. oh that’s wonderful! if you manage to pull this off, take a few pictures&screenshoits, write some text, post it somewhere and then submit it to us, we’d gladly cover it!

      RE FOX: hehe yeah it’s just our font – the actual headline I used is F0x, and you can see the f0x in the URL too.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.