如果大型语言模型愿意“查看”:简单的逐行检查可提升漏洞定位
If LLMs Would Just Look: Simple Line-by-line Checking Improves Vulnerability Localization
AI总结:
针对LLMs在较长代码上下文中漏洞定位准确性不足的问题,提出LOVA框架,利用自注意力机制跟踪代码行注意力权重,显著提升跨语言漏洞定位精度、可扩展性和鲁棒性。
摘要:
软件系统的快速扩展和已报告漏洞数量的不断增加,凸显了准确识别易受攻击代码段的重要性。传统的漏洞定位方法(如手动代码审计或基于规则的工具)通常耗时且范围有限,通常专注于特定编程语言或漏洞类型。近年来,GPT和LLaMA等大型语言模型(LLMs)的引入为漏洞检测自动化开辟了新可能。然而,尽管LLMs在该领域显示出潜力,但它们面临挑战,尤其是在较长代码上下文中保持准确性。本文介绍LOVA,一个利用LLMs自注意力机制增强漏洞定位的新型框架。我们的核心见解是,自注意力机制为输入的不同部分分配不同的重要性,使得跟踪模型对特定代码行的注意力程度成为可能。在漏洞定位背景下,假设是易受攻击的代码行自然会吸引更高的注意力权重,因为它们对模型输出的影响更大。通过系统跟踪注意力权重的变化并聚焦于特定代码行,LOVA提高了跨多种编程语言识别易受攻击代码行的精度。通过严格的实验和评估,我们证明LOVA显著优于现有的基于LLM的方法,F1分数提升高达5.3倍。LOVA还表现出强大的可扩展性,在C、Python、Java和Solidity等语言的智能合约漏洞定位中提升高达14.6倍。其鲁棒性通过在不同LLM架构上的一致性能得到证明。
英文摘要:
The rapid expansion of software systems and the growing number of reported vulnerabilities have emphasized the importance of accurately identifying vulnerable code segments. Traditional methods for vulnerability localization, such as manual code audits or rule-based tools, are often time-consuming and limited in scope, typically focusing on specific programming languages or types of vulnerabilities. In recent years, the introduction of large language models (LLMs) such as GPT and LLaMA has opened new possibilities for automating vulnerability detection. However, while LLMs show promise in this area, they face challenges, particularly in maintaining accuracy over longer code contexts. This paper introduces LOVA, a novel framework leveraging the self-attention mechanisms inherent in LLMs to enhance vulnerability localization. Our key insight is that self-attention mechanisms assign varying importance to different parts of the input, making it possible to track how much attention the model focuses on specific lines of code. In the context of vulnerability localization, the hypothesis is that vulnerable lines of code will naturally attract higher attention weights because they have a greater influence on the model's output. By systematically tracking changes in attention weights and focusing on specific lines of code, LOVA improves the precision of identifying vulnerable lines across various programming languages. Through rigorous experimentation and evaluation, we demonstrate that LOVA significantly outperforms existing LLM-based approaches, achieving up to a 5.3x improvement in F1-scores. LOVA also demonstrated strong scalability, with up to a 14.6x improvement in smart contract vulnerability localization across languages like C, Python, Java, and Solidity. Its robustness was proven through consistent performance across different LLM architectures.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。