Manuscript Offprint

arXiv:2609.39783

COMPASS: Predicting the Relationship of Multiple Patches for Vulnerabilities with LLMs

Yi Song, Dongchen Xie, Xiaoyuan Xie, He Zhang, Lin Xu, Chunying Zhou, Zhi Jin

Yi Song 1,∗^{1,*}, Dongchen Xie 1,∗^{1,*}, Xiaoyuan Xie 2,†^{2,\dagger}, He Zhang 2^{2}, Lin Xu 1^{1}, Chunying Zhou 2^{2}, and Zhi Jin 2^{2}

1^{1}School of Cyber Science and Engineering, Wuhan University, Wuhan, China

2^{2}School of Computer Science, Wuhan University, Wuhan, China

{yisong, xiedongchen, xxie, zhanghe, xulin_xl, zcy9838, zhijin}@whu.edu.cn

Abstract—Modern software heavily relies on code reuse, so upstream vulnerability fixes do not automatically propagate to downstream codebases. Downstream maintainers must manually adopt patches to eliminate known risks. In practice, a single vulnerability often corresponds to multiple patches, which greatly complicates downstream patch adoption because different patch relationships imply different adoption strategies. To address this challenge, we first manually inspect large-scale multi-patch vulnerabilities ( ∼\sim1K) in the real world and interview experienced developers, summarizing six typical types of patch relationships, i.e., Merge, Mirror, Better Solution, Fixing-of-Fixing, Collaboration, and Separation. Based on these observations, we propose COMPASS, an automated approach that predicts the relationships of multiple vulnerability patches with large language models. Given a CVE as input, COMPASS follows a four-phase pipeline that (i) identifies the patch group and pre-scans explicit relationships, (ii) performs individual patch analysis, (iii) infers relationship instances via a hierarchy-guided prompt, and (iv) validates completeness and consistency of the inferred results. As output, COMPASS reports the predicted relationships within the patch group and visualizes them as a relationship graph. We evaluate COMPASS on a benchmark of 300 multi-patch CVEs and compare it against mainstream learning-based and LLM baselines. Results show that our method achieves strong and consistent prediction effectiveness and outperforms SOTA by 85.04% on average. We publicly release an online querying website to support community reuse of patch relationships knowledge: https://patch-relation.com.

Index Terms—Security Patches, Patch Relationships, Open-source Community, Large Language Models

I. INTRODUCTION

Security vulnerabilities pose severe risks to software systems, patches (typically in the form of code commits 1^{1}) are the most important and straightforward resources to remediate their hazard [1]–[3]. In practice, one vulnerability is often fixed by more than one patch rather than a single commit, i.e., the “many-for-one” fixing pattern. Existing research has shown that this phenomenon is widespread in real-world software ecosystems. For example, Xu et al. reveal that multiple patches are developed for about 41% of the vulnerabilities by an empirical study [4], Jiang et al. point out that one vulnerability may map to more than one patch due to incomplete fixes [5], and Li et al. find that a non-trivial portion of vulnerability entries on public platforms such as CVE (Common Vulnerabilities and Exposures) [6] and NVD (National Vulnerability Database) [7] has multiple associated code commits. Apart from these, there are many other studies demonstrating the prevalence of this many-for-one fixing pattern [4], [8]–[11].

In the context of open-source environments, the general many-for-one fixing pattern in upstream software brings significant complexity to patch adoption for downstream projects that depend on it. The complexity is largely determined by the relationships of patches, as different relationships directly lead to different adoption strategies. Specifically, modern software development heavily relies on code reuse: many projects act as upstream software platforms whose code is copied, integrated, and customized by a large number of downstream projects, and upstream vulnerability fixes do not propagate to downstream code by default because the code between the upstream and downstream is disconnected [12]–[16]. Thus, when an upstream vulnerability is fixed, downstream projects need to manually adopt these patches. However, the decoupling caused by code copying, long-term independent evolution, and project-specific customization often makes upstream patches inapplicable or ambiguous, and more importantly, the many-for-one fixing pattern implies that these patches may play different roles and interact in complex ways. As a result, downstream maintainers must understand how these patches relate to each other (i.e., their relationships) before deciding how to adopt them [17]–[20].

For example, if Patch-A initially fixes a vulnerability but inadvertently introduces a new bug or vulnerability, and Patch-B later fixes this issue, the two patches must be applied sequentially and released together, otherwise, releasing the two patches in different releases (e.g., due to the tight schedule, the capability of the maintenance team, or the limitation of available manpower) may expose users to new security risks. In another case, multiple patches may collaboratively fix a vulnerability step by step, where later patches just depend on variables or logic introduced by earlier ones. Such patches must be applied in order, but they can be released separately when necessary, because intermediate patches represent incomplete yet safe fixes that do not introduce new flaws. For another example, if Patch-A provides a complete fix and Patch-B merely optimizes the original solution (e.g., improving performance or code readability), downstream maintainers may choose to apply only the latter to avoid redundant

∗^{*}Yi Song and Dongchen Xie contributed equally to this work.

†^{\dagger}Xiaoyuan Xie is the corresponding author.

1^{1}We use the terms “commit” and “patch” interchangeably unless otherwise specified, because the commits we are focusing on to fix vulnerabilities are actually patches.

work. In addition to the above example situations, there are more other cases where the relationship of patches largely participates in the vulnerability fixing, which will be given in Section II. These examples illustrate that different patch relationships imply fundamentally different adoption behaviors, and misunderstanding these relationships can lead to delayed or inconsistent decisions, and a higher risk of incomplete or even unsafe patch adoption.

Therefore, a precise understanding of patch relationships is essential for facilitating effective patch adoption in downstream software, which directly impacts the quality and security of end-user software applications. However, such understanding is currently obtained almost exclusively through manual analysis, which is not only time-consuming and labor-intensive, but also inherently error-prone and difficult to scale [4], [21], [22]. Maintainers need to carefully inspect commit messages, examine code changes across multiple patches, and reason about subtle inter-patch dependencies. As the number of vulnerabilities and associated patches continues to grow, this manual process becomes increasingly impractical.

To address this challenge, we propose COMPASS, an automated approach of predicting the relationship of MultiPle pAtcheS for vulnerabilities with large language models (LLMs). As a preliminary, we inspect large-scale vulnerability cases (1,050 CVE entries) having multiple patches in the wild, and interview 20 experienced developers, summarizing six typical types of relationships of patches, i.e., Merge, Mirror, Better Solution, Fixing-of-Fixing, Collaboration, and Separation (which will be explained in detail in Section II). Driven by these typical relationships, COMPASS performs a fourfold pipeline to predict patches' relationships. First, for a given vulnerability, we determine all its associated patches (referred to as patch group) by checking the corresponding NVD webpage for recorded patch links, and pre-scanning explicit relationships. Second, we feed the patch group (including the commit ID, the branch/version information, the commit message, and the code change of each patch) to LLMs, and guide LLMs to think about three questions using the intuition of chain-of-thought: (i) double-checking whether each patch directly fixes the vulnerability, (ii) identifying key components/files modified by the patches, and (iii) noting implicit signals available in commit messages and branch/version information. Third, we design a sophisticated prompt describing the summarized six relationships in the text form, and ask LLMs to predict the relationships of the fed patches according to given schema based on the thoughts. Fourth, LLMs are required to validate the prediction result to make sure that all patches have been predicted, no contradictory relationships, and so on. Finally, the relationships within the patch group will be output and further reorganized into a visualized graph to facilitate users' understanding.

To evaluate the effectiveness of COMPASS, we construct a benchmark consisting of 300 vulnerability entries with 2∼72 \sim 7 patches, which is completely disjoint from the 1,050 multipatch vulnerability entries used for taxonomy construction. The benchmark entries are collected from public platforms CVE [6], NVD [7], and Snyk [23], span the period from 2009 to 2024, and each entry includes a CVE identifier, all associated patches and their relationships. We further develop an online website to publicly host vulnerability entries together with the relationships of their multiple patches. This design is motivated by the observation that a single CVE can affect many downstream projects, and thus the relationships of its patches are often repeatedly queried by different teams, making a shared resource valuable for avoiding duplicated manual effort. The 300 benchmark entries have been uploaded as an initial release, and we will continuously maintain the website in the future. We also implement COMPASS as a user-friendly tool that, given the identifier of a CVE having multiple patches, automatically predicts its patch relationships, and visualizes the results to support practical downstream patch adoption.

The main contributions of this paper are as follows:

• A novel approach. We propose COMPASS to automatically predict the relationship of multiple patches for a given vulnerability, for facilitating downstream maintainers' understanding for better adoption. To the best of our knowledge, this is the first work focusing on vulnerability patches' relationship prediction.

• A manually-crafted benchmark. We construct a benchmark of 300 real-world vulnerabilities with multiple patches, where patch relationships are manually analyzed and labeled for evaluation. We make this dataset publicly available to facilitate future research.

• An online querying website and a tool. We develop and maintain a public website to host patch relationships for community reuse. We also implement COMPASS as a user-friendly tool to automatically predict and visualize patches’ relationships of disclosed vulnerabilities.

The experimental code (including the designed prompt) and data, as well as the source code and the instructions for the tool, are given in a public repository [24]. The URL of the online querying website is https://patch-relation.com.

The remainder of this paper is organized as follows: Section II describes the summarized six typical types of patch relationships. Section III describes the details of COMPASS. Section IV provides the research questions, baselines, datasets, and metrics. Section V analyzes the experimental results. Section VI further discusses our approach. Section VII declares the threats to validity. Section VIII summarizes the related work. Section IX concludes the paper and outlines future work.

References (53)

  • Spider: Enabling fast patch propagation in related software repositories
  • Just-in-time detection of silent security patches
  • Vulnerabilities and security patches detection in oss: A survey
  • Tracking patches for open source software vulnerabilities
  • Understanding vulnerability inducing commits of the linux kernel
  • A large-scale empirical study of security patches
  • Locating the security patches for disclosed oss vulnerabilities with vulnerability-commit correlation ranking
  • Automated mapping of vulnerability advisories onto their fix commits in open source repositories
  • A large-scale analysis of the effectiveness of publicly reported security patches
  • Lags in the release, adoption, and propagation of npm vulnerability fixes
  • Tracing vulnerability propagation across open source software ecosystems
  • Tracing vulnerabilities in maven: A study of cve lifecycles and dependency networks
  • An investigation of the android kernel patch ecosystem
  • The ripple effect of vulnerabilities in maven central: Prevalence, propagation, and mitigation challenges
  • An investigation of patch porting practices of the linux kernel ecosystem
  • Automated patch backporting in linux (experience paper)
  • What do they fix? llm-aided categorization of security patches for critical memory bugs (opens arXiv in a new tab)
  • An exploratory study of the pull-based software development model
  • Refactoring-aware patch integration across structurally divergent java forks
  • compass: Predicting the relationship of multiple patches for vulnerabilities with llms
  • An empirically based terminology and taxonomy for global software engineering
  • Towards a taxonomy of code review smells
  • Software development waste
  • Grounded theory in software engineering research: a critical review and guidelines
  • Recovering commit branch of origin from github repositories
  • Branch use in practice: A large-scale empirical study of 2,923 projects on github
  • Semantic slicing of software version histories
  • Speedoo: Prioritizing performance optimization opportunities
  • Recommending refactorings via commit message analysis
  • An empirical study on github pull requests’ reactions
  • Vfcfinder: Pairing security advisories and patches
  • Secomlint: A linter for security commit messages (opens arXiv in a new tab)
  • Are security commit messages informative? not enough!
  • On the informativeness of security commit messages: A large-scale replication study (opens arXiv in a new tab)
  • DeepSeek-V3 Technical Report
  • Gemini 2.5: Pushing the Frontier with Advanced Reasoning, Multimodality, Long Context, and Next Generation Agentic Capabilities
  • Automating code review activities by large-scale pre-training
  • Codet5: Identifier-aware unified pre-trained encoder-decoder models for code understanding and generation
  • Bert: Pre-training of deep bidirectional transformers for language understanding
  • Dual prompt-based few-shot learning for automated vulnerability patch localization
  • Not every patch is an island: Llm-enhanced identification of multiple vulnerability patches
  • Patchfinder: A two-phase approach to security patch tracing for disclosed vulnerabilities in open-source software
  • Selink: A semantic-enhanced modular framework for issue-commit link recovery
  • Ealink: An efficient and accurate pre-trained framework for issue-commit link recovery
  • Mtlink: Adaptive multi-task learning based pre-trained language model for traceability link recovery between issues and commits
  • No more fine-tuning? an experimental evaluation of prompt tuning in code intelligence
  • Prompt tuning in code intelligence: An experimental evaluation
  • Knowledge-guided prompt learning for request quality assurance in public code review
  • A systematic analysis of performance measures for classification tasks
  • Deepfl: Integrating multiple fault diagnosis dimensions for deep fault localization
  • Fault localization with code coverage representation learning
  • Learning to detect and localize multilingual bugs
  • Upset: visualization of intersecting sets