TL;DR
This paper introduces PROTST, a novel transformer-based framework that unifies binary code embedding and knowledge transfer. By employing a progressive teacher-student learning paradigm, PROTST builds a hierarchical understanding of binary code, leading to significantly improved performance on various downstream analysis tasks compared to existing methods.
What Problem Does This Paper Address?
Modern binary analysis tasks, such as function similarity detection and signature recovery, have increasingly leveraged deep learning, particularly transformer models. The common approach involves a two-stage process: Masked Language Modeling (MLM) pre-training on raw binary code, followed by fine-tuning on specific downstream tasks. While MLM helps learn code structure, it often overlooks crucial inherent knowledge like control and data flow.
More advanced methods attempt to incorporate this domain-specific knowledge by concatenating features from control flow graphs (CFGs), data flow graphs (DFGs), or dynamic execution traces. However, this approach is complex, requires specialized tools and knowledge, and is sensitive to errors introduced by reverse engineering tools, especially with stripped or obfuscated code. Furthermore, indiscriminately adding all possible modalities during pre-training can be detrimental if the information isn't relevant to the target task. This leads to a critical question: can we effectively capture binary code knowledge without complex feature engineering and without the drawbacks of multi-modal approaches?
Methods
PROTST tackles this challenge with a Progressive Teacher-Student Binary Analysis (PROTST) framework. Instead of a single pre-training phase, PROTST uses a hierarchical, tree-like structure where tasks are organized progressively. Lower-level tasks (like instruction boundary recovery) act as teachers for more specialized, higher-level tasks (like function signature prediction). This allows knowledge to flow hierarchically, with each task building upon the learned representations of its predecessors.
The architecture consists of three main components:
- Embedding Module: Transforms raw binary bytes into high-dimensional vectors, incorporating learned positional encodings.
- Backbone Model: A RoBERTa transformer that processes the embedded byte sequences and captures contextual dependencies.
- Task Head Module: Specialized heads for each binary analysis task. The core innovation is the Binary Knowledge Accumulation (BKA) stage, where tasks are chained in a teacher-student fashion.
The knowledge transfer is achieved by initializing a student model's parameters with the learned weights of its teacher model. This progressive fine-tuning allows the model to build a richer, more semantically aware representation of binary code.
Datasets
PROTST was evaluated on seven diverse binary analysis tasks using the following datasets:
- Binutils: For MLM pre-training.
- SPEC CPU (2017 & 2006): For instruction and function boundary recovery.
- BAP: For function boundary recovery.
- BIG2015: For malware classification.
- Binkit: For compiler provenance and function signature prediction.
- SymLM: For function name prediction.
- Binarycorp-3M: For function similarity detection.
Key Insights and Ideas
- Hierarchical Knowledge Transfer is Key: The core insight is that binary code knowledge can be effectively learned through a structured progression of causally related tasks, rather than a monolithic pre-training phase or complex multi-modal feature engineering.
- Teacher-Student Paradigm Works for Binary Analysis: The paper demonstrates that the teacher-student learning paradigm, successful in other domains, is highly effective for unifying binary code embedding and knowledge transfer.
- Task Order Matters: The order of tasks in the BKA stage significantly impacts performance, with tasks benefiting from knowledge learned from preceding, simpler tasks.
- Efficiency Gains: PROTST achieves faster convergence during fine-tuning compared to traditional methods, suggesting that its pre-trained knowledge base is more robust.
- Generalization to Obfuscation and Optimization: PROTST shows strong generalization capabilities, performing well on binaries compiled with various optimization levels and even on obfuscated code, without explicit pre-training on such data.
Key Results
PROTST demonstrates significant improvements across seven binary analysis tasks:
- Overall Improvement: An average validation score improvement of 14.8% compared to traditional two-stage training and 10.7% compared to multimodal two-stage frameworks.
- Instruction Boundary Recovery: Achieved the highest average F1-score of 88.4%, outperforming Bi-RNN and DeepDi.
- Function Boundary Recovery: Achieved an average F1-score of 91.5%.
- Compiler Provenance: Achieved an average F1-score of 46%, outperforming Binprov and O-glasses.
- Malware Classification: Achieved an average F1-score of 80.1%, outperforming IMCFN and Malconv2.
- Function Signature Prediction: Outperformed EKLAVYA and Palmtree in both argument count (76.3%) and return type (62.6%) prediction.
- Function Name Prediction: Achieved the highest average F1-score of 83.5%, outperforming Asm2vec and Symlm.
- Convergence Speed: PROTST requires 2-3 times fewer fine-tuning epochs than XDA to reach a specific performance threshold.
Limitations and Future Work
- Manual Task Ordering: The current hierarchical task order is manually determined. Future work could explore curriculum learning to optimize this order systematically.
- Raw Byte Input: The current implementation uses raw byte input for computational efficiency. Future work could explore using assembly code, which might require longer convergence times but could potentially incorporate more detailed information.
- Scalability: While PROTST is efficient, exploring lightweight fine-tuning approaches like LoRA or sparse transformers could further enhance scalability for a larger number of tasks.
- Architecture Applicability: While focused on x86, PROTST is applicable to other instruction sets like ARM and MIPS.
- New Task Integration: Adding new tasks to the hierarchy only requires fine-tuning the new task and its successors, demonstrating efficient extensibility.
- Alternative Transfer Methods: Future work will explore feature-based and unified-loss transfer learning methods to further enhance PROTST's capabilities.
Summary updated