Skip to main content
QUICK REVIEW

[论文解读] Large Language Models for Code Analysis: Do LLMs Really Do Their Job?

Chongzhou Fang, Ning Miao|arXiv (Cornell University)|Oct 18, 2023
Natural Language Processing TechniquesComputer Science被引用 11
一句话总结

本论文系统评估公开可用的 LLMs(GPT-3.5/4、LLaMA-2-13B 变体)在代码分析任务上的表现,包括未混淆的代码和混淆代码,并给出两个真实世界的恶意软件案例研究来评估能力与局限。

ABSTRACT

Large language models (LLMs) have demonstrated significant potential in the realm of natural language understanding and programming code processing tasks. Their capacity to comprehend and generate human-like code has spurred research into harnessing LLMs for code analysis purposes. However, the existing body of literature falls short in delivering a systematic evaluation and assessment of LLMs' effectiveness in code analysis, particularly in the context of obfuscated code. This paper seeks to bridge this gap by offering a comprehensive evaluation of LLMs' capabilities in performing code analysis tasks. Additionally, it presents real-world case studies that employ LLMs for code analysis. Our findings indicate that LLMs can indeed serve as valuable tools for automating code analysis, albeit with certain limitations. Through meticulous exploration, this research contributes to a deeper understanding of the potential and constraints associated with utilizing LLMs in code analysis, paving the way for enhanced applications in this critical domain.

研究动机与目标

  • 评估 LLMs 是否能够理解并分析跨语言的源代码(JavaScript、Python、C)。
  • 评估 LLMs 理解混淆代码和可读性较低的代码的能力。
  • 提供将 LLMs 应用于恶意软件分析的真实世界案例研究,以评估防御效用。

提出的方法

  • 构建跨多种语言(JavaScript、Python、C)的未混淆和混淆代码数据集。
  • 使用四种方案对 JavaScript 代码进行混淆,并纳入 IOCCC 样本以用于去混淆挑战。
  • 评估多种 LLMs(GPT-3.5-turbo、GPT-4、LLaMA-2-13B、Code-LLaMA-2-13B-instruct)在代码分析任务上的表现。
  • 以 GPT-4 作为参考进行解释的手工真实标签,并计算余弦相似度、基于 BERT 的语义相似性,以及基于 GPT-4 的准确度等度量。
  • 测试 IOCCC 派生样本的去混淆代码生成及编译/运行的可行性。
  • 进行两个案例研究,分析反编译的 Android 恶意软件和 WannaCry 勒索软件以说明实际的防御分析。
(a) C.
(a) C.

实验结果

研究问题

  • RQ1RQ1:LLMs 是否理解源代码?
  • RQ2RQ2:LLMs 能否理解混淆或高难度阅读的代码?
  • RQ3公开可用的 LLM 在现实世界的代码分析和恶意软件分析任务中的表现如何?

主要发现

  • GPT-4 在未混淆代码(C、JavaScript、Python)上的准确性很高,总体准确率为 97.4%。
  • 较小的模型如 LLaMA-2-13B 和 Code-LLaMA-2-13B-instruct 很难给出有意义的代码分析。
  • 混淆的 JavaScript 会降低 GPT-3.5 和 GPT-4 的性能,其中 GPT-4 在混淆代码上的准确率达到 87%。
  • 在混淆环境中,GPT-4 通常优于 GPT-3.5,尽管两者都受影响;基础的混淆(如标识符重命名)对 GPT 模型的性能影响仅略有减弱。
  • GPT 模型对 IOCCC 风格的 C 代码的去混淆具有挑战性;可编译且正确可运行的结果很少见(测试样本中,GPT-3.5 ~8% 正确可运行,GPT-4 ~4% 正确可运行)。
  • GPT-4 在将输入与 IOCCC 示例关联方面显示出更好能力,但往往不能提供确切的年份/作者信息;GPT-3.5 能识别的 IOCCC 样本更少。
(b) Python.
(b) Python.

阅读本论文

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

在 Nubint 中阅读本论文

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