TL;DR
This paper introduces REMaQE, a novel framework that automatically extracts mathematical equations from compiled binary executables. This is crucial for understanding the behavior of embedded systems, especially in critical domains like industrial control, where malware can subtly alter system dynamics. REMaQE achieves this by combining symbolic execution with advanced parameter analysis and algebraic simplification, outperforming existing methods in handling complex code and producing human-readable equations.
What Problem Does This Paper Address?
Cybersecurity threats targeting embedded systems, such as those in industrial control systems (ICS) and cyber-physical systems (CPS), can have severe real-world consequences, from power outages to physical destruction. These attacks often involve injecting malware that modifies the system's control logic. To defend against and understand these threats, it's essential to recover the semantic knowledge embedded within these systems, particularly the mathematical equations that govern their behavior.
While traditional reverse engineering tools can decompile binaries into low-level code, they often lack the semantic insight needed to reconstruct high-level mathematical models. Existing methods struggle with various parameter access methods (registers, stack, memory, pointers), object-oriented code, and complex conditional logic. This gap makes it difficult to understand the intended functionality, identify malicious modifications, or even debug complex algorithms. REMaQE aims to bridge this gap by providing a robust and automated way to extract these mathematical equations from binary executables.
Methods
REMaQE employs a three-stage pipeline:
- Parameter Analysis: This stage identifies all relevant parameters (inputs, outputs, constants) used in a function's mathematical equation. It determines their storage location (register, stack, global memory, or via pointers) and kind. This is a key differentiator, as it allows REMaQE to handle a wider range of code, including object-oriented C++ and functions with complex memory access patterns, which many prior methods struggle with.
- Symbolic Execution: Using the parameter metadata, REMaQE runs the function in an emulated environment with symbolic inputs. This process generates a symbolic expression tree (ET) that represents the function's logic. Symbolic execution ensures that all execution paths are explored, yielding a comprehensive representation of the implemented math equation. The authors leverage the Angr framework for this stage.
- Algebraic Simplification: The raw symbolic expressions from symbolic execution can be complex and cluttered with implementation-specific details. REMaQE uses math-aware algebraic methods to simplify these expressions into human-friendly mathematical equations. This stage is crucial for handling deeply nested conditional branches and complex floating-point operations, which can be challenging for machine learning-based simplification approaches.
Datasets
The authors generated a dataset consisting of 25,096 compiled binary executables and their corresponding 3,137 ground truth math equations. These equations were implemented in C and Simulink. The dataset was created by randomly generating equations as directed acyclic graphs (DAGs) and then compiling them into binaries using C and Simulink with various optimization levels. This dataset is made available for research.
Key Insights and Ideas
- Parameter-agnostic analysis is key: The ability to identify and handle parameters stored in registers, stack, global memory, and via pointers is a significant advancement, enabling REMaQE to analyze a much broader range of real-world code than previous methods.
- Algebraic simplification over ML: The paper argues that math-aware algebraic simplification is more robust and scalable for complex, conditional equations than machine learning-based approaches, which can struggle with expression size and complexity.
- Bridging the gap between binary and math: REMaQE doesn't just decompile code; it aims to recover the semantic meaning in the form of equations, making the code's behavior understandable to humans.
- Uncovering subtle bugs: The "tmon" Linux kernel example demonstrates how REMaQE can reveal subtle bugs caused by incorrect variable assignments that might be missed by traditional analysis.
Key Results
- REMaQE successfully recovered the correct equation for all 25,096 binaries in their dataset.
- Equivalence checks showed:
- 47.94% structural match
- 49.91% semantic match
- 2.12% evaluated match (with a tolerance of 10⁻⁵)
- The average execution time for the entire pipeline is 0.48 seconds, with complex equations taking up to 2 seconds. This real-time performance makes it suitable for interactive workflows.
- Human-friendliness, measured by the ratio of operations in the recovered equation to the ground truth, averaged close to 1, indicating comparable complexity.
Limitations and Future Work
Limitations:
- REMaQE does not explicitly handle data type casting or precision conversions (e.g., floor(x) from float to int).
- Bit manipulation for comparisons (e.g., sign-bit check) is not simplified.
- Advanced control-flow mechanisms like function pointers, recursion, or heavily obfuscated code can lead to path explosion issues in symbolic execution.
- Vector and matrix operations are unrolled into sequences of scalar operations, which can be less ideal for human readability.
- Algebraic simplification cannot handle subjective modifications (like manually introducing a temporary variable 't').
Future Work:
- Integrate REMaQE into GUI decompilation tools.
- Support data type conversions and bit-manipulation.
- Handle complex control-flow structures like function pointers and recursion.
- Recognize advanced mathematical structures (dynamic loops, summation, integration, differentiation, vectors, matrices).
- Extend simplification to handle long chains of scalar computations into high-level operations.
Summary updated