There's Plenty of Room at the Bottom: Analyzing and Verifying Machine Code

Thomas W. Reps, Junghee Lim, Aditya V. Thakur, Gogul Balakrishnan, Akash Lal

Abstract

This paper addresses the "WYSINWYX" (What You See Is Not What You eXecute) phenomenon, where high-level language abstractions fail to capture the true behavior of compiled binaries. We present a suite of tools—CodeSurfer/x86, DDA/x86, and MCVETO—designed to analyze stripped machine code. These tools overcome challenges such as the lack of types, instruction aliasing, and self-modifying code by employing novel memory-region models and directed proof generation.

Introduction: The WYSINWYX Phenomenon

Most program analysis relies on source-level abstractions like variables, types, and structured control flow. However, these are merely "fictions" that disappear during compilation. In security-critical contexts, such as analyzing malware or device drivers, only the "stripped" binary is available. At this level, the distinction between data and control flow blurs; an array overflow can overwrite a return address, hijacking the program's execution. Traditional tools assuming a static Control-Flow Graph (CFG) or a well-behaved stack are insufficient for these "deviant" behaviors.

Methodology: A Suite for Machine-Code Analysis

The research introduces three primary tools to bridge the gap between binary execution and formal verification:

  1. CodeSurfer/x86: This tool performs program slicing and dependence analysis by recovering a sense of "variables" through a Memory-Region Model. It partitions memory into Global, Activation Record, and Malloc regions to track offsets and data flow.
  2. MCVETO (Machine-Code VErification Tool): Designed for highly dynamic code, MCVETO uses Directed Proof Generation (DPG). It balances under-approximation (concrete traces) against over-approximation (abstract state graphs). By performing disassembly "on-the-fly," it can handle instruction aliasing and self-modifying code.
  3. TSL (Transformer Specification Language): To ensure portability across architectures (e.g., x86 to ARM), TSL allows researchers to specify instruction semantics once. It then automatically generates the necessary abstract interpreters and symbolic executors.

Key Insights and Ideas

A central challenge in machine-code analysis is that numeric operations and memory dereferences are inextricably intertwined. One cannot perform alias analysis without simultaneous arithmetic analysis.

A control-flow graph (CFG) illustrating the interplay between data (function addresses) and control flow in machine-code analysis.

As shown in the figure above, tracking the value of variables like addr_bar is essential to understanding the program's behavior. If the address is corrupted or misinterpreted, the analysis might fail to identify that the loop eventually leads to a specific return or error state. Furthermore, the return address on the stack must be treated as mutable data. MCVETO explicitly verifies if a ret instruction returns to the expected caller, accounting for potential stack corruption.

Key Results

The authors achieved several milestones in the field:

  • CodeSurfer/x86 became the first program-slicing tool for machine code.
  • DDA/x86 provided the first automatic API-compliance checker for stripped binaries.
  • MCVETO demonstrated the ability to verify safety properties even in self-modifying code.

These tools successfully identify "executable-only" bugs—vulnerabilities introduced by compilers or linkers that are entirely invisible at the source-code level.

Limitations and Future Work

Despite these advances, challenges remain. The memory-region model can lose precision when encountering low-level bitwise operations on stack addresses. Additionally, while MCVETO handles many deviant behaviors, it still assumes that call and ret instructions generally follow standard procedure conventions for efficiency. Future work involves using TSL to incorporate higher-fidelity hardware details, such as CPU caches and interrupt tables, into the formal models.

Summary updated

BibTeX
@inproceedings{reps2010there,
  author = {Thomas W. Reps and Junghee Lim and Aditya V. Thakur and Gogul Balakrishnan and Akash Lal},
  title = {{There's Plenty of Room at the Bottom: Analyzing and Verifying Machine Code}},
  booktitle = {CAV},
  year = {2010},
  doi = {10.1007/978-3-642-14295-6\_6},
}
Figure