From 1e58eb6928bcc2f1f37534fc67aeabd8f0835e51 Mon Sep 17 00:00:00 2001 From: Martin Vychodil Date: Tue, 1 Jun 2021 00:07:09 +0200 Subject: [PATCH] system/security: Memprot bypassing mitigation Check Memprot lock bit(s) during the system startup, abort/reset on any Memprot parts found locked during this phase. There is no legal reason to disallow the Memprot configuration by the system, so it's either a critical bug in the application or an malicious attempt to bypass the system security. Error message is printed before digital system reset. Closes IDF-2700 --- components/esp_system/port/cpu_start.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/esp_system/port/cpu_start.c b/components/esp_system/port/cpu_start.c index 59e9eb10ef..49c65306d9 100644 --- a/components/esp_system/port/cpu_start.c +++ b/components/esp_system/port/cpu_start.c @@ -480,6 +480,12 @@ void IRAM_ATTR call_start_cpu0(void) esp_cache_err_int_init(); #if CONFIG_ESP_SYSTEM_MEMPROT_FEATURE + // Memprot cannot be locked during OS startup as the lock-on prevents any PMS changes until a next reboot + // If such a situation appears, it is likely an malicious attempt to bypass the system safety setup -> print error & reset + if ( esp_memprot_is_locked_any() ) { + ESP_EARLY_LOGE(TAG, "Memprot feature locked after the system reset! Potential safety corruption, rebooting."); + esp_restart_noos_dig(); + } #if CONFIG_ESP_SYSTEM_MEMPROT_FEATURE_LOCK esp_memprot_set_prot(true, true, NULL); #else