Identifying Helpful Context for LLM-based Vulnerability Repair: A Preliminary Study
作者: Gábor Antal, Bence Bogenfürst, Rudolf Ferenc, Péter Hegedűs
分类: cs.SE, cs.AI
发布日期: 2025-06-13
💡 一句话要点
探讨GPT-4o在Java漏洞修复中的上下文影响
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 大型语言模型 自动化漏洞修复 上下文信息 软件安全 提示设计 CVE Java漏洞
📋 核心要点
- 现有的自动化漏洞修复方法在处理复杂上下文信息时表现不佳,导致修复效果有限。
- 论文提出通过不同的上下文信息(如CWE、CVE)优化GPT-4o的漏洞修复能力,探索提示设计的影响。
- 实验结果表明,GPT-4o在修复独特漏洞方面表现优于基线,结合CVE信息和手动上下文的组合效果最佳。
📝 摘要(中文)
随着大型语言模型(LLMs)的进步,自动化漏洞检测和修复在软件系统中展现出潜力。本文研究了GPT-4o在修复Vul4J数据集中Java漏洞的表现,探讨了不同上下文信息对自动化漏洞修复能力的影响。通过与GPT-4的对比,评估了九种不同的提示,结果显示GPT-4o在相同提示下平均表现较差,但在修复独特漏洞方面有所提升,结合CVE信息和手动提取的代码上下文的组合表现最佳。
🔬 方法详解
问题定义:本文旨在解决大型语言模型在自动化漏洞修复中对上下文信息的依赖不足,现有方法在复杂场景下的修复效果不理想。
核心思路:通过设计多种提示,结合CWE和CVE等上下文信息,提升GPT-4o在修复Java漏洞时的性能,探索不同上下文对修复效果的影响。
技术框架:研究采用了Vul4J数据集,针对42个漏洞设计了九种不同的提示,分别执行三次以验证修复候选的有效性,使用自动化测试框架进行验证。
关键创新:最重要的创新在于结合CVE信息和手动提取的代码上下文,形成最佳的提示组合,从而显著提升了漏洞修复的成功率。
关键设计:在实验中,提示的设计考虑了上下文信息的丰富性和相关性,使用了多次执行以确保结果的可靠性,且对比了不同提示的修复效果。
📊 实验亮点
实验结果显示,GPT-4o在修复独特漏洞方面表现优于基线,使用最佳的提示组合后,修复成功率达到62%,显著高于原始基线的40%和重现结果的45%。CVE信息的引入显著提高了修复率,提示设计的优化效果明显。
🎯 应用场景
该研究的潜在应用领域包括软件安全性提升、自动化代码审查和漏洞修复工具的开发。通过优化大型语言模型在漏洞修复中的表现,能够有效降低软件系统的安全风险,提升开发效率,具有重要的实际价值和未来影响。
📄 摘要(原文)
Recent advancements in large language models (LLMs) have shown promise for automated vulnerability detection and repair in software systems. This paper investigates the performance of GPT-4o in repairing Java vulnerabilities from a widely used dataset (Vul4J), exploring how different contextual information affects automated vulnerability repair (AVR) capabilities. We compare the latest GPT-4o's performance against previous results with GPT-4 using identical prompts. We evaluated nine additional prompts crafted by us that contain various contextual information such as CWE or CVE information, and manually extracted code contexts. Each prompt was executed three times on 42 vulnerabilities, and the resulting fix candidates were validated using Vul4J's automated testing framework. Our results show that GPT-4o performed 11.9\% worse on average than GPT-4 with the same prompt, but was able to fix 10.5\% more distinct vulnerabilities in the three runs together. CVE information significantly improved repair rates, while the length of the task description had minimal impact. Combining CVE guidance with manually extracted code context resulted in the best performance. Using our \textsc{Top}-3 prompts together, GPT-4o repaired 26 (62\%) vulnerabilities at least once, outperforming both the original baseline (40\%) and its reproduction (45\%), suggesting that ensemble prompt strategies could improve vulnerability repair in zero-shot settings.