[论文解读] A Cross-Architecture Instruction Embedding Model for Natural Language Processing-Inspired Binary Code Analysis
本文提出一种联合学习模型,用于生成跨指令集架构(ISA)的指令嵌入,以捕捉不同ISA(如x86和ARM)之间的语义相似性。通过同时利用架构内上下文和跨架构语义等价性,该模型生成了高质量的嵌入表示,在跨架构基本块相似性比较任务中表现优异,AUC达到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.
研究动机与目标
- 解决在缺乏源代码的情况下,对不同指令集架构(ISA)的专有和交叉编译二进制文件进行分析的挑战。
- 克服ISA之间在语法和结构上的差异,这些差异阻碍了二进制代码的语义比较。
- 为指令开发统一的表示方法,以保留跨架构的语义相似性,从而实现稳健的跨架构分析。
- 在一项基础的二进制代码相似性任务——基于语义的基本块比较中,展示指令嵌入的实用性。
- 通过学习不变的语义表示,实现基于一种ISA训练的模型向另一种ISA的可迁移性。
提出的方法
- 采用联合学习框架,同时优化架构内上下文(通过指令序列上的滑动窗口)和跨架构语义等价性(通过来自不同ISA的对齐指令对)。
- 训练神经网络以预测同一架构内上下文相邻的指令,从而学习局部语法和语义模式。
- 同时训练模型,通过x86和ARM二进制文件中提取的对齐对,最小化跨架构语义等价指令嵌入之间的距离。
- 将每个基本块表示为其指令嵌入之和,从而支持基于余弦相似度的块级比较。
- 借鉴NLP中文档/句子嵌入的既定实践,利用预训练的指令嵌入构建类似句子的块表示。
- 采用类似Siamese的架构,学习一个嵌入空间,使得来自不同ISA的语义等价指令在该空间中被映射得彼此接近。
实验结果
研究问题
- RQ1是否能够学习到一个统一的嵌入空间,使得不同ISA(如x86和ARM)之间语义等价的指令被映射得彼此接近?
- RQ2与单独训练相比,联合学习架构内上下文和跨架构对齐信号在多大程度上提升了指令嵌入的质量?
- RQ3所学习的指令嵌入在跨架构二进制代码相似性任务(如基本块比较)中的泛化能力如何?
- RQ4该模型是否能在检测语义相似的基本块方面超越传统的基于统计特征的方法(如指令计数、常量计数)?
- RQ5所学习的嵌入在不同架构之间是否具有可迁移性——即在一种ISA上训练的分类器能否无需或仅需极少调整直接应用于另一种ISA?
主要发现
- 所提出的跨架构指令嵌入模型在跨架构基本块相似性比较任务中取得了0.90的AUC,显著优于统计基线方法(AUC = 0.85)。
- 模型成功捕捉了不同ISA之间指令的语义等价性,例如x86的`SUBQ RSP,0`与ARM的`SUB SP,SP,0`在嵌入空间中表现出相近的表示。
- 联合学习架构内上下文与跨架构对齐信号,相比单独学习任一信号,能生成更鲁棒且更具泛化能力的指令嵌入。
- 该模型的嵌入在下游任务(如漏洞检测和恶意软件分析)中表现有效,因其能保留跨架构差异下的语义含义。
- 该模型的架构支持迁移学习:在一种ISA(如x86)上训练的分类器可直接应用于另一种ISA(如ARM),得益于共享的语义表示空间。
- 该模型的实现代码、数据集和训练好的模型均已公开发布于GitHub,有助于实现结果复现,并推动跨架构二进制分析领域的进一步研究。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。