NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Identifying Vulnerability Patches by Comprehending Code Commits with Comprehensive Change Contexts

Tianyu Chen, Lin Li, Taotao Qian, Zeyu Wang, Guangtai Liang, Ding Li, Qianxiang Wang, Tao Xie

Abstract

Applying security patches in open source software timely is critical for ensuring the security of downstream applications. However, it is challenging to apply these patches promptly because notifications of patches are often incomplete and delayed. To address this issue, existing approaches employ deep-learning (DL) models to identify additional vulnerability patches by determining whether a code commit addresses a vulnerability. Nonetheless, these approaches suffer from low accuracy due to the imprecise context provided for the patches. To provide precise context for patches, we propose a multi-granularity slicing algorithm and an adaptive-expanding algorithm to accurately identify code related to the patches. Additionally, the precise context enables to design an iterative identification framework, CompVPD, which utilizes the human validation results, and substantially improve the effectiveness. We empirically compare CompVPD with four state-of-the-art/practice (SOTA) approaches in identifying vulnerability patches. The results demonstrate that CompVPD improves the F1 score by 20% compared to the best scores of the SOTA approaches. Additionally, CompVPD contributes to security practice by helping identify 20 vulnerability patches and 18 fixes for high-risk bugs from 2,500 recent code commits in five highly popular open-source projects.

Introduction

Open-source software (OSS) serves as the foundation for modern digital infrastructure, yet it remains a primary vector for security vulnerabilities. While critical flaws are ideally reported via the National Vulnerability Database (NVD) with associated CVE identifiers, the reality is often far more fragmented. Many maintainers release "silent patches"—commits that resolve security issues without explicit labeling. Identifying these patches is crucial for downstream security but remains a significant challenge.

Existing deep learning (DL) approaches to patch identification often struggle with the "context problem." Models either receive insufficient context (e.g., only the changed lines), missing the semantic flow necessary to understand the fix, or too-coarse context (e.g., entire files), which introduces noise and exceeds model token limits.

The CompVPD Framework

To overcome these limitations, we present CompVPD, a framework designed to provide precise context for vulnerability patch identification through advanced code analysis and an iterative human-in-the-loop process.

Precise Context Generation

CompVPD moves beyond standard git diff outputs by employing two specialized algorithms to extract a "Goldilocks" level of context:

  1. Multi-granularity Slicing: This algorithm filters irrelevant files and uses a Bi-BFS slicing approach at the statement level. It retains only the code with direct data or control flow dependencies relative to the changed lines.
  2. Adaptive Context-Expanding: By leveraging Abstract Syntax Tree (AST) depth, this algorithm ensures that logical blocks (like try-catch or if-else structures) are kept intact, providing the model with complete semantic units rather than fragmented snippets.
The CompVPD pipeline for generating comprehensive change context from code commits.

Iterative Identification and Human Validation

A key innovation of CompVPD is its iterative framework. Recognizing that industrial security workflows already involve manual validation, CompVPD integrates this step into the model's learning cycle.

The iterative identification framework of CompVPD, incorporating human validation into the model fine-tuning loop.

As shown in the framework, the model (e.g., StarCoder or CodeBERT) identifies potential patches which are then validated by human engineers. These validated results—both true positives and false positives—are fed back into the training set for iterative fine-tuning. This process allows the model to adapt to the specific coding styles and vulnerability patterns of a target repository, effectively bridging the generalization gap inherent in cross-project tasks.

Key Results and Real-World Impact

We evaluated CompVPD using the VulFix dataset (1,359 vulnerability patches across 127 projects) and a real-world scan of 2,500 recent commits from popular projects like Jenkins and Dubbo.

  • Superior Accuracy: CompVPD achieved an F1 score of 0.603, representing a 20% improvement over the previous state-of-the-art (RGCN).
  • High Precision: With a precision of 0.910, the framework minimizes "alert fatigue" by ensuring that flagged commits are highly likely to be security-relevant.
  • Efficiency: Despite using large models like StarCoder (15.5B parameters), the precise context allows it to process a commit in less than 0.5 seconds.
  • Practical Utility: The tool successfully identified 20 previously unknown vulnerability patches and 18 high-risk bug fixes in major OSS projects, demonstrating its immediate value for security maintainers.

Conclusion

CompVPD demonstrates that the effectiveness of LLMs in software security tasks is heavily dependent on the quality of input context. By combining precise, AST-aware code slicing with an iterative human-validation loop, CompVPD significantly advances the state-of-the-art in identifying silent security patches. Future work will focus on extending these slicing techniques to other programming languages beyond Java and further reducing the human effort required for the initial validation seed.

Summary updated

BibTeX
@misc{chen2023identifying,
  author = {Tianyu Chen and Lin Li and Taotao Qian and Zeyu Wang and Guangtai Liang and Ding Li and Qianxiang Wang and Tao Xie},
  title = {{Identifying Vulnerability Patches by Comprehending Code Commits with Comprehensive Change Contexts}},
  year = {2023},
  eprint = {2310.02530},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.02530},
}
Figure