arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2403.17218cs.SEcs.CRcs.LG
收藏

犯错的是机器:漏洞检测挑战 LLM 推理

To Err is Machine: Vulnerability Detection Challenges LLM Reasoning

Iowa State University(爱荷华州立大学);University College London(伦敦大学学院)

Benjamin Steenhoek, Md Mahbubur Rahman, Monoshi Kumar Roy, Mirza Sanjida Alam, Hengbo Tong, Swarna Das, Earl T. Barr, Wei Le

AI总结:

本文评估 LLM 在漏洞检测这一代码推理任务上的表现,发现 SOTA 模型平衡准确率仅 54.5%,扩大模型、数据、提示或微调均难显著改善。

摘要:

本文提出一项具有挑战性的代码推理任务:漏洞检测。大型语言模型(LLM)已在自然语言和数学推理方面展现出可喜成果,但在我们的漏洞检测评估中,即使是在大量源代码上预训练过的最先进(SOTA)模型,也仅取得 54.5% 的平衡准确率。我们对 LLM 响应的错误分析表明,模型难以推理与识别漏洞相关的代码语义,尤其是由细微文本变化导致的微妙语义差异。我们探究了主流模型和训练设置,以理解它们对漏洞检测性能的影响——包括更好的提示、更大的模型、更多预训练数据和微调——但没有一种带来显著提升。这引出一个问题:单纯扩大训练数据和模型规模,是否足以让我们“解决”漏洞检测这类复杂代码推理任务,还是需要在建模和训练技术上实现根本性转变。我们还探索了在提示中加入领域知识;尽管这帮助某些模型理解了部分代码语义,但漏洞检测需要多步推理,而这些模型仍在诸如变量关系推理等步骤上失败。结果表明,要攻克漏洞检测,可能需要新模型、新训练方法或更多面向执行的预训练数据。我们推测,对源代码进行自回归预训练可能无法有效提取代码语义,尤其是在当前执行数据稀缺的预训练混合数据中。漏洞检测作为代码推理任务的成功,可惠及调试、测试输入生成和程序修复等软件工程领域。代码和数据见 https://doi.org/10.6084/m9.figshare.27368025。

英文摘要:

In this paper, we present a challenging code reasoning task: vulnerability detection. Large Language Models (LLMs) have shown promising results in natural-language and math reasoning, but state-of-the-art (SOTA) models reported only 54.5% Balanced Accuracy in our vulnerability detection evaluation, even those models pre-trained on large amounts of source code. Our error analysis on LLM responses shows that the models struggle to reason about the code semantics relevant to identifying vulnerabilities, especially subtle semantic differences caused by small textual changes. We explored prominent models and training settings to understand their effects on vulnerability detection performance -- including better prompts, larger models, more pre-training data, and fine-tuning -- but none led to significant improvements. This raises the question of whether simply scaling training data and model size will allow us to "solve" complex code reasoning tasks like vulnerability detection, or if a fundamental shift in modeling and training techniques is required. We also explored adding domain knowledge to prompts; although it helped certain models understand some code semantics, vulnerability detection requires multi-step reasoning, and these models still failed in steps, such as reasoning about variable relations. Our results suggest that new models, new training methods, or more execution-specific pretraining data may be needed to conquer vulnerability detection. We speculate that auto-regressive pre-training on source code may not effectively extract code semantics, especially on the current pretraining mixtures, in which execution data is scarce. Success on vulnerability detection as a code reasoning task can benefit many areas of software engineering such as debugging, test input generation, and program repair. Our code and data are available at https://doi.org/10.6084/m9.figshare.27368025.

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

↑