Validating that my code is safe on the board - some help please! #17536
Unanswered
sotpotatis
asked this question in
Other
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
I am working on securing an ESP32 microcontroller with flash encryption and secure boot. I don't want to blindly trust that the commands given in the docs without verifying it myself.
Especially because I recently found out that the flash encryption didn't behave as I expected
I am using a GPY board, made by a company called Pycom. Unfortunately this company no longer exists and their forums are shut down.
This is their port's source code: https://github.com/pycom/pycom-micropython-sigfox
However, I believe that the process of securing their firmware is the same as any other ESP32 device.
What I want to verify is that the code that is on the device (Python files) can not be read by anyone that doesn't have access to the keys used to encrypt it.
I will put my questions at the end of this post after telling you what I've done to try invesigating if you can read out the source code of the device:
I believe I have enabled secure boot and flash encryption. I use the following commands for that:
keys are generated using:
If I perform a readout of the flash using
esptool.py -p /dev/ttyUSB0 --no-stub read_flash 0x400000 0x400000 flash_contents_after_enc.bin --flash_size 8MB
(as suggested by robert-hh in another discussion),I can not find a trace of the source code in the
.bin
file (only this):Same if I use the on-device REPL:
and also if I list the
/flash
and/flash/lib
folder, there are no traces of my code there.Also looked at the efuse summary:
From this it looks to me that flash encryption and secureboot is enabled. I assume that
??
means that the keys are burnt correctly.Now to my questions:
Main question: As I said above: What I want to verify is that the code that is on the device (Python files) can not be read by anyone that doesn't have access to the keys used to encrypt it.
I do not know how to validate this. I have only dumped the flash as I would assume that it would be where the source code code would be located if the encryption didn't work, but this is 95% guesswork. Should I dump another part of the memory (the factory partition?) Is there any other command I can consult to validate that the code is encrypted? Recall I am using a 3rd party Micropython port. You can find the partition layout for my board here: https://github.com/pycom/pycom-micropython-sigfox/blob/a37510c092bcec00671c924accb97dcdfa2f4b5d/esp32/boards/GPY/script_8MB_enc (I assume I should look at the
_enc
file and not the file without that prefix)Bonus question: The ESP32 docs say that
These fuses are all set to
False
if I look at the EFUSE summary - shouldn't they beTrue
, or am I mistaken?Thanks for any help!
Beta Was this translation helpful? Give feedback.
All reactions