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

VulKey:基于领域特定修复模式的自动漏洞修复

VulKey: Automated Vulnerability Repair Guided by Domain-Specific Repair Patterns

The Chinese University of Hong Kong(香港中文大学);Sun Yat-sen University(中山大学)

Jia Li, Zhuangbin Chen, Yuxin Su, Michael R. Lyu

AI总结:

VulKey通过层级化抽象专家知识指导补丁生成,实现更高泛化性和语义丰富性,其在PrimeVul数据集上达到31.5%的修复准确率,超越现有方法。

摘要:

软件漏洞的增加凸显了有效自动漏洞修复(AVR)工具的必要性。尽管基于大语言模型(LLM)的方法有潜力,但它们难以整合结构化的安全知识,如CWE和NVD。当前方法要么通过将CWE-ID拼接入输入提示来浅层利用这些信息,效果有限,要么依赖于少样本学习,使用固定且无法泛化的示例,限制了其在现实场景中的有效性。为解决这一差距,我们提出了VulKey,一个基于LLM的AVR框架,利用专家知识的分层抽象来指导补丁生成。我们的新型三级抽象以CWE类型、语法动作和语义关键元素来制定修复策略。这种方法比具体示例更具泛化性,比传统基于语法的模板更具语义丰富性,克服了先前方法的覆盖限制。VulKey实施为一个两阶段流程:首先,专家知识匹配预测适当的修复模式;其次,修复代码生成使用模式引导的微调LLM生成安全补丁。在现实世界C/C++数据集PrimeVul上,VulKey实现了31.5%的修复准确率,超越最佳基线7.6%,并优于VulMaster和GPT-5等领先工具。此外,VulKey展示了跨语言和跨模型的泛化能力,在Java基准Vul4J上表现出最先进的性能。这些结果强调了结构化专家知识在提升AVR有效性中的重要性。我们的工作证明,通过层级模式显式建模和整合专家安全知识是构建更有效和可靠AVR工具的关键步骤。

英文摘要:

The increasing prevalence of software vulnerabilities highlights the need for effective Automatic Vulnerability Repair (AVR) tools. While LLM-based approaches are promising, they struggle to incorporate structured security knowledge from sources like CWE and NVD. Current methods either use this information superficially by concatenating the CWE-ID into the input prompt, yielding negligible benefits, or rely on few-shot learning with rigid, non-generalizable examples, which limits their effectiveness in real-world scenarios. To address this gap, we propose VulKey, an LLM-based AVR framework that leverages a hierarchical abstraction of expert knowledge to guide patch generation. Our novel three-level abstraction formulates repair strategies in terms of CWE type, syntactic actions, and semantic key elements. This approach captures the essence of a security fix with greater generality than concrete examples and more semantic richness than traditional syntax-based templates, overcoming the coverage limitations of prior methods. VulKey is implemented as a two-stage pipeline: first, expert knowledge matching predicts an appropriate repair pattern for the vulnerability; second, repair code generation uses a pattern-guided, fine-tuned LLM to produce secure patches. On the real-world C/C++ dataset PrimeVul, VulKey achieves 31.5% repair accuracy, surpassing the best baseline by 7.6% and outperforming leading tools such as VulMaster and GPT-5. Moreover, VulKey demonstrates cross-language and cross-model generalizability, with state-of-the-art performance on the Java benchmark Vul4J. These results underscore the importance of structured expert knowledge in advancing AVR effectiveness. Our work demonstrates that explicitly modeling and integrating expert security knowledge through hierarchical patterns is a crucial step toward building more effective and reliable AVR tools.

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

↑