AIM: Automatic Interrupt Modeling for Dynamic Firmware Analysis

Bo Feng, Meng Luo, Changming Liu, Long Lu, Engin Kirda

TL;DR

AIM (Automatic Interrupt Modeling) is a novel framework that significantly improves the dynamic analysis of microcontroller (MCU) firmware by automatically modeling complex, event-driven interrupts. By using a "Just-in-Time" interrupt firing technique, it achieves up to 11.2x better coverage of interrupt-dependent code compared to previous state-of-the-art tools, enabling deeper security testing of IoT devices without requiring real hardware.

What Problem Does This Paper Address?

The "monolithic" nature of MCU firmware makes it incredibly difficult to test. Unlike desktop software, firmware is tightly coupled with diverse hardware peripherals (sensors, actuators, radios). To test this code effectively, researchers use emulators, but no emulator can support the thousands of unique peripherals found in the wild.

A major roadblock is the interrupt interface. MCU firmware is event-driven; it often sits in loops waiting for a peripheral to trigger an interrupt (e.g., "data received" or "timer expired"). If an emulator doesn't know when or how to fire these interrupts, the firmware gets stuck, and large portions of the code—specifically the logic that handles these events—remain "dark" and untested. Existing solutions either require slow, unscalable physical hardware or use "naive" interrupt modeling (firing interrupts at fixed intervals), which fails to trigger complex logic sequences.

Methods

The authors introduce AIM, which moves away from trying to emulate hardware and instead focuses on what the firmware expects. It consists of three main stages:

  1. Interrupt Identification: AIM monitors the MCU's interrupt controller (NVIC) to see which lines are active. It then performs an automated analysis of the Interrupt Service Routines (ISRs). Using dynamic backward slicing, it identifies which global variables each interrupt modifies and creates an "Interrupt Model Table."
  2. Just-in-Time (JIT) Interrupt Firing: This is the core innovation. When the firmware reads a global variable that could be changed by an interrupt, AIM pauses the execution. It then uses Dynamic Symbolic Execution (DSE) to explore potential future paths. If it finds a path that requires a specific variable value, it consults the Model Table to "back-calculate" and fire the exact sequence of interrupts needed to reach that state.
  3. Path Filtering: To prevent the "state explosion" common in symbolic execution, AIM identifies and discards redundant ISR paths. If two different interrupt events result in the exact same changes to the firmware's state, AIM only tests one, drastically reducing the search space.

The system is implemented as an extension to the popular angr binary analysis framework.

Datasets

The researchers evaluated AIM using a suite of eight real-world MCU firmwares originally curated for the P2IM project. These include:

  • Industrial control systems (PLC, CNC, Heat Press, Reflow Oven).
  • IoT gateways and steering controllers.
  • Drone and Robot control logic.

These samples represent a diverse range of complexities, from simple bare-metal loops to firmware utilizing Real-Time Operating Systems (RTOS).

Key Insights and Ideas

  • Firmware-Centric Modeling: Instead of guessing what the hardware does, AIM looks at how the firmware reacts to state changes. This makes the tool hardware-agnostic.
  • Interrupts as Constraint Solvers: The "aha moment" is treating interrupts not as random external events, but as a mechanism to satisfy symbolic constraints. If a code path requires variable_x == 5, and an interrupt increments variable_x, AIM treats that interrupt as a tool to unlock that path.
  • Prioritizing "Clean" Interrupts: When multiple interrupts can achieve a desired state change, AIM chooses the one with the fewest "side effects" (modifications to other global variables). This keeps the system stable and prevents unintended crashes during analysis.

Key Results

  • Massive Coverage Boost: AIM covered up to 11.2 times more interrupt-dependent code than the previous state-of-the-art (Baseline-P²IM).
  • Overall Code Coverage: On average, AIM reached 45% basic block coverage, a significant jump from the 29% achieved by existing automated tools.
  • Efficiency: The path filtering mechanism was highly effective, reducing the number of potential interrupt sequences to explore by as much as 13x in complex cases like the "Gateway" firmware.
  • DSE vs. Fuzzing: In a head-to-head comparison with the high-performance fuzzer Fuzzware, AIM found unique functions that the fuzzer missed. This demonstrates that while fuzzing is faster, AIM’s symbolic approach is better at solving the complex "magic number" constraints often found in firmware.

Limitations and Future Work

  • State Explosion: Despite the filtering, Dynamic Symbolic Execution is still computationally expensive. For some very complex firmwares, AIM spent over 90% of its time in the inference stage.
  • Peripheral Modeling Gaps: While AIM excels at interrupts, it still relies on existing (and sometimes imperfect) techniques for modeling Memory-Mapped I/O (MMIO) and Direct Memory Access (DMA).
  • Instruction Support: The authors had to exclude two firmware samples because they used specific ARM instructions not yet supported by the underlying angr engine.
  • Hybrid Potential: The authors suggest that the ultimate firmware testing tool would be a "hybrid" that combines AIM’s intelligent interrupt modeling with the raw speed of a fuzzer.

Summary updated

BibTeX
@article{feng2024aim,
  author = {Bo Feng and Meng Luo and Changming Liu and Long Lu and Engin Kirda},
  title = {{AIM: Automatic Interrupt Modeling for Dynamic Firmware Analysis}},
  journal = {IEEE Trans. Dependable Secur. Comput.},
  year = {2024},
  doi = {10.1109/tdsc.2023.3339569},
}
Figure