[论文解读] The Hitchhiker's Guide to Program Analysis: A Journey with Large Language Models
该论文提出 LLift,是一个完全自动化的框架,将静态分析与大语言模型相结合,在大型代码库(Linux 内核)中检测 Use-Before-Initialization 漏洞,在测试用例中达到 50% 精度和 100% 召回,并发现了 13 个新错误。
Static analysis is a widely used technique in software engineering for identifying and mitigating bugs. However, a significant hurdle lies in achieving a delicate balance between precision and scalability. Large Language Models (LLMs) offer a promising alternative, as recent advances demonstrate remarkable capabilities in comprehending, generating, and even debugging code. Yet, the logic of bugs can be complex and require sophisticated reasoning and a large analysis scope spanning multiple functions. Therefore, at this point, LLMs are better used in an assistive role to complement static analysis. In this paper, we take a deep dive into the open space of LLM-assisted static analysis, using use-before-initialization (UBI) bugs as a case study. To this end, we develop LLift, a fully automated framework that interfaces with both a static analysis tool and an LLM. By carefully designing the framework and the prompts, we are able to overcome a number of challenges, including bug-specific modeling, the large problem scope, the non-deterministic nature of LLMs, etc. Tested in a real-world scenario analyzing nearly a thousand potential UBI bugs produced by static analysis, LLift demonstrates a potent capability, showcasing a reasonable precision (50%) and appearing to have no missing bugs. It even identified 13 previously unknown UBI bugs in the Linux kernel. This research paves the way for new opportunities and methodologies in using LLMs for bug discovery in extensive, real-world datasets.
研究动机与目标
- 在像 Linux 内核这样的大型软件系统中,推动静态分析在精度与可扩展性之间取得平衡的必要性。
- 研究大语言模型是否能够在传统静态分析在时间/内存约束等方面受限的场景中协助发现漏洞。
- 开发一个完全自动化的框架(LLift),将静态分析与LLMs 集成以识别 Use-Before-Initialization 漏洞。
- 设计提示策略和工作流技术,以缓解 LLM 的局限性(非确定性、上下文窗口、幻觉)并实现可靠的结果。
- 在约 1,000 个潜在 UBI 漏洞上评估 LLift,并报告精度、召回率和新发现的漏洞。
提出的方法
- 引入后置约束引导的路径分析,利用后置条件去除不可行路径。
- 通过将分析拆分为多个可管理的与 LLM 的对话来实现任务分解。
- 使用渐进式提示按需提供函数定义,减轻上下文窗口压力。
- 引入自我验证机制,使 LLM 审查其自身输出以提高可靠性。
- 应用思考链提示和基于源代码的分析来引导 LLM 推理。
- 实现一个软件代理,通过 OpenAI API 协调 LLM 调用并处理结果。
实验结果
研究问题
- RQ1LLMs 是否能够在大型实际代码库中对静态分析提供有意义的协助,以检测 Use-Before-Initialization 漏洞?
- RQ2哪些提示策略和工作流设计能够实现可靠且可扩展的 LLM 辅助漏洞发现?
- RQ3在真实世界的潜在 UBI 漏洞数据集上,LLift 的精度和召回率表现如何?
- RQ4LLift 能发现哪些传统静态分析可能漏掉的新漏洞?
主要发现
- LLift 在近 1,000 个分析的 UBI 实例中实现了 50% 的精度和 100% 的召回率。
- LLift 在 Linux 内核中发现了 13 个此前未知的 UBI 漏洞,经 Linux 社区验证。
- 在超过 1,000 个分析案例中,26 份报告为阳性,证明了在现实世界数据上的实际有效性。
- 与基础静态分析管道(UBITect)相比,LLift 处理由时间/内存约束引起的困难案例。
- 该方法证明了使用 LLMs 来辅助静态分析进行大规模漏洞发现的可行性。
- 开放源代码意图:计划发布代码和数据以促进行业研究。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。