Tutorial: Security Hardening, Runtime policy Gate & Crash Core Dump
PylotOS combines ESP-IDF v5.5.6 silicon security primitives with a session-aware MicroPython capability gate (pylotos.policy) and persistent Flash ELF Core Dump diagnostics (0x13000).
1. Runtime Action Policy Engine (pylotos.policy)
Every remote request arriving over :8266 HTTP/JSON, the LAN AI MCP Bridge, or inbound MQTT command topics is classified into three deterministic outcomes:
| Decision | Constant | Meaning | Example Actions |
|---|---|---|---|
| Allow | policy.ALLOW | Safe read-only telemetry or local physical UI input. | board.describe, sys.mem, apps.list, display.screenshot, diag.coredump |
| Ask | policy.ASK | State-mutating remote action; prompts on-device ConfirmDialog unless ota_key challenge-response or session approval is active. | apps.write, apps.run, ota.flash, nvs.set, sys.reboot |
| Deny | policy.DENY | Hard non-overridable block: protects secret credentials from remote exfiltration even during approved sessions! | Remote nvs.get / config.get on wifi_pass, ota_key, admin_pass, gh_token, mqtt_pass, *_token, *_secret |
from pylotos import policy
# 1. Safe read-only telemetry -> ('allow', 'read-only action')
dec, reason = policy.evaluate("board.describe", source="lan")
# 2. Mutating app upload -> ('ask', 'on-device confirmation required')
dec, reason = policy.evaluate("apps.write", target="thermostat.py", source="lan")
# 3. Secret exfiltration attempt -> ('deny', 'protected credential cannot be read remotely')
dec, reason = policy.evaluate("nvs.get", target="wifi_pass", source="lan")
assert dec == policy.DENY
2. Flash ELF Core Dump (0x13000) & Crash QR Diagnostics
Every asym-v1 partition table allocates 52 KiB at 0x13000 for CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH=y (ELF format):
import hal
info = hal.coredump_info()
if info.get("present"):
print("Crash ELF captured:", info["size"], "bytes")
first_kb = hal.coredump_read(0, 1024)
# After uploading to your workstation or AI MCP agent (`get_coredump`), clear the slot:
hal.coredump_erase()
When a board reboots after a C panic or watchdog fault, PylotOS automatically surfaces a Crash Summary & Scannable QR Code in Diagnostics so field engineers can capture the PC/backtrace with a phone camera even without USB-C access.
3. Opt-In Silicon Security Build Profiles
When compiling custom fleet firmware in PylotOS/pylotos:
--security-profile hmac_nvs— Encrypts NVS using an eFuse HMAC key (zero external flash key exposure).--security-profile sbv2_fe— Enables Secure Boot v2 + XTS-AES Flash Encryption.--security-profile tee— Enables the hardware Trusted Execution Environment (ESP-TEE) onESP32-C6.--debug-sanitizers— Enables stack-smash protection and heap poisoning during driver bring-up.
Try the interactive Policy & Config explorer right now:
pylotos-sim examples/app_config_and_policy_demo.py --board m5stack_core2 --port 8080