Secure Runtime for MCU Modules

IGL‑RV‑emb: Secure Runtime for MCU Modules (ARM Cortex‑M / RISC‑V)

It consists of:

• Host‑packer (PC): Validates WASM‑subset, lowers it into compact bytecode BC2, builds policies, and assembles the IGL‑PKG container (optionally signs and adds HW‑lock).

• no_std runtime (MCU): Verifies IGL‑PKG and executes BC2 in a VM, strictly enforcing policies.

Key principle: No uncontrolled side effects — external interactions are available only through permitted hostcalls.

Architecture (Components)

Host Side

1) Packer / Lowering (WASM‑subset → BC2 → PKG)

The packer takes a WASM subset, validates it against a whitelist, lowers it into compact stack bytecode BC2, and builds the IGL‑PKG container together with a policy.

  • Limits: locals / stack / linear memory
  • Effects control: hostcalls allowlist
  • Sandbox: MMIO allowlist ranges (deny‑by‑default)
  • Execution budget: GasV1 (max VM steps)
  • Optional binding: HW‑lock parameters (device identity)

2) Integrity & Authenticity

  • CRC32 for fast corruption detection (flash/transport)
  • P‑256 ECDSA signature for authenticity

Important: the signature protects not only the code, but also critical policy/flags, preventing “policy weakening” without breaking verification.

MCU Side (no_std)

1) Container Verify + Load

The runtime verifies:

  • Package header, section table, and bounds/overlap rules
  • CRC integrity
  • Policy/MMIO/Gas/HW‑lock sections (if present)
  • Runtime hard limits (stack/locals/memory constraints of this build)
  • Strict mode via package flags (required sections and checks)

2) Security Pipeline (Unified Contract)

Firmware should use a single entry point to avoid wrong verification order:

verify_and_load_module_v1(pkg, mem_len, ctx)

Pipeline behavior:

  • Verify structure + CRC + policy + strict requirements
  • Verify signature (only if required by flags)
  • Verify HW‑lock (only if required by flags)
  • Return ModuleRef for VM execution

3) VM Runtime

  • no_std VM with static buffers (no heap by design)
  • Traps on invalid opcodes, bounds violations, and denied operations
  • Step metering enforced by GasV1
  • External effects only via HostApi/HAL and allowlisted hostcalls

Recommended failure policy: on verification error, do not execute the module (fail‑stop), optionally with UART/LED diagnostics.