EXAMINER: automatically locating inconsistent instructions between real devices and CPU emulators for ARM

Muhui Jiang, Tianyi Xu, Yajin Zhou, Yufeng Hu, Ming Zhong, Lei Wu, Xiapu Luo, Kui Ren

TL;DR

Researchers have developed INSDET, a tool that automatically finds "deviations"—behavioral differences—between real ARM hardware and CPU emulators like QEMU. By building the first symbolic execution engine for ARM’s formal specification language (ASL), they identified over 155,000 inconsistent instruction streams, uncovering four critical QEMU bugs and demonstrating how malware can use these gaps to evade security analysis.

What Problem Does This Paper Address?

In the world of cybersecurity, emulators are the workhorses of dynamic analysis. Tools like QEMU allow researchers to safely run malware, trace every instruction, and analyze crashes across different architectures without needing a room full of physical devices.

However, there is a dangerous implicit assumption: that an instruction executed on an emulator will behave exactly like it does on a real chip. If this assumption fails, the emulator is no longer a "digital twin" but a distorted mirror. Malware authors exploit these subtle deviations to detect if they are being analyzed (anti-emulation) or to break fuzzing tools. Manually finding these inconsistencies among the millions of possible ARM instruction variations is a needle-in-a-haystack problem that this paper seeks to automate.

Methods

The authors introduce INSDET, a framework consisting of two main components:

  1. Syntax and Semantics-Aware Test Case Generation:
    • Instead of blindly fuzzing 32-bit values (which would require $2^{32}$ tests), the authors leverage ARM’s Architecture Specification Language (ASL)—the machine-readable "source of truth" for how ARM instructions should work.
  2. They built the first symbolic execution engine for ASL. By treating instruction encoding symbols as variables, they can solve for specific values that trigger different execution paths (e.g., "if register $Rn$ is 15, behavior is UNPREDICTABLE"). This allows them to generate a representative set of instruction streams that cover nearly all possible behaviors.
  3. Deterministic Differential Testing Engine:
    • INSDET executes the generated instruction streams on both a real ARM device and an emulator (QEMU) under identical initial conditions (registers and memory).
  4. It then compares the "final state" (registers, memory, and processor signals). If the states differ—for instance, if the real device throws a "Segmentation Fault" but the emulator continues smoothly—an inconsistency is logged.

Datasets

The study evaluated QEMU (v5.1.0) against four distinct physical ARM environments:

  • ARMv5: OLinuXino iMX233
  • ARMv6: Raspberry Pi Zero
  • ARMv7-a: Raspberry Pi 2B
  • ARMv8-a: Hikey 970

The researchers generated a total of 2,774,649 instruction streams covering four instruction sets: A64, A32, T32 (Thumb-2), and T16 (Thumb-1).

Key Insights and Ideas

  • The "Tolerance" Trap: One of the most common deviations is that QEMU is often "too tolerant." It may execute an instruction that the ARM manual defines as "UNDEFINED" or "UNPREDICTABLE," whereas real hardware might trigger a signal (like SIGILL). This creates a perfect "fingerprint" for malware to detect the emulator.
  • ASL as a Lever: By targeting the specification language (ASL) rather than the binary itself, the authors could systematically explore edge cases that random fuzzing would likely miss. Their method covered 100% of instruction encodings, compared to just 54.5% for random generation.
  • The "Unpredictable" Goldmine: A significant portion of inconsistencies stems from "implementation-defined" or "unpredictable" behaviors in the ARM manual. Different chip manufacturers and emulator developers interpret these gray areas differently, leading to permanent, unpatchable deviations.

Key Results

  • Massive Deviation Found: INSDET located 155,642 inconsistent instruction streams. These deviations cover 30% of all instruction encodings and 47.8% of all instructions tested.
  • Bug Discovery: The authors discovered four new bugs in QEMU that were confirmed and patched by developers. These bugs affected commonly used instructions like STR (Store Register) and BLX (Branch with Link and Exchange).
  • Security Impact: The researchers demonstrated three practical applications:
  • Emulator Detection: Using a single inconsistent instruction to determine if a program is running in QEMU.
  • Anti-Emulation: Crafting code that executes malicious payloads on real devices but crashes or exits on emulators.
  • Anti-Fuzzing: Reducing the code coverage of fuzzers by 100% by inserting inconsistent instructions that QEMU-based fuzzers cannot handle correctly.

Limitations and Future Work

  • Single Instructions Only: Currently, INSDET only tests single instructions. It does not yet account for "instruction sequences" where the interaction between multiple instructions might create new deviations.
  • Unprivileged Mode: The testing was conducted in user-space (unprivileged mode). Deviations in kernel-space (privileged mode) or system-level instructions (like those involving MMU or interrupts) remain unexplored.
  • Architecture Specificity: While the framework is theoretically architecture-independent, it currently relies on the existence of a formal specification like ARM's ASL. Applying this to other architectures (like RISC-V) would require similar machine-readable manuals.

Summary updated

BibTeX
@inproceedings{jiang2022examiner,
  author = {Muhui Jiang and Tianyi Xu and Yajin Zhou and Yufeng Hu and Ming Zhong and Lei Wu and Xiapu Luo and Kui Ren},
  title = {{EXAMINER: automatically locating inconsistent instructions between real devices and CPU emulators for ARM}},
  booktitle = {ASPLOS},
  year = {2022},
  doi = {10.1145/3503222.3507736},
}
Figure