Not Just Any Example: Security Requirements and Fix Patterns for Guiding LLM Vulnerability Repair

arXiv:2611.31993 · cs.CR, cs.SE · Submitted 2026-11-24 · Read on arXiv

Listen

Radio episode about this paper

Transcript

Introduction to the show: ident: Security Radio. Generated commentary on the latest security and cryptography papers.

Nadia: We're looking at the paper: "Not Just Any Example".

Title and authors: Nadia: We’re starting with this paper, "Not Just Any Example: Security Requirements and Fix Patterns for Guiding LLM Vulnerability Repair". The authors are Zichen Liu, Liangyi Huang, Stanley Nguyen, Kha Tu Nguyen, Xinda Wang, and Xusheng Xiao from Arizona State University and the University of Texas at Dallas.

Elias: That's a solid team. They bring together work on security impacts from Priya’s side and probably some deep insights into the mechanics of how these LLMs generate code fixes that Nadia’s work focuses on.

Priya: I'm interested in seeing how they handle the data collection, since they're looking at three thousand eight hundred sixteen patches from three hundred forty-eight different open-source repositories <ref:2611.31993#pg1>. That’s a massive amount of data to sift through for meaningful patterns.

Nadia: Right, that’s what they do first: manual study of security patches to derive concrete fix patterns by examining edits in those patches, which is the foundation of their entire approach.

Elias: They look at how code changes recur and how those changes combine with surrounding code to identify patterns that capture the relationship between the affected data, its required condition, and the actual fixes.

Priya: So it’s not just looking for similar lines of code; they are trying to find a structure in *how* security requirements translate into specific programming actions.

The paper's summary: Nadia: They move on to defining what those security impacts actually mean. They define twelve security impact classes based on violated security requirements, drawing from studies on things like concurrency and algorithmic complexity, and also looking at certificate validation <ref:2611.31993#pg3,12 security impact classes based on violated security requirements, drawing>.

Elias: What’s really interesting is that they aren't just using a broad label like a general CWE; they create a more comprehensive taxonomy that captures individual violations and directed chains of impact.

Priya: That sounds crucial because existing impact-aware studies often focus on only specific types of vulnerabilities, leaving the broader spectrum of security impacts incompletely characterized.

Nadia: They conduct this large-scale study on three thousand eight hundred sixteen patches to uncover a wide spectrum of violations across things like memory safety, concurrency issues, resource management problems, and data protection <ref:2611.31993#pg1>.

Elias: And they show that a general consequence or a broad category label doesn't always uniquely identify the actual requirement that was broken in the code. That’s a subtle but important point for understanding what we are actually fixing when we see an issue.

The paper's improvements: Nadia: The main contribution they make is relating these identified fix patterns directly to those security impacts to select repair examples for four different LLMs, testing them on tasks with varying levels of complexity.

Elias: They argue that choosing the right fix examples substantially improves how well the LLM generates a patch, and it shows that this relevant example knowledge helps the models diagnose the specific vulnerability better than just looking at the code context alone.

Priya: So it’s not just about feeding them more text; it’s about feeding them *contextually relevant* examples that share a necessary repair element to help them understand what needs fixing.

Nadia: They found that cluster-guided and impact-guided retrieval methods improve repair even for a frontier model, like Qwen three point eight, showing that these guided retrievals are way better than just random or zero-shot prompting <ref:2611.31993#pg2>.

Elias: For example, cluster-guided retrieval achieved a pass at three percentage for Qwen three point eight with seventy-four point eight percent success rate under those conditions. That suggests the organization of the repair knowledge base is key to guiding the AI effectively, not just its raw power alone.

Conclusion: Nadia: So, to wrap up, they conclude that security requirements can serve as a common basis for organizing all this repair knowledge and applying it to new vulnerabilities. They map violated requirements to candidate repair strategies while letting the target code context determine which strategy is actually applicable.

Elias: The impact-pattern map connects those violated requirements with the possible fix strategies, and then the target code's context tells you which of those strategies makes sense for that specific bug.

Priya: From my side, it sounds like this framework moves us toward a workflow where we have diagnosis, retrieval of relevant fix examples based on these patterns, generation, and then validation to prevent exploitation while keeping the intended functionality intact.

Nadia: That’s the big picture—a repair workflow that uses security requirements to connect all those pieces together. The paper aims to establish this empirical foundation for further research on integrating repair knowledge with LLM patch generation.

Elias: And they pointed out that the analysis of the generated plans even shows that using these relevant examples helps models improve problem identification and makes the repair plan more complete.

Priya: It’s promising, but they did flag some gaps, specifically that while this helps with certain repairs, there are still harder repairs where retrieving and applying this fix-pattern and security-impact knowledge needs to be even more refined to prevent exploitation.

Nadia: So the next step is testing whether pairing vulnerable code with these examples during post-training helps models recognize when the same protection is needed in a different place.

Elias: That moves us toward a broader goal of having a repair workflow where security requirements connect diagnosis, retrieval of relevant fix examples, generation, and validation. That’s what this paper sets up for the next round of work.

Zichen Liu, Liangyi Huang, Stanley Nguyen, Kha Tu Nguyen, Xinda Wang, Xusheng Xiao

Arizona State University · The University of Texas at Dallas

cs.CR, cs.SE

Submitted: 2026-11-24

Updated: 2026-11-24

License: http://creativecommons.org/licenses/by/4.0/

Importance score: 87/100

The gist: 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…

Key concepts

Fix Patterns
These are recurring sequences of code changes found across many security patches. Researchers identified these patterns by examining how different edits combine to protect specific operations. A fix pattern captures what data or operation is affected, the condition required for the fix, and the exact changes needed to establish that protection.
Security Impact Classes
The paper defines 12 distinct categories of security impact based on which security requirements vulnerable code violates. These classes are derived from studying areas like concurrency and input interpretation. This taxonomy helps categorize individual violations and the chains of related security issues a vulnerability might present.
Impact-Pattern Map
This is a crucial knowledge structure connecting the identified fix patterns with the defined security impact classes. It links specific violated requirements to candidate repair strategies. The context of the target code then determines which strategy from this map is actually applicable for fixing that specific vulnerability.

Terminology

Summary

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. p. 0

Where the paper says it

edu 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.

<ref:2611.31993#pg1,passing functionality tests does not ensure that a patch enforces the security requirement the vulnerability violated>. p. 0
Where the paper says it

edu 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.

This paper presents a large-scale empirical study relating recurring fix patterns to the security impacts of vulnerabilities and examines how this knowledge can guide LLM-based repair. p. 0
Where the paper says it

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.

<ref:2611.31993#pg1,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>. p. 0
Where the paper says it

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.

Characterizing and Mining Fix Patterns

The study begins by manually studying security patches to derive concrete fix patterns from 348 open-source repositories.<ref:2611.31993#pg4>. This process involves examining fix actions in 300 ARVO patch diffs to find recurring actions. p. 1

Where the paper says it

Part I: Characterizing and mining fix patterns. We begin by examining the fix actions in 300 security patches and find recurring actions and combinations.

<ref:2611.31993#pg4,We first examined which code changes recur in security patches and how they combine>. p. 3
Where the paper says it

From Fix Actions to Fix Patterns Manual study of fix actions. We first examined which code changes recur in security patches and how they combine.

From edits to repair mechanisms, the researchers examine the repair relationships established by changes and surrounding code to identify patterns that capture recurring relations between code changes, the operations they protect, and the conditions. p. 3
Where the paper says it

Prior work characterizes recurring edits [32] and combines AST context with edit actions [14]. We examine the repair relationships established by changes and surrounding code.

<ref:2611.31993#pg4,A fix pattern identifies the affected data or operation, its required condition, and the changes that establish it>. p. 3
Where the paper says it

We examine the repair relationships established by changes and surrounding code. A fix pattern identifies the affected data or operation, its required condition, and the changes that establish it, such as checking that enough input remains before a read.

Where Security Impacts are Defined

The paper defines security impact through security requirements that vulnerable code violates.<ref:2611.31993#pg2>. They define 12 security impact classes based on violated security requirements, drawing on studies of concurrency, algorithmic complexity, input interpretation and certificate validation. p. 2

Where the paper says it

Existing impact-aware studies often focus on selected vulnerability types, leaving the broader spectrum of security impacts incompletely characterized [20], [21]. We define a more comprehensive taxonomy of 12 security impact classes based on violated security requirements, drawing on studies of concurrency, algorithmic complexity, input interpretation and certificate validation, together with cryptographic specifications [27], [28], [29], [30], [31].

<ref:2611.31993#pg7>. The taxonomy captures individual violations and directed chains. p. 2
Where the paper says it

We label vulnerability descriptions separately from the code-based characterization of repairs (Section 4). The taxonomy captures individual violations and directed chains.

<ref:2611.31993#pg8>.

How Fix Patterns Guide Repair Choices

The core contribution is relating these patterns to security impacts to select repair examples for four LLMs on repair tasks of varying complexity.<ref:2611.31993#pg1,We then use these patterns and impact–pattern associations to select repair examples for four LLMs on repair tasks of varying complexity>. p. 0

Where the paper says it

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.

The study shows that choosing appropriate fix examples substantially improves LLM patch generation. p. 2
Where the paper says it

We compare both methods with Zero-shot, Random and an Oracle based on reviewed mechanism matches, evaluating repair success and plan quality on 291 targets stratified by edit complexity. Our evaluation results show that choosing appropriate fix examples substantially improves LLM patch generation: Cluster-guided and Impact-guided retrieval raise fourmodel mean pass@3 from 37.

<ref:2611.31993#pg7>. This demonstrates that relevant examples supply vulnerability-specific repair knowledge that these models do not reliably recover from the target code alone. p. 2
Where the paper says it

6% under the same method. These gains suggest that relevant examples supply vulnerabilityspecific repair knowledge that these models do not reliably recover from the target code alone, helping them identify the violated requirement and an applicable repair strategy.

<ref:2611.31993#pg7>.

Evaluation of Retrieval Methods

The evaluation compares guided retrieval with Zero-shot, Random and Oracle conditions across models and edit complexities.<ref:2611.31993#pg7>. The findings show that Cluster-guided and Impact-guided retrieval improve repair even for a frontier model. p. 9

Where the paper says it

We generate three candidates per example group and count the group as successful if any candidate passes (pass@3). Repair Effectiveness Finding 4: Cluster-guided and Impact-guided retrieval improve repair even for a frontier model, with the largest gains for models with lower baseline repair rates.

<ref:2611.31993#pg7>. For example, Cluster-guided retrieval yields 74. p. 2
Where the paper says it

Relative to Random, Cluster-guided retrieval improves their pass@3 by 42. 3%, respectively, while Impactguided retrieval yields improvements of 39.

8% pass@3 for Qwen3. p. 2
Where the paper says it

Relevant examples also enable some open-weight models to match or exceed GPT-6 Luna’s observed repair rate on easy targets: Cluster-guided retrieval yields 74. 8% pass@3 for Qwen3.

8-27B.<ref:2611.31993#pg10>.

Conclusion on Knowledge Organization

The study concludes that security requirements can serve as a common basis for organizing repair knowledge and applying it to new vulnerabilities.<ref:2611.31993#pg7>. The impact–pattern map connects violated requirements with candidate repair strategies, while the target’s code context determines their applicability. p. 1

Where the paper says it

We describe a vulnerability’s security impact through the security requirements its code violates, such as memory bounds or the validity of a reference. Relating impacts to patterns connects what a repair must restore with how code changes restore it, while the target’s context determines which strategy applies.

<ref:2611.31993#pg7>. Relevant examples help models diagnose the defect. p. 2
Where the paper says it

Analysis of the generated plans further shows that relevant examples improve problem identification and repairplan completeness, helping explain their benefit to patch generation. Using the generator’s own hypothetical fix as the retrieval query retains part of the improvement, suggesting that this knowledge can also help when the developer fix is unavailable.

<ref:2611.31993#pg7>. The remaining gaps on harder repairs motivate further research on retrieving and applying fix-pattern and security-impact knowledge to prevent exploitation while preserving intended functionality. p. 2
Where the paper says it

Improvements nevertheless narrow on harder targets, where reviewed pattern matches retain a larger advantage, motivating further work on retrieving and applying suitable repair strategies. By characterizing this knowledge and examining its use in patch generation, our study aims to inspire further research on integrating fix patterns and security impacts with LLMs for more effective vulnerability repair.

<ref:2611.31993#pg7>.

Future Directions

Future work could test whether pairing vulnerable code with such examples during post-training helps models recognize when the same protection is needed elsewhere.<ref:2611.31993#pg7>. These directions converge on a broader goal: a repair workflow in which security requirements connect diagnosis, retrieval of relevant fix examples, generation and validation. p. 1

Where the paper says it

Security patches manual action study Change representation embeddings / AST edits Clustering Source inspection changes and context Concrete fix patterns Vulnerability descriptions Impact taxonomy violated requirements LLM impact labeling Impact–pattern relations Repair knowledge base examples + relations Vulnerable code fix-based query Relevant fix examples guided retrieval Augmented LLM repair examples → plan → code Patch assessment success + plan quality Repair effectiveness models / edit complexity fix patterns and code context patch clusters retrieve relevant fix examples from the knowledge base Part I: Characterizing and mining fix patterns (§3) Part II: Security impacts and their association with fix patterns (§4, §5) Part III: Retrieval-augmented vulnerability patch generation (§6) Figure 1. Study overview: careful inspection and clustering of security patches reveal fix patterns.

<ref:2611.31993#pg7>. The paper aims to establish an empirical foundation for further research on integrating repair knowledge with LLM patch generation. p. 1
Where the paper says it

We therefore conduct a large-scale study to develop an in-depth understanding of fix patterns, their associations with security impacts, and how this knowledge can improve LLMs’ vulnerability patch generation. The study aims to establish an empirical foundation for further research on integrating repair knowledge with LLM patch generation.

<ref:2611.31993#pg2,The study aims to establish an empirical foundation for further research on integrating repair knowledge with LLM patch generation>. p. 1
Where the paper says it

We therefore conduct a large-scale study to develop an in-depth understanding of fix patterns, their associations with security impacts, and how this knowledge can improve LLMs’ vulnerability patch generation. The study aims to establish an empirical foundation for further research on integrating repair knowledge with LLM patch generation.

p. 1
Where the paper says it

We therefore conduct a large-scale study to develop an in-depth understanding of fix patterns, their associations with security impacts, and how this knowledge can improve LLMs’ vulnerability patch generation. The study aims to establish an empirical foundation for further research on integrating repair knowledge with LLM patch generation.

The analysis of the generated plans further shows that relevant examples improve problem identification and repair plan completeness. p. 2
Where the paper says it

These results highlight the need to retrieve fix examples whose repair strategies apply to the target vulnerability, so that generation draws on relevant knowledge from the repair knowledge base. Analysis of the generated plans further shows that relevant examples improve problem identification and repairplan completeness, helping explain their benefit to patch generation.

<ref:2611.31993#pg7>.

Related Work

The paper reviews existing work on mining fix patterns, patch representations and analysis units, security impact characterization, and knowledge-guided vulnerability repair.<ref:2611.31993#pg8>. This includes work on FixMiner [14], Getafix [15], TreeCen [36], GraphCodeBERT [58], and VulKey [22]. p. 4

Where the paper says it

Both structural baselines use GumTree edits between paired functions [35]. Diff-AST Centrality describes the edit graph using node-centrality features, adapting TreeCen’s structural-summary approach [36], with a fixed function-level scaler to standardize its features.

<ref:2611.31993#pg8,This includes work on FixMiner [14], Getafix [15], TreeCen [36], GraphCodeBERT [58], and VulKey [22]>. p. 4
Where the paper says it

Both structural baselines use GumTree edits between paired functions [35]. Diff-AST Centrality describes the edit graph using node-centrality features, adapting TreeCen’s structural-summary approach [36], with a fixed function-level scaler to standardize its features.

The study connects patch clusters with measured impact–pattern associations and evaluates how the resulting fix examples help LLMs understand and repair new vulnerabilities. p. 1
Where the paper says it

Without this account, it remains unclear how fix-pattern and security-impact knowledge can support retrieval-augmented generation by retrieving only fix examples relevant to the target vulnerability from a repair knowledge base. We therefore conduct a large-scale study to develop an in-depth understanding of fix patterns, their associations with security impacts, and how this knowledge can improve LLMs’ vulnerability patch generation.

<ref:2611.31993#pg7>. The paper aims to inspire further research on integrating fix patterns and security impacts with LLMs for more effective vulnerability repair. p. 2
Where the paper says it

Improvements nevertheless narrow on harder targets, where reviewed pattern matches retain a larger advantage, motivating further work on retrieving and applying suitable repair strategies. By characterizing this knowledge and examining its use in patch generation, our study aims to inspire further research on integrating fix patterns and security impacts with LLMs for more effective vulnerability repair.

<ref:2611.31993#pg7>. This paper is 2611. p. 0
Where the paper says it

For example, an early return and a conditional wrapper can both prevent a copy from exceeding its destination capacity. This shared structure motivates mining fix patterns, which capture recurring relations between code changes, the operations they protect, and the conditions arXiv:2611.

31993.<ref:2611.31993#pg8>.

Conclusion

Our large-scale study identifies recurring fix patterns across syntactically different patches and relates them to 12 security impact classes.<ref:2611.31993#pg7>. The resulting map connects violated requirements with candidate repair strategies, while code context determines their applicability. p. 1

Where the paper says it

We describe a vulnerability’s security impact through the security requirements its code violates, such as memory bounds or the validity of a reference. Relating impacts to patterns connects what a repair must restore with how code changes restore it, while the target’s context determines which strategy applies.

<ref:2611.31993#pg7>. The study aims to establish an empirical foundation for further research on integrating repair knowledge with LLM patch generation. p. 1
Where the paper says it

We therefore conduct a large-scale study to develop an in-depth understanding of fix patterns, their associations with security impacts, and how this knowledge can improve LLMs’ vulnerability patch generation. The study aims to establish an empirical foundation for further research on integrating repair knowledge with LLM patch generation.

<ref:2611.31993#pg2,The study aims to establish an empirical foundation for further research on integrating repair knowledge with LLM patch generation>. The remaining gaps on harder repairs motivate further research on retrieving and applying fix-pattern and securityimpact knowledge to prevent exploitation while preserving intended functionality. p. 2
Where the paper says it

Improvements nevertheless narrow on harder targets, where reviewed pattern matches retain a larger advantage, motivating further work on retrieving and applying suitable repair strategies. By characterizing this knowledge and examining its use in patch generation, our study aims to inspire further research on integrating fix patterns and security impacts with LLMs for more effective vulnerability repair.

<ref:2611.31993#pg7>. The paper is 2611. p. 0
Where the paper says it

For example, an early return and a conditional wrapper can both prevent a copy from exceeding its destination capacity. This shared structure motivates mining fix patterns, which capture recurring relations between code changes, the operations they protect, and the conditions arXiv:2611.

31993.<ref:2611.31993#pg8>.

References

The references listed support the claims made throughout the study. The references are extensive and cover various aspects of software engineering and security research. p. 0

Where the paper says it

Despite these gains in functional-bug repair, where LLMs reason about functional requirements and code structure with feedback from tests, generating effective vulnerability patches remains challenging. Security requirements additionally constrain behavior under adversarial inputs and execution conditions that functional tests often do not cover [9].

The paper cites numerous prior works in pattern mining, code representation, and vulnerability analysis. p. 1
Where the paper says it

Security patches manual action study Change representation embeddings / AST edits Clustering Source inspection changes and context Concrete fix patterns Vulnerability descriptions Impact taxonomy violated requirements LLM impact labeling Impact–pattern relations Repair knowledge base examples + relations Vulnerable code fix-based query Relevant fix examples guided retrieval Augmented LLM repair examples → plan → code Patch assessment success + plan quality Repair effectiveness models / edit complexity fix patterns and code context patch clusters retrieve relevant fix examples from the knowledge base Part I: Characterizing and mining fix patterns (§3) Part II: Security impacts and their association with fix patterns (§4, §5) Part III: Retrieval-augmented vulnerability patch generation (§6) Figure 1. Study overview: careful inspection and clustering of security patches reveal fix patterns.

The references are listed at the end of the document. p. 8
Where the paper says it

The watchdog’s CR cluster contains 11 patches from seven repositories, and all ten labeled members are memorybounds. The same > to >= edit rejects a one-past-end index in FreeRDP and radare2 but selects a valid boundary entry in the watchdog (Table 7).

Green — the paper says it, and the page is printed. Red — no passage carries it, so treat that sentence as unverified. The same check runs on your own text: check a summary against its source, $5.

Improvements for AI systems

  1. Improve LLM patch generation by using fix patterns to guide example selection, as 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%.

  2. Implement a retrieval-augmented generation workflow that uses patch clusters and impact–pattern associations to retrieve relevant fix examples, allowing the LLM to identify the unsafe operation and repair the vulnerability by providing relevant examples that share a necessary repair element.

  3. Develop a system where security requirements guide repair choices by connecting them to candidate strategies, ensuring that Security impacts guide repair choices, while code context determines the applicable pattern.

  4. Enhance model performance on open-weight LLMs by leveraging relevant examples, as retrieval methods can help open-weight models close the performance gap on specific difficulty levels.

  5. Refine repair planning by using retrieved fix examples to improve both problem identification and plan completeness, as relevant examples help models recognize what needs fixing.

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.

Sources

Related papers