TL;DR
This paper introduces MSSA, a lightweight neural network for detecting similar binary code snippets. MSSA uniquely combines semantic and structural information across multiple levels of binary code, achieving high accuracy in classification and competitive performance in retrieval, all while being significantly more efficient than existing Transformer-based models.
What Problem Does This Paper Address?
Binary Code Similarity Detection (BCSD) is crucial for tasks like malware analysis, patch analysis, and software piracy detection. Existing state-of-the-art methods often rely on computationally expensive Transformer models, making them impractical for resource-constrained environments. Furthermore, many learning-based approaches tend to focus on either semantic or structural information, neglecting the potential benefits of integrating both. This paper aims to bridge this gap by proposing a model that is both highly accurate and computationally efficient, capable of capturing a deeper understanding of binary code semantics by considering its structure at multiple granularities.
Methods
The proposed MSSA model employs a multi-stage approach with four semantic-aware neural networks:
- Pre-Processing: This stage normalizes assembly instructions to handle out-of-vocabulary (OOV) issues and constructs a Control Flow Graph (CFG) and its corresponding adjacency matrix for each function.
- Block Embedding: Utilizes a Continuous Bag-of-Words (CBOW) model from Word2Vec to learn semantic relationships between instructions within a basic block, converting them into fixed-dimension vector representations.
- Intra-Block Learning: Employs a Bidirectional Gated Recurrent Unit (Bi-GRU) to capture sequential dependencies and semantic flow within a single basic block.
- Inter-Block Learning: Uses an iterative network that processes the CFG's adjacency matrix to integrate structural information among basic blocks, enriching their semantic representations.
- Function-Level Learning: Leverages a Bi-GRU with an attention mechanism to learn high-level semantic meaning from the function's overall structure, focusing on key features.
- Similarity Detection: A Siamese neural network architecture with a Multi-Layer Perceptron (MLP) takes the learned function embeddings and outputs a similarity score.
The key novelty lies in the multi-stage integration of semantic and structural information, from individual instructions within basic blocks to the overall function structure, and the model's lightweight design.
Datasets
The paper uses the BinaryCorp-3M dataset for evaluation. This dataset is large and constructed from the ArchLinux official repository and the Arch User Repository, compiled for the x86 architecture with various optimization levels (O0-O3, Os).
Key Insights and Ideas
- Multi-stage integration is key: MSSA's success stems from its ability to progressively learn from instructions within blocks, then between blocks, and finally at the function level, capturing a holistic understanding.
- Structure matters: The Inter-Block Learning stage, which explicitly uses structural information (CFG adjacency matrix), significantly boosts performance, highlighting the importance of control flow.
- Lightweight is viable: MSSA demonstrates that high performance in BCSD doesn't necessarily require massive Transformer models, offering a practical alternative for resource-constrained environments.
- CPU deployment is feasible: The model's small parameter count (0.38M for the backbone) makes it suitable for deployment on CPUs, expanding its applicability.
Key Results
- Classification Performance: MSSA consistently outperforms Gemini, Asm2Vec, and SAFE across Accuracy, Recall, F1, and AUC. It ranks second only to jTrans in Precision.
- MSSA achieves an Accuracy of 0.9776, Recall of 0.9894, F1 of 0.9779, and AUC of 0.9976.
- Retrieval Performance: MSSA ranks second only to jTrans in retrieval tasks (MRR and Recall@1).
- On average, MSSA's MRR is 0.9240, and Recall@1 is 0.8739.
- It shows significant improvements over SAFE, with an average MRR boost of 0.0273 and Recall@1 of 0.0409.
- Complexity and Efficiency: MSSA has the fewest parameters among the compared models (16.48M total), significantly less than jTrans (87.87M) and SAFE (57.24M).
- It achieves the highest execution speed at 32.20 pairs/second, far surpassing SAFE (6.78) and jTrans (0.74).
Limitations and Future Work
- Retrieval Performance: While competitive, MSSA's retrieval metrics slightly trail behind Transformer-based models like jTrans.
- Obfuscated Code: MSSA faces challenges in detecting obfuscated binary code, as obfuscation techniques disrupt original structures and semantics.
- Future Work: The authors plan to focus on optimizing and balancing model size, training cost, detection speed, and overall performance. They also aim to enhance MSSA's robustness against obfuscation, potentially by incorporating anti-obfuscation techniques or improving generalization.
Summary updated