Custom firmware (Safely disabling WEBREPL and REPL) #12303
-
Hi, I'm developing a custom firmware for a plant that will allow users to run small portions of python code through a webserver on an ESP32. The problem is that I need to manage this well, because malicious users can try to use the REPL to gain access to the plant/code, and I would like to protect the firmware and prevent the use of REPL and WEBREPL. I already searched the forums, but I found some things about ESP8266 that didn't help me a bit, so I had to investigate on my own... [WEBREPL] I managed to disable webrepl import by changing manifest.py in (lib\micropython-lib\micropython\net\webrepl), I thought that just changing "mpconfigboard.h" was enough, however it wasn't (I didn't quite understand why)...so I did both. [REPL] I managed to disable repl by changing "mpconfigboard.h" and using MICROPY_HW_ENABLE_UART_REPL (0), it worked fine in my attempts, but should I be worried about something? I know a malicious user could copy the fiwmware, however that wouldn't be a problem if he can't edit easily... I would like to know if this was the best and safest methodology to avoid using REPL and WEBREPL. Thank you for your attention. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 8 replies
-
To completely omit the As to the rest of your questions, unfortunately I am ill-equipped to provide definitive advice on securing your micropython instance. |
Beta Was this translation helpful? Give feedback.
-
If you have pre-written functions that you want to be able to run in demand via web browser (ie using microdot server), you can freeze your code into a custom firmware build that's got the entire compiler disabled. This way even if they get to a uart interface, the repl won't exist at all. That being said I've often just disabled the uart/USB interface to repl, either via compile args like that or even just with dupterm. |
Beta Was this translation helpful? Give feedback.
-
Note that on a esp8266, without any option to even try to encypher the code, physical access is the end of security. You can add a few more speedbumps such as name mangling, minification, and perhaps @viper or similar decorators and that may be worth the effort. Threat_Modeling helps you think out what and how you can improve security, and avoids bolting down the front door while leaving the gardendoors open. If you really need to protect the software op on the device, you will need more capable MCUs |
Beta Was this translation helpful? Give feedback.
-
To completely remove "webrepl" from the firmware, you need to modify 4 files in the micropython directory
|
Beta Was this translation helpful? Give feedback.
To completely remove "webrepl" from the firmware, you need to modify 4 files in the micropython directory