[论文解读] Semantic-aware Binary Code Representation with BERT
该论文提出 DeepSemantic,一种基于 BERT 的模型,通过应用平衡的指令归一化方法,在保留上下文信息的同时最小化词汇表外(OOV)问题,以学习语义感知的二进制代码表示。该方法在二进制相似性比较任务中达到最先进性能,平均优于 DeepBinDiff 49.84% 和 SAFE 15.83%,并通过在二进制函数上微调预训练 BERT 模型,在编译器来源追溯任务中展现出强劲表现。
A wide range of binary analysis applications, such as bug discovery, malware analysis and code clone detection, require recovery of contextual meanings on a binary code. Recently, binary analysis techniques based on machine learning have been proposed to automatically reconstruct the code representation of a binary instead of manually crafting specifics of the analysis algorithm. However, the existing approaches utilizing machine learning are still specialized to solve one domain of problems, rendering recreation of models for different types of binary analysis. In this paper, we propose DeepSemantic utilizing BERT in producing the semantic-aware code representation of a binary code. To this end, we introduce well-balanced instruction normalization that holds rich information for each of instructions yet minimizing an out-of-vocabulary (OOV) problem. DeepSemantic has been carefully designed based on our study with large swaths of binaries. Besides, DeepSemantic leverages the essence of the BERT architecture into re-purposing a pre-trained generic model that is readily available as a one-time processing, followed by quickly applying specific downstream tasks with a fine-tuning process. We demonstrate DeepSemantic with two downstream tasks, namely, binary similarity comparison and compiler provenance (i.e., compiler and optimization level) prediction. Our experimental results show that the binary similarity model outperforms two state-of-the-art binary similarity tools, DeepBinDiff and SAFE, 49.84% and 15.83% on average, respectively.
研究动机与目标
- 为解决从缺乏源代码结构且在编译过程中经历大量变换的二进制代码中恢复高级语义意义的挑战。
- 开发一种统一且可迁移的二进制分析表示模型,使其在无需从头开始训练的情况下泛化于多种下游任务。
- 在保留丰富语义和句法信息的同时,最小化二进制代码表示中的词汇表外(OOV)问题。
- 通过单一预训练的基于 BERT 的架构,实现有效的二进制相似性检测和工具链来源追溯。
提出的方法
- 提出一种平衡的指令归一化技术,将低级机器指令映射为语义有意义且适合 BERT 的词汇友好表示。
- 通过将每个函数视为归一化指令序列,适配 BERT 架构以处理二进制代码,从而实现上下文表示学习。
- 利用预训练 BERT 模型进行通用代码表示学习,随后在二进制相似性和编译器来源等具体下游任务上进行微调。
- 使用序列级分类头处理下游任务,支持基于梯度优化的端到端训练。
- 应用自注意力机制以捕捉函数内指令之间的长距离依赖关系和结构上下文。
- 采用受控词汇映射策略,在指令细节与 OOV 减少之间取得平衡,基于对 1.08 亿条指令和 170 万个函数的实证分析。
实验结果
研究问题
- RQ1在函数级序列上微调后,基于 BERT 的模型能否学习到有意义的、语义感知的二进制代码表示?
- RQ2指令归一化如何影响所学表示的质量以及二进制代码建模中的 OOV 率?
- RQ3单一预训练 BERT 模型在多样的二进制分析任务(如相似性检测和编译器来源追溯)中能多大程度上实现泛化?
- RQ4在二进制相似性任务中,所提方法与 DeepBinDiff 和 SAFE 等最先进工具相比表现如何?
主要发现
- 二进制相似性模型 DS-BinSim 在相似性检测任务中,平均优于 DeepBinDiff 49.84% 和 SAFE 15.83%。
- 该模型在编译器来源追溯任务中表现出色,表明所学表示在工具链推断任务中具有鲁棒性。
- 现有工具中,83% 的匹配基本块对由五个或更少的指令组成,表明块级粒度不足以实现语义理解。
- 函数级表示比基本块级分析捕获了更多上下文信息,这由相同指令序列来自不同函数时块级匹配的高错配率(14.1%)所证实。
- 二进制代码中的指令分布遵循齐普夫定律,表明其具有类语言结构,支持使用 BERT 等自然语言处理模型。
- 尽管无法访问 Order matters 的源代码,但其类似的基于 BERT 的方法 DeepSemantic 在二进制相似性任务中表现更优,表明其有效性与泛化能力。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。