TL;DR
This paper explores using minimal virtual machines (VMs) on resource-constrained IoT microcontrollers for secure code isolation. They introduce rBPF, a register-based VM derived from eBPF, and compare its performance and memory footprint against a WebAssembly (Wasm) VM. The findings suggest rBPF offers a compelling solution for isolating small, updatable IoT modules with significantly lower memory overhead than Wasm.
What Problem Does This Paper Address?
The proliferation of Internet of Things (IoT) devices, built on low-power, memory-limited microcontrollers, presents a growing security challenge. While virtual machines (VMs) are a standard approach for isolating software modules and enhancing security in larger systems, their substantial memory and processing requirements have historically made them impractical for these tiny embedded devices. This paper addresses the need for lightweight, software-only VM solutions that can provide process isolation on microcontrollers, enabling secure execution of potentially untrusted or updatable code without requiring specialized hardware. This is crucial for mitigating various IoT attacks and establishing a root of trust.
Methods
The authors investigate two minimal VM approaches:
- WebAssembly (Wasm): They use the WASM3 interpreter, a stack-based VM designed for portability and sandboxing. Wasm applications are compiled from various languages (like C/C++, Rust) to Wasm bytecode, which is then interpreted.
- rBPF (register-based Berkeley Packet Filter): This is a novel VM designed by the authors, based on the extended Berkeley Packet Filter (eBPF) architecture. Unlike Wasm's stack-based model,
rBPFis register-based, aiming for a minimal memory footprint. They adapted eBPF to be ISA-compatible and integrated it into the RIOT IoT operating system, providing bindings for OS facilities and event triggers.
Both VMs were implemented and tested on commercial off-the-shelf IoT hardware (Nordic nRF52840 Development Kit). They designed two benchmarks: a computational benchmark (Fletcher32 checksum) to assess basic VM performance and memory impact, and a networked benchmark simulating a CoAP-based sensor reading application to evaluate real-world IoT use cases.
Datasets
Not discussed in the paper. The evaluation uses custom benchmarks and real-world IoT application scenarios rather than pre-existing datasets.
Key Insights and Ideas
- Memory Footprint is King for IoT: The most striking insight is the dramatic difference in memory requirements. While Wasm VMs can double the firmware size for a simple IoT application,
rBPFadds only a negligible amount of memory overhead (less than 10%). This is a critical differentiator for resource-constrained devices. rBPF's Register-Based Architecture Pays Off: The register-based design ofrBPF, in contrast to Wasm's stack-based approach, significantly reduces the pressure on RAM. This is a key factor in its superior memory efficiency.- Tolerable Performance for Specific IoT Tasks: While both VMs introduce execution time overhead compared to native code, this overhead is deemed tolerable for low-throughput, low-energy IoT applications.
rBPFis about twice as slow as Wasm for the tested checksum algorithm, but both are orders of magnitude slower than native execution. rBPFOffers a Promising Software-Only Isolation:rBPFprovides a viable software-only solution for isolating small, updatable modules without requiring specialized hardware, making it more accessible and adaptable than hardware-based solutions.- Script Size Matters for Updates: For over-the-air updates, the size of the code to be transferred is important. While Wasm scripts were slightly smaller than
rBPFscripts in their tests, the overall firmware size increase with Wasm makesrBPFmore attractive for frequent updates.
Key Results
- Flash Memory: The WASM3 interpreter is 15 times larger than the
rBPFinterpreter in terms of ROM size. Adding anrBPFVM to a typical IoT application adds less than 10% to the firmware size, while a Wasm VM more than doubles it. - RAM Memory: For a simple networked IoT application, Wasm requires doubling the memory budget, whereas
rBPFrequires only a negligible increase (e.g., 16B for additional memory access regions). - Execution Time: For the Fletcher32 checksum,
rBPFexecution was approximately 2 times slower than Wasm. Both VMs were significantly slower than native C code (Wasm ~35x,rBPF~70x slower). However,rBPFstill achieves around 1.3 million instructions per second, sufficient for many IoT tasks. - Script Size for Updates: Wasm scripts were about 30% smaller than
rBPFscripts for the Fletcher32 example. - Networked Application: A sensor reading application compiled to
rBPFbytecode was 296 B, with an execution overhead of 94 µs. The full firmware image with therBPFinterpreter was 69 KiB. This is significantly smaller than a comparable JavaScript solution mentioned in prior work, which required a 156 KiB engine.
Limitations and Future Work
- Execution Time Overhead: The authors acknowledge that VMs inherently introduce execution overhead, impacting power consumption. While they argue this is manageable for low-throughput tasks, they suggest future work could involve hardware acceleration (MPU/MMU) or ahead-of-time transpilation to native code for performance-critical scenarios.
- Wasm RAM Usage: The significant RAM requirements of Wasm (64 KiB pages) are a major limitation for microcontrollers. Future work could explore alternative Wasm interpreters (e.g., WAMR, WARDuino) or adaptations to reduce memory page sizes.
rBPFScript Size: WhilerBPFexcels in memory footprint, its script sizes can be larger than Wasm. The authors suggest using compression algorithms like Heatshrink to reduce script size by up to 60%.- CPU Time Capping: The current
rBPFdesign does not limit the CPU time a single VM invocation can consume, potentially draining batteries. Capping CPU time is identified as a crucial next step for extending sandboxing guarantees. - Generalizability: While the paper uses RIOT OS, the approach is presented as applicable to other similar OSes. Further validation on a wider range of IoT hardware and operating systems would be beneficial.
Summary updated