Not Just Any Example: Security Requirements and Fix Patterns for Guiding LLM Vulnerability Repair
Zichen Liu, Liangyi Huang, Stanley Nguyen, Kha Tu Nguyen, Xinda Wang, Xusheng Xiao
Abstract
Software vulnerabilities leave systems open to attack, and their remediation is often delayed. Large language models (LLMs) have advanced automated patch generation, yet passing functionality tests does not ensure that a patch enforces the security requirement the vulnerability violated. Existing vulnerability repair techniques rely on curated patterns or templates with limited coverage, leaving unclear which repair strategies carry over across vulnerabilities and how they can steer LLMs. We present a large-scale empirical study that relates recurring fix patterns to the security impacts of vulnerabilities and examines how this knowledge can guide LLM-based repair. Building on a manual study of security patches, we cluster 3,816 security patches from 348 open-source repositories and analyze the edits and their context to derive concrete fix patterns, ranging from local safeguards to coordinated changes across multiple locations. We define 12 security impact classes by the security requirements that vulnerabilities violate and map them to repair categories and fix patterns, revealing characteristic repairs, alternative strategies within a class, and patterns shared across classes. We then use these patterns and impact-pattern associations to select repair examples for four LLMs on repair tasks of varying complexity. Guided example selection raises the four-model mean pass@3 from 37.9% under zero-shot prompting to up to 49.2%, whereas randomly selected examples reach only 36.9%. Our findings connect vulnerability characterization with patch generation and support organizing repair knowledge around security requirements.
Create a lesson
Metadata
- Categories
- cs.CR, cs.SE
Related papers
PORTA: Systematic Discovery of Vulnerabilities in Identity Brokers
Shared title terminologycs.CRZixu Zhou, Xiangyu Guo, Ilya Grishchenko et al.
ReQOR: Operator-Discrepancy Subspace Repair for Quantization-Conditioned Backdoors in Large Language Models
Shared title terminologycs.CRWonjune Seo, Minkyung Park, Saerom Park
The Oracle Is Not Enough: Secure Settlement for Prediction Markets
Shared title terminologycs.CRJiayu Liu, Sen Yang, Xueyuan Zhao et al.
Mixed-Initiative Mining of Root-Cause Analyses into Audit Priors for C/C++ Vulnerability Hunting
Shared title terminologycs.CRYuhei Kawakoya, Eitaro Shioji, Yuto Otsuki et al.
Harvesting Apple's Orchard: A Security Analysis of On-Device CoreML Models Across the Apple Ecosystem
Shared title terminologycs.CRJustice Owusu Agyemang, Winifred Harriet Asante, Kwame Opuni-Boachie Obour Agyekum et al.
Evaluating LLM Security Review Agents with Operationally Sourced Ground Truth
Shared title terminologycs.CRMudita Khurana, Karim Liman-Tinguiri