Skip to main content
QUICK REVIEW

[论文解读] Symbol Preference Aware Generative Models for Recovering Variable Names from Stripped Binary

Xiangzhe Xu, Zhuo Zhang|arXiv (Cornell University)|Jun 5, 2023
Topic ModelingComputer Science被引用 3
一句话总结

该论文提出 LmPa,一种新颖方法,通过将大型语言模型(LLMs)与程序分析相结合,从剥离的二进制文件中恢复有意义的变量名。通过迭代地使用上下文丰富的程序片段查询 LLM,并利用静态分析传播结果,LmPa 在最先进方法的基础上将名称恢复的精确率和召回率分别提升了 16.5% 和 20.23%,实现了 75% 的用户认为‘良好’的名称。

ABSTRACT

Decompilation aims to recover the source code form of a binary executable. It has many security applications, such as malware analysis, vulnerability detection, and code hardening. A prominent challenge in decompilation is to recover variable names. We propose a novel technique that leverages the strengths of generative models while mitigating model biases. We build a prototype, GenNm, from pre-trained generative models CodeGemma-2B, CodeLlama-7B, and CodeLlama-34B. We finetune GenNm on decompiled functions and teach models to leverage contextual information. GenNm includes names from callers and callees while querying a function, providing rich contextual information within the model's input token limitation. We mitigate model biases by aligning the output distribution of models with symbol preferences of developers. Our results show that GenNm improves the state-of-the-art name recovery precision by 5.6-11.4 percentage points on two commonly used datasets and improves the state-of-the-art by 32% (from 17.3% to 22.8%) in the most challenging setup where ground-truth variable names are not seen in the training dataset.

研究动机与目标

  • 解决反编译二进制文件中变量名恢复的关键挑战,现有方法因上下文有限且性能不佳而受限。
  • 通过将名称恢复任务分解为多个上下文感知的查询,克服 LLM 的输入长度限制。
  • 通过利用程序语义和静态分析,迭代传播并优化名称预测,从而提升 LLM 的性能。
  • 证明 LLM 与程序分析的协同作用显著优于独立使用 LLM 或基于规则的方法。
  • 通过用户研究和在多样化二进制文件上的消融实验,验证该方法的鲁棒性与泛化能力。

提出的方法

  • 将二进制函数划分为多个上下文相关的片段,以适应 LLM 的输入限制,从而实现聚焦的名称预测。
  • 采用多轮迭代过程,利用控制流和数据流分析传播并优化 LLM 的预测结果,以保持语义一致性。
  • 使用程序分析关联不同片段中的变量使用情况,确保名称在整个函数作用域内的一致性应用。
  • 系统采用反馈循环:LLM 的预测结果为静态分析提供输入,而静态分析则为后续 LLM 查询提供增强的上下文。
  • 利用 GPT-4 和 ChatGPT 等预训练 LLM,通过代码片段和程序上下文提示,生成语义上合理的变量名。
  • 通过分析调用图和参数传递,该方法支持函数内及跨函数的名称恢复。
Figure 1 . Motivating example
Figure 1 . Motivating example

实验结果

研究问题

  • RQ1LLM 与程序分析的协同作用是否能显著提升反编译二进制文件中的变量名恢复效果?
  • RQ2上下文感知的分解与迭代传播如何影响恢复的变量名质量?
  • RQ3在输入上下文有限的情况下,程序分析在多大程度上能提升 LLM 的性能?
  • RQ4LmPa 在变量名恢复的精确率和召回率方面,与最先进方法 DIRTY 相比表现如何?
  • RQ5LmPa 的性能是否能在包括 LLM 预训练数据中未见的二进制文件在内的多样化二进制文件上保持泛化?

主要发现

  • 在用户研究中,LmPa 恢复的 75% 的变量名被人类评估者评为‘良好’,表明其具有较强的可读性。
  • 使用 GPT-4 时,LmPa 在基准数据集上相比最先进方法 DIRTY,精确率提升 16.5%,召回率提升 20.23%。
  • 该方法在多种 LLM(包括 GPT-4 和 ChatGPT)上均表现出稳定性能,且在两项指标上均有持续提升。
  • 消融实验表明,迭代传播与程序分析显著提升了 LLM 性能,尤其在复杂二进制文件中效果更明显。
  • 即使在 LLM 训练数据中不太可能出现的近期编译的二进制文件上,该方法依然有效,表明其泛化能力超越记忆化。
  • 用户研究结果表明,LmPa 的输出在可读性和语义准确性方面显著优于基线方法。
Figure 4 . Three rounds of interactions with ChatGPT. Round 1’s query is partially shown in Fig. 3 . Each box shows a function with symbols renamed according to ChatGPT’s response. Red circles show the numbers of rounds. Red arrows and boxes indicate how LmPa uses information from previous response
Figure 4 . Three rounds of interactions with ChatGPT. Round 1’s query is partially shown in Fig. 3 . Each box shows a function with symbols renamed according to ChatGPT’s response. Red circles show the numbers of rounds. Red arrows and boxes indicate how LmPa uses information from previous response

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。