Abstract
Binary Code Similarity Detection (BCSD) is a fundamental task in cybersecurity, essential for vulnerability discovery and malware analysis. Traditional methods often struggle with the significant variations introduced by different hardware architectures, compilers, and optimization levels. We present IRBinDiff, a framework that addresses these challenges by lifting binary code to a platform-neutral LLVM Intermediate Representation (LLVM-IR). By integrating BERT-based semantic features with Gated Graph Neural Network (GGNN) structural embeddings and employing Momentum Contrastive Learning (MoCo), IRBinDiff achieves state-of-the-art accuracy. Our evaluation shows that IRBinDiff significantly outperforms existing assembly-based methods, particularly in large-scale, cross-platform retrieval scenarios.
The Challenge of Binary Divergence
The primary obstacle in BCSD is the divergence of binary code across different compilation environments. With the proliferation of IoT devices, a single source code file may be compiled for various architectures (e.g., x86, ARM, MIPS) using different compilers (e.g., GCC, Clang) and optimization settings (O0 to O3). These variations can make semantically identical functions appear entirely different at the assembly level.
As shown in the figure above, the same bubble_sort logic results in distinct assembly instructions and control flow graph (CFG) structures depending on the compiler and optimization level. This "noise" makes it difficult for traditional models to identify functional equivalence, especially when searching for a specific vulnerability across millions of functions.
The IRBinDiff Pipeline
To overcome these hurdles, IRBinDiff employs a multi-stage analysis pipeline:
- Lifting to LLVM-IR: The framework uses the Retdec decompiler to translate binaries into LLVM Intermediate Representation. This architecture-independent format provides a unified language that abstracts away hardware-specific details like register names and instruction mnemonics.
- Hybrid Feature Extraction:
- Semantics: A BERT-based language model, pre-trained on normalized LLVM-IR, captures the underlying meaning of the instructions.
- Structure: A Gated Graph Neural Network (GGNN) processes the CFG to capture the logical branching and looping behavior of the function.
- Momentum Contrastive Learning (MoCo): The model is trained using MoCo, which maintains a dynamic queue of thousands of negative samples. This approach forces the model to learn highly discriminative embeddings, effectively pushing similar functions together and dissimilar ones apart in the vector space.
Experimental Evaluation
IRBinDiff was evaluated on a massive dataset of over 6.4 million functions derived from 16 open-source projects (e.g., OpenSSL, SQLite) cross-compiled for 5 architectures and 2 compiler families.
The results demonstrate IRBinDiff's superiority:
- One-to-One Comparison: It achieved an average AUC of 0.956, outperforming the state-of-the-art Trex model (0.938).
- One-to-Many Search: In challenging cross-architecture and cross-optimization tasks, IRBinDiff improved Recall@1 scores by up to 185% over baselines.
- Structural Importance: Ablation studies confirmed that the GGNN component is vital for portability, as the CFG structure remains a more stable signal than syntax across architectures.
Conclusion and Future Work
IRBinDiff represents a significant step forward in BCSD by leveraging intermediate representations and advanced contrastive learning. While highly effective, future work will address the challenges of code obfuscation and the computational overhead associated with the lifting process. Expanding the training dataset to include a wider variety of software types will also be a priority to further enhance generalizability.
Summary updated