Automated Vulnerability Repair Based on Retrieval-Augmented Generation
As software scale continues to grow and complexity increases, vulnerabilities have become a significant issue affecting system security and stability. In recent years, advancements in machine learning and natural language processing technologies have made automated vulnerability repair an increasingly effective solution to this problem. However, existing automated vulnerability repair methods often lack a sufficient understanding of code context, making it difficult to handle complex vulnerabilities. As a result, the repair performance is often suboptimal, and these methods suffer from limited generalization capabilities. To address these issues, we propose VulRag, an automated vulnerability repair method based on Retrieval-Augmented Generation. This method leverages existing vulnerability repair samples as a knowledge base and retrieves the most similar vulnerability repair processes to assist the large language model in better understanding and repairing vulnerabilities. Additionally, we design four prompt templates to guide the model in utilizing the retrieved knowledge to generate repair code. Experimental results show that VulRag outperforms the best baseline method, achieving relative improvements of 7.9% and 17.3% in EM and BLEU scores, respectively.
Authors
- Yu Qiao (ORCID: https://orcid.org/0000-0002-6392-9461)
- Stephen Z. D. Cheng (ORCID: https://orcid.org/0000-0003-1448-0546)
- Yi Zhu (ORCID: https://orcid.org/0000-0001-8780-6768)
- Zhicheng Huang (ORCID: https://orcid.org/0000-0003-3105-3669)
Institutions
- Jiangsu Normal University (CN)
Publication Details
- Published
- 2025-04-18
- DOI
- https://doi.org/10.1109/iseae64934.2025.11041756
- Primary Topic
- Network Security and Intrusion Detection
- Type
- article
- Field-Weighted Citation Impact
- 0.00
Funders
- National Natural Science Foundation of China