Binary code similarity detection (BCSD) is a critical task in cybersecurity, supporting applications such as vulnerability discovery, malware analysis, and software provenance. As the field has shifted toward massive, Transformer-based pre-trained models, the computational overhead has increased significantly. In their research, Chensen Huang and colleagues propose FastBCSD, a lightweight framework designed to match the accuracy of heavy-duty models while operating five times faster and utilizing a fraction of the parameters.
The Challenges of Scale in BCSD
Modern BCSD tools often rely on large-scale pre-training (e.g., BERT-based models for assembly code). While effective, these models face three primary hurdles:
- Computational Expense: Models like jTrans possess nearly 90 million parameters, making them slow and costly for high-throughput, real-world deployment.
- Input Length Constraints: Transformers typically impose a 512-token limit. Complex software functions often exceed this, leading to data truncation and loss of semantic information.
- Out-of-Vocabulary (OOV) Issues: Assembly code contains numerous rare tokens. Traditional normalization (e.g., replacing constants with generic tags) often strips away vital semantic nuances.
Methodology
FastBCSD departs from the "instruction-as-a-sentence" paradigm. Instead, it treats assembly functions as sequences of dynamic instruction vectors.
Dynamic Instruction Vector Encoding
The authors implement a granular tokenization strategy, using delimiters to split instructions into opcodes and operands. To address the OOV problem without over-normalizing, they apply frequency-based filtering, retaining tokens that appear at least 32 times. This results in a manageable vocabulary of approximately 40,000 tokens that preserves semantic detail.
Each instruction is represented by concatenating an opcode vector, multiple operand vectors, and a position vector. This ensures the input sequence length is proportional to the number of instructions rather than the total number of tokens, effectively bypassing the 512-token bottleneck.
Model Architecture
The researchers evaluated three backbones—TextCNN, LSTM, and MLP-Mixer—within a Siamese network framework. TextCNN emerged as the most effective architecture, utilizing 1D convolutional kernels to extract features with high efficiency.
Datasets and Evaluation
The study utilized the BinaryCorp dataset, a massive collection of binaries from ArchLinux repositories. Evaluation was conducted on two subsets:
- BinaryCorp-3M: Approximately 3.6 million functions for primary training and benchmarking.
- BinaryCorp-26M: The full dataset (~26 million functions) used to test scalability against state-of-the-art (SOTA) models.
Key Results
FastBCSD-TextCNN demonstrates that efficiency does not require sacrificing performance:
- Accuracy: On the BinaryCorp-3M dataset (pool size 10,000), FastBCSD achieved a Mean Reciprocal Rank (MRR) of 0.633, outperforming the SOTA jTrans model (0.623).
- Model Size: FastBCSD-TextCNN contains only 13.4M parameters, a significant reduction from jTrans’s 87.88M.
- Inference Speed: Latency is recorded at 0.00267s per sample, roughly 1/5th the time required by jTrans (0.0129s).
- Scalability: The model remained highly competitive on the 26M dataset, proving robustness across varying code volumes.
Conclusion
FastBCSD proves that smart encoding and lightweight architectures can outperform massive Transformers in specialized domains like assembly code analysis. By focusing on instruction-level dependencies rather than generic token sequences, the model achieves superior speed and scalability. Future work will focus on extending this framework to cross-architecture similarity detection, such as matching x86 functions to their ARM equivalents.
Summary updated