[Paper Review] jTrans: Jump-Aware Transformer for Binary Code Similarity
jTrans is a novel Transformer-based model that integrates control-flow information into binary code representation by introducing a jump-aware architecture, enabling more accurate binary code similarity detection. It achieves a 62.5% F1-score on the newly released BinaryCorp dataset—30.5% higher than prior SOTA methods—and demonstrates 2X higher recall in real-world vulnerability detection.
Binary code similarity detection (BCSD) has important applications in various fields such as vulnerability detection, software component analysis, and reverse engineering. Recent studies have shown that deep neural networks (DNNs) can comprehend instructions or control-flow graphs (CFG) of binary code and support BCSD. In this study, we propose a novel Transformer-based approach, namely jTrans, to learn representations of binary code. It is the first solution that embeds control flow information of binary code into Transformer-based language models, by using a novel jump-aware representation of the analyzed binaries and a newly-designed pre-training task. Additionally, we release to the community a newly-created large dataset of binaries, BinaryCorp, which is the most diverse to date. Evaluation results show that jTrans outperforms state-of-the-art (SOTA) approaches on this more challenging dataset by 30.5% (i.e., from 32.0% to 62.5%). In a real-world task of known vulnerability searching, jTrans achieves a recall that is 2X higher than existing SOTA baselines.
Motivation & Objective
- Address the limitation of existing NLP-based models in capturing control-flow semantics in binary code.
- Overcome the reliance on graph neural networks (GNNs) and manually crafted features in current binary code similarity solutions.
- Improve robustness and accuracy of binary code similarity detection under compiler optimizations and code transformations.
- Provide a scalable, high-quality benchmark for future research by releasing BinaryCorp, the largest and most diverse binary dataset to date.
- Enable direct comparison of two binary functions via a unified model architecture that captures inter-function relationships in large-scale pools.
Proposed method
- Introduce a jump-aware representation that explicitly models control-flow jumps (e.g., conditional/ unconditional branches) in binary functions.
- Design a novel self-attention mechanism that preserves the semantic impact of control-flow jumps by modifying attention computation with jump-aware positional encoding.
- Use a pre-training task that emphasizes control-flow structure, enhancing the model's ability to learn meaningful representations of binary code.
- Replace GNN-based CFG processing with a pure Transformer-based architecture, improving training efficiency and scalability.
- Leverage the learned representations to compute similarity between binary functions via cosine similarity in the vector space.
- Apply SVD decomposition and theoretical analysis to prove that attention weights are positively biased toward jump-connected tokens, justifying the design.
Experimental results
Research questions
- RQ1Can a Transformer-based model effectively learn control-flow semantics in binary code without relying on GNNs?
- RQ2How does incorporating jump-aware representations improve binary code similarity detection accuracy compared to standard NLP models?
- RQ3To what extent does the proposed pre-training task enhance model generalization on diverse binary code?
- RQ4How does jTrans perform in large-scale similarity search scenarios with thousands of candidate binaries?
- RQ5Can jTrans outperform existing SOTA methods in real-world vulnerability detection tasks?
Key findings
- jTrans achieves a 62.5% F1-score on the BinaryCorp dataset, a 30.5% improvement over the previous SOTA (32.0%).
- In a real-world known vulnerability search task, jTrans achieves 2X higher recall than existing SOTA baselines.
- The model maintains high performance even when the candidate pool size increases to 10,000 functions, where prior methods drop below 20% accuracy.
- Theoretical analysis confirms that attention weights are positively biased toward jump-connected tokens, validating the design’s soundness.
- BinaryCorp, the newly released dataset, contains the largest and most diverse collection of binaries to date, supporting robust benchmarking.
- jTrans outperforms models relying solely on sequential instruction modeling or CFG-based GNNs, demonstrating the importance of integrated control-flow semantics.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.