[Paper Review] A Cross-Architecture Instruction Embedding Model for Natural Language Processing-Inspired Binary Code Analysis
This paper proposes a joint learning model to generate cross-architecture instruction embeddings that capture semantic similarity across different instruction set architectures (ISAs), such as x86 and ARM. By leveraging both intra-architecture context and inter-architecture semantic equivalence, the model achieves high-quality embeddings that outperform statistical baselines in cross-architecture basic block similarity comparison, attaining an AUC of 0.90.
Given a closed-source program, such as most of proprietary software and viruses, binary code analysis is indispensable for many tasks, such as code plagiarism detection and malware analysis. Today, source code is very often compiled for various architectures, making cross-architecture binary code analysis increasingly important. A binary, after being disassembled, is expressed in an assembly languages. Thus, recent work starts exploring Natural Language Processing (NLP) inspired binary code analysis. In NLP, words are usually represented in high-dimensional vectors (i.e., embeddings) to facilitate further processing, which is one of the most common and critical steps in many NLP tasks. We regard instructions as words in NLP-inspired binary code analysis, and aim to represent instructions as embeddings as well. To facilitate cross-architecture binary code analysis, our goal is that similar instructions, regardless of their architectures, have embeddings close to each other. To this end, we propose a joint learning approach to generating instruction embeddings that capture not only the semantics of instructions within an architecture, but also their semantic relationships across architectures. To the best of our knowledge, this is the first work on building cross-architecture instruction embedding model. As a showcase, we apply the model to resolving one of the most fundamental problems for binary code similarity comparison---semantics-based basic block comparison, and the solution outperforms the code statistics based approach. It demonstrates that it is promising to apply the model to other cross-architecture binary code analysis tasks.
Motivation & Objective
- Address the challenge of analyzing proprietary and cross-compiled binaries across diverse instruction set architectures (ISAs), where source code is unavailable.
- Overcome the syntactic and structural differences between ISAs that hinder semantic comparison of binary code.
- Develop a unified representation for instructions that preserves semantic similarity across architectures, enabling robust cross-architecture analysis.
- Demonstrate the utility of instruction embeddings in a fundamental binary code similarity task: semantics-based basic block comparison.
- Enable transferability of models trained on one ISA to another by learning invariant semantic representations.
Proposed method
- Use a joint learning framework that simultaneously optimizes for intra-architecture context (via sliding window over instruction sequences) and cross-architecture semantic equivalence (via aligned instruction pairs from different ISAs).
- Train a neural network to predict contextually adjacent instructions within the same architecture, learning local syntactic and semantic patterns.
- Simultaneously train the model to minimize the distance between embeddings of semantically equivalent instructions across architectures, using aligned pairs from x86 and ARM binaries.
- Represent each basic block as the sum of its instruction embeddings, enabling cosine similarity computation for block-level comparison.
- Leverage pre-trained instruction embeddings to construct sentence-like representations of basic blocks, following established NLP practices for document/sentence embedding.
- Apply a Siamese-like architecture to learn embedding space where semantically equivalent instructions from different ISAs are mapped close together.
Experimental results
Research questions
- RQ1Can a unified embedding space be learned such that semantically equivalent instructions across different ISAs (e.g., x86 and ARM) are mapped close together?
- RQ2To what extent does the joint learning of intra-architecture context and cross-architecture alignment improve instruction embedding quality compared to isolated training?
- RQ3How well do the learned instruction embeddings generalize to cross-architecture binary code similarity tasks, such as basic block comparison?
- RQ4Can the model outperform traditional statistical feature-based approaches (e.g., instruction count, constant count) in detecting semantically similar basic blocks?
- RQ5How transferable are the learned embeddings across architectures—can a classifier trained on one ISA be applied directly to another?
Key findings
- The proposed cross-architecture instruction embedding model achieves an AUC of 0.90 on the cross-architecture basic block similarity comparison task, significantly outperforming the statistical baseline (AUC = 0.85).
- The model successfully captures semantic equivalence between instructions across ISAs, as demonstrated by the proximity of embeddings for semantically equivalent pairs like x86's `SUBQ RSP,0` and ARM's `SUB SP,SP,0`.
- Joint learning of intra-architecture context and cross-architecture alignment leads to more robust and generalizable instruction embeddings than learning either signal in isolation.
- The model’s embeddings are effective for downstream tasks such as vulnerability detection and malware analysis, as they preserve semantic meaning across architectural differences.
- The model’s architecture enables transfer learning: a classifier trained on one ISA (e.g., x86) can be applied to another (e.g., ARM) with minimal or no adaptation, due to shared semantic representation space.
- The implementation, datasets, and trained models are publicly available on GitHub, facilitating reproducibility and further research in cross-architecture binary analysis.
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.