arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2606.25356cs.CRcs.SE
收藏

表示至关重要:LLM 漏洞推理中程序表示的实证研究

Representation Matters: An Empirical Study of Program Representations for LLM Vulnerability Reasoning

University at Buffalo, SUNY(纽约州立大学布法罗分校)

Andrew Stoltman, Johnathan Tang, Haipeng Cai

AI总结:

通过 RepBench 基准比较原始源码与基于静态分析的程序表示,发现 AST+PDG 组合准确率达 83.2%,远超原始源码的 53.5%,表明精心选择的结构化表示能提供更优的准确率-开销权衡。

摘要:

大型语言模型(LLM)越来越多地用于自动化漏洞检测,但目前尚不清楚如何表示程序结构和语义以进行基于 LLM 的推理。大多数基于提示的方法提供原始源代码,隐含地假设更多的源代码级上下文能为模型提供更好的证据。本文通过 RepBench 挑战了这一假设,这是一个将原始源代码与基于静态分析的程序表示进行比较的实证基准。RepBench 将现实世界的 C/C++ 漏洞测试用例转换为多种表示:原始源代码、抽象语法树(AST)、控制流图(CFG)、程序依赖图(PDG)、它们的组合,以及一个增强 PDG(ePDG)的辅助轨道。使用从 PrimeVul 派生的包含 107 个基于 Joern 的测试用例(涵盖五个 CWE 类别)的精选语料库,我们在固定的思维链和结构化输出协议下评估了十种表示变体,以及通过 VulChecker/Hector 生成的 19 个额外的 ePDG 案例。表示选择显著影响 LLM 漏洞推理。最强的变体 AST+PDG 达到了 83.2% 的准确率,而原始源代码仅为 53.5%。在家族层面,仅使用图的提示优于仅使用源代码和源代码加图的提示,同时所需的提示开销大大减少。这些结果揭示了一种上下文稀释效应:将原始源代码添加到紧凑的结构图证据中可能会降低推理能力,因为漏洞相关证据的显著性降低。总体而言,我们的发现表明,精心选择的结构化表示比简单地给 LLM 更多原始输入提供了更好的准确率-开销权衡,并表明静态分析可以作为面向安全的 LLM 推理的有效提示构建层。

英文摘要:

Large Language Models (LLMs) are increasingly used for automated vulnerability detection, but it remains unclear how program structure and semantics should be represented for LLM-based reasoning. Most prompting-based approaches provide raw source code, implicitly assuming that more source-level context gives the model better evidence. This paper challenges that assumption through RepBench, an empirical benchmark comparing raw source code with static-analysis-based program representations. RepBench converts real-world C/C++ vulnerability testcases into multiple representations: raw source, Abstract Syntax Trees (ASTs), Control-Flow Graphs (CFGs), Program Dependence Graphs (PDGs), their combinations, and an auxiliary track of enriched PDGs (ePDGs). Using a curated PrimeVul-derived corpus of 107 Joern-based testcases across five CWE categories, we evaluate ten representation variants under a fixed Chain-of-Thought and structured-output protocol, plus 19 additional ePDG cases generated through VulChecker/Hector. Representation choice substantially affects LLM vulnerability reasoning. The strongest variant, AST+PDG, achieves 83.2% accuracy, compared with 53.5% for raw source. At the family level, graph-only prompts outperform both source-only and source-plus-graph prompts while requiring far less prompt overhead. These results reveal a context dilution effect: adding raw source code to compact structural graph evidence can degrade reasoning by making vulnerability-relevant evidence less salient. Overall, our findings show that carefully selected structural representations offer a better accuracy-overhead tradeoff than simply giving LLMs more raw input, and suggest that static analysis can serve as an effective prompt-construction layer for security-focused LLM reasoning.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑