Abstract
Binary Code Similarity Detection (BCSD) is a fundamental task in cybersecurity, yet existing methods often force a trade-off between interpretability and cross-architecture performance. This paper explores a novel paradigm that moves beyond opaque vector embeddings by utilizing Large Language Models (LLMs) as structured feature extractors. By prompting LLMs to perform high-level reverse engineering, we generate human-readable JSON features that enable exact similarity searches via inverted indexes. Our approach achieves state-of-the-art zero-shot performance on cross-architecture and cross-optimization tasks, providing both accuracy and transparency for security analysts.
Introduction: The BCSD Trilemma
Binary Code Similarity Detection (BCSD) aims to determine if two compiled functions originate from the same source code, a task complicated by variations in CPU architectures (e.g., x86 vs. ARM) and compiler optimization levels. Traditionally, the field has struggled with a "trilemma" involving interpretability, generalizability, and scalability.
As shown in Figure 1, handcrafted features are interpretable but shallow, failing to capture deep semantics. Conversely, deep learning embeddings offer strong cross-setting matching but act as "black boxes," making it impossible for analysts to verify why a match was found. Furthermore, searching high-dimensional vector spaces requires approximate nearest neighbor (ANN) algorithms, which introduce an accuracy-efficiency trade-off.
Methodology: LLMs as Structured Vectorizers
The proposed method redefines the role of the LLM. Rather than generating code, the LLM acts as a "structured feature extractor" that transforms raw assembly into a detailed JSON representation.
Feature Taxonomy
The system prompts the LLM to analyze assembly code across five semantic dimensions:
- Type Signatures: Inferring function parameters and return types.
- Logic & Operations: Identifying structural elements like loops or jump tables.
- Notable Constants: Extracting semantically significant values (e.g., magic numbers for encryption) while filtering out noise.
- Side Effects: Documenting interactions with global state, I/O, or memory allocation.
- Algorithmic Intent: Assigning high-level labels such as "initialization" or "cryptographic hashing."
Similarity and Search
By converting assembly into structured text, similarity is calculated using Jaccard overlap on field-value pairs. This allows the system to leverage mature text-search technologies like Elasticsearch. This approach enables exact similarity searches at scale, bypassing the precision loss inherent in vector-based ANN searches.
Experimental Evaluation
The method was evaluated using a dataset of 383,658 assembly functions from seven major open-source projects (including OpenSSL, curl, and SQLite) across four architectures (x86-64, ARM, MIPS, PowerPC) and four optimization levels (O0-O3).
Key Results
- Zero-Shot Superiority: Using Gemini 2.5 Flash, the method achieved a 42.2% recall@1 in cross-architecture tasks without any specialized training. This outperformed CLAP (39.7%), a leading model specifically trained for BCSD.
- Robustness to Optimization: In the challenging O0 to O3 matching task, the LLM-based approach reached 61.7% recall@1, nearly doubling the performance of the best-trained baseline (33.9%).
- Interpretability: Analysts can directly compare the generated JSON objects to understand the semantic basis for a similarity match, a critical requirement for forensic analysis.
Conclusion and Future Work
By treating LLMs as reverse engineering agents, we can extract structured, interpretable features that outperform traditional embeddings in zero-shot scenarios. While the computational cost of LLM inference remains a challenge, future work involving model distillation—training smaller models to mimic the LLM's feature extraction—promises to make this high-fidelity approach more accessible for large-scale binary analysis.
Summary updated