This paper, presented at NDSS 2019, introduces INNEREYE, a system that treats binary code analysis as a translation problem. By applying techniques from Natural Language Processing (NLP)—specifically Neural Machine Translation (NMT)—the authors tackle the difficult task of comparing binary code across different hardware architectures (like x86 vs. ARM) without needing the original source code.
TL;DR
INNEREYE leverages LSTMs and Siamese networks to treat assembly instructions as "words" and basic blocks as "sentences," enabling highly accurate cross-architecture binary similarity detection. It moves beyond simple function-to-function comparison to solve the "code containment" problem, outperforming traditional symbolic execution methods in speed by up to four orders of magnitude.
What Problem Does This Paper Address?
With the explosion of IoT devices, security researchers often find themselves analyzing binaries for diverse architectures (ARM, MIPS, x86) where source code is unavailable. A vulnerability in a common library (like OpenSSL) might exist across hundreds of different device types.
Existing solutions face a "Goldilocks" problem:
- Symbolic execution and theorem proving: Highly precise but computationally expensive and slow—unsuitable for large-scale analysis.
- Feature-based machine learning: Fast, but relies on manually selected features (like the number of constants or instructions) that lose the rich semantic meaning and dependencies within the code.
- Scope: Most tools only check if two functions are equivalent. They struggle with containment—determining if a specific snippet of code (like a crypto algorithm) is hidden inside a larger, different function.
Methods
The authors propose a multi-layered approach inspired by how NMT models translate human languages.
1. Instruction Embedding (The "Word" Level)
Just as words with similar meanings appear in similar contexts, assembly instructions do too. The authors use a Skip-gram model (Word2Vec) to convert instructions into high-dimensional vectors. To handle the "Out-of-Vocabulary" (OOV) problem—where unique constants or memory addresses make every instruction look different—they apply a preprocessing step that replaces specific values with generic tags (e.g., replacing all function names with FOO and constants with 0).
2. Basic-Block Embedding (The "Sentence" Level)
To capture the semantics of a sequence of instructions, they use a Siamese Network architecture featuring Long Short-Term Memory (LSTM) units.
- LSTM: Automatically captures the dependencies and order of instructions.
- Siamese Network: Two identical LSTMs are trained together. During training, the model is shown pairs of blocks and told if they are similar or not. It learns to project similar blocks (even from different ISAs) into nearby points in a vector space.
3. Code Containment (The "Component" Level)
To find a piece of code $Q$ inside a target program $T$, INNEREYE-CC decomposes the code into paths. It uses the Longest Common Subsequence (LCS) algorithm, treating basic blocks as the elements of the sequence. By comparing the embeddings of blocks along these paths, it can calculate a similarity score even if the code has been rearranged or embedded in the middle of a larger function.
Datasets
The authors created a large-scale dataset to train and evaluate the model:
- Source: OpenSSL and four popular Linux packages (coreutils, findutils, diffutils, binutils).
- Architectures: x86-64 and ARM.
- Compilers: Clang with three optimization levels (O1, O2, O3).
- Ground Truth: They modified the LLVM backend to annotate basic blocks with unique IDs. This allowed them to know for certain which x86 block corresponded to which ARM block, regardless of how the compiler transformed them.
Key Insights and Ideas
- The NLP Analogy Works: The most powerful insight is that the "context" of an instruction is a reliable proxy for its semantic meaning.
- Automatic Feature Extraction: By using LSTMs, the model discovers "features" of assembly code that humans might miss, leading to much higher precision than manual feature engineering.
- Preprocessing is Critical: Without normalization, the vocabulary of assembly instructions is infinite due to constants. Preprocessing reduced OOV cases from 90% to just 3.7%, making the model practical.
- Architecture vs. Semantics: t-SNE visualizations (see Figure 9 in the paper) show that instructions cluster primarily by architecture. This explains why cross-ISA comparison is so much harder than single-ISA comparison—the "dialects" are fundamentally different.
Key Results
- Accuracy: INNEREYE-BB achieved an AUC (Area Under the Curve) of 98% for basic block similarity, significantly higher than the 85-87% achieved by previous state-of-the-art SVM-based models (like Gemini).
- Speed: Compared to symbolic execution-based tools (like CoP), INNEREYE is 3,700x to 140,000x faster. A task that took CoP an hour was finished by INNEREYE in under 2 seconds.
- Real-world Utility: In case studies, the system successfully identified MD5 and AES implementations across architectures with similarity scores between 86% and 94%.
Limitations and Future Work
- Compiler Agnosticism: The training was performed on LLVM-generated code. While the authors believe the model is compiler-agnostic, they have not yet extensively tested it on code produced by GCC or proprietary compilers.
- Obfuscation: The current block-level model was not tested against heavy code obfuscation (like instruction substitution). However, the authors note that their path-level analysis (INNEREYE-CC) inherits some resilience to obfuscation (like garbage code insertion) from the underlying LCS approach.
- Future Directions: The authors plan to incorporate obfuscated binaries into the training set to improve robustness.
Summary updated