EUVIMEDEUVIMED entdecken
Open Access · CC BY 4.0

Fix Pattern-Aware Vulnerability Patch Generation via In-Context Learning

Miaomiao Shao, Yuxin Ding, Cuiyun Gao, Junru Wang, Guoqing Zhu

ACM Transactions on Software Engineering and Methodology · 31.10.2026 · 35 (10) · 1-46

DOI: 10.1145/3796512 ↗

Kurz gefasst

Fachartikel in der Zeitschrift ACM Transactions on Software Engineering and Methodology, online erschienen am 16.09.2026. Verfasst von Miaomiao Shao und 4 weiteren Autor:innen. Die Arbeit wurde bisher 2-mal zitiert (Crossref) und nennt 73 Literaturangaben. Der Volltext ist frei zugänglich (Open Access, CC BY 4.0). Gefördert von: Guangdong Basic and Applied Basic Research Foundation, National Natural Science Foundation of China under project, Shenzhen-Hong Kong Jointly Funded Project.

AbstractBibliografische AngabenZitierenVerwandte Studien

Abstract (Originalsprache)

With the rapid advancement of deep learning technologies, numerous large language models (LLMs) have been developed, achieving remarkable performance across various tasks. Nevertheless, in the field of vulnerability patch generation, previous studies still face notable limitations: (1) Insufficient context. LLM-based approaches often rely on a single vulnerable function as prompt input for generating patches, which prevents the model from utilizing adequate contextual information and limits its ability to produce accurate patches. (2) Difficulties in extracting effective fix patterns. The substantial semantic differences between various vulnerabilities result in a wide range of fix patterns. Consequently, automatically extracting effective fix patterns tailored to specific vulnerabilities becomes a significant challenge. To address this, we propose PailGen, a novel fix Pattern-Aware, In-context Learning-incorporated vulnerability patch GENeration approach. PailGen comprises three main modules: hybrid patch retrieval module, fix pattern mining module, and in-context learning-incorporated patch generation module. (1) Hybrid patch retrieval module, aims at retrieving the top- \( k \) relevant vulnerability-fix pairs from the existing codebase by combining BM25 and Dense Passage Retrieval (DPR) to construct a hybrid patch retriever. (2) Fix pattern mining module, aims at extracting effective fix patterns from the relevant vulnerability-fix pairs by leveraging an automatic fix pattern mining strategy based on Abstract Syntax Tree (AST). Fix patterns are designed to analyze code changes at different levels (e.g., expression-level and statement-level). (3) In-context learning-incorporated patch generation module, aims at providing comprehensive contextual information for LLMs by integrating the vulnerable code, its AST, the relevant patches, and the extracted fix patterns into the prompt input. Overall, PailGen delivers better demonstrations for in-context learning and provides more comprehensive semantic guidance for patch generation, enabling LLMs to effectively address vulnerabilities. We evaluate PailGen on two real-world C/C++ vulnerability datasets. The experimental results demonstrate that PailGen achieves the best performance, outperforming all baseline approaches.

Förderung

  • Guangdong Basic and Applied Basic Research Foundation
  • National Natural Science Foundation of China under project
  • Shenzhen-Hong Kong Jointly Funded Project

Zitieren

APA

Shao, M., Ding, Y., Gao, C., Wang, J., & Zhu, G. (2026). Fix Pattern-Aware Vulnerability Patch Generation via In-Context Learning. ACM Transactions on Software Engineering and Methodology, 35(10), 1-46. https://doi.org/10.1145/3796512

Vancouver

Shao M, Ding Y, Gao C, Wang J, Zhu G. Fix Pattern-Aware Vulnerability Patch Generation via In-Context Learning. ACM Transactions on Software Engineering and Methodology. 2026;35(10):1-46. doi:10.1145/3796512

BibTeX
@article{Shao2026,
  author = {Shao, Miaomiao and Ding, Yuxin and Gao, Cuiyun and Wang, Junru and Zhu, Guoqing},
  title = {Fix Pattern-Aware Vulnerability Patch Generation via In-Context Learning},
  journal = {ACM Transactions on Software Engineering and Methodology},
  year = {2026},
  volume = {35},
  number = {10},
  pages = {1--46},
  doi = {10.1145/3796512}
}
Kostenlos starten →