Copy protected Firmware

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
Simanas
Posts: 1
Joined: Mon Feb 22, 2021 1:16 pm

Copy protected Firmware

Post by Simanas » Mon Feb 22, 2021 1:35 pm

Hello guys!

First of all thank you so much for developing this. It's amazing! I am senior Python developer and just recently got in to micro-controllers. Started with Arduino, got a chance to remember high school times, c++ memory management, all that good/nasty stuff, eventually I got out of memory even without using any strings, so then I switched to ESP32. And what a a relief! It's hard to describe in words, but it feels like I got a chance to ride my childhoods old crappy carburated moped for a few months and now I am back to my Porsche 911! It's just that great! So thank you all for doing this. Your work is really appreciated. Thank you for everyone!

Now to the point... I tried googling on how can I secure my firmware written with MicroPython didn't managed to find anything concrete enough. As I understood there were some progress over the years with the introduction of Partitions... encryption...

Anyways I just wanted to ask what is the most that I can do with current MicroPython version to secure my firmware from being copied. I do not want to see copies of my device start popping up on aliexpress as soon as I launch my product.

I already designed my PCB without usb interface, so in order to upload a firmware separate controller will be needed, I am also planning on freezing my python scripts and baking them in to the custom build binary. Other than that, what more can I do to make it copy protected?

User avatar
jimmo
Posts: 2244
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Copy protected Firmware

Post by jimmo » Wed Feb 24, 2021 12:43 am

Simanas wrote:
Mon Feb 22, 2021 1:35 pm
I already designed my PCB without usb interface, so in order to upload a firmware separate controller will be needed, I am also planning on freezing my python scripts and baking them in to the custom build binary. Other than that, what more can I do to make it copy protected?
There's been several threads on this in the past, but the long story short is that you first have to define what your threat model is -- i.e. how determined your attacker is -- and how much effort you're prepared to put into it.

Freezing your code goes a long way. Pretty much the practical upshot is that someone will be able to copy your firmware and sell cloned hardware running the same firmware, but it will not be easy for them to modify or customise your firmware. Not easy, but definitely not impossible. (I'm not aware that anyone has written a useful decompiler for MicroPython bytecode yet).

Encrypting helps because it prevents someone from being able to dump the spiflash directly. (Most ESP32 designs have the code stored in external spiflash). I'm not entirely sure what the current support for encrypted spiflash in MicroPython is.

One of the main risks is that the UART is typically accessible. You said that you've removed the USB interface chip, but like you say someone can then connect to the UART directly and if the REPL is still enabled then an attacker can use that to access anything they like (including accessing the contents of RAM and ROM).

Post Reply