Hi devanl,
devanl wrote: ↑Mon Aug 03, 2020 9:11 pm
For example, if someone were to use their own RAM flash programming stub, would it be able to read out the decrypted flash contents, or would it still be limited to seeing the encrypted flash the same way as the UART bootloader itself?
This particular method doesn't work. With the DISABLE_DL_ENCRYPT and DISABLE_DL_DECRYPT efuses burned, the flash encryption module is disabled in hardware when the chip bootstraps into the download mode (based on the GPIO pins at SoC reset time). The only way to re-enable it is to trigger a full system reset into a different boot mode.
devanl wrote: ↑Mon Aug 03, 2020 9:11 pm
Is it expected that an attacker would likely to be able to bypass the decryption protection settings on the rev 3 bootloader and that turning it off entirely is the only reliable way to preserve flash encryption, or can I trust that it is reasonably secure?
Security researchers have shown that on ESP32 they can use the UART download mode to seed the internal RAM with some chosen values, and then reset and use fault injection to cause the CPU to skip some of the normal boot instructions and instead jump to the value seeded in RAM.
See our advisory here for CVE-2020-13629 (PDF).
This research was using a revision 1 ESP32, and the ROM code function targeted with the fault is not used if Secure Boot V2 is enabled. We don't know of any similar vulnerability if Secure Boot V2 is used, the verification and loading process is different. If Secure Boot V2 is not being used then the same approach described in the advisory is probably reproducible in the same way on ESP32 V3.
The recommended approach for ESP32 V3 is to enable Secure Boot V2, Flash Encryption, and to disable the UART Download Mode. This maximizes the number of protections in place, and makes the smallest possible "attack surface" for an attacker. However enabling Secure Boot V2 & Flash Encryption is sufficient against all the attacks we know of.
You should consider how motivated/resourced someone attacking your particular product will be, and what tradeoffs of functionality vs security may be acceptable. Note that even if you don't disable UART Download Mode initially, if you have an OTA update mechanism or similar then it's possible to flash an app which disables this mode in the field.