arXiv:2608.27928cs.CRAug 2026

Manuscript Offprint

arXiv:2608.27928

GraftyVul: Synthesising Insecure Programs Through Real-World Vulnerability Grafting

Omri Ram, Mitchell Horner, Ron Van der Meyden, Alsharif Abuadbba, Hammond Pearce

Omri Ram*†, Mitchell Horner*†, Ron Van der Meyden*, Alsharif Abuadbba‡, Hammond Pearce*

  • University of New South Wales, Australia

† Nullify, Australia

‡^{\ddagger} CSIRO, Australia

{o.ram, mitch.horner, r.vandermeyden, hammond.pearce}@unsw.edu.au, sharif.abuadbba@csiro.au

Abstract—Vulnerability datasets underpin a wide range of security research, including vulnerability detection, automated remediation, and secure code generation. However, existing datasets sacrifice at least one of three desirable properties: diversity (of language or vulnerability type), reproducibility/executability, or realism. We therefore present GraftyVul, a system that constructs vulnerable programs by grafting real-world vulnerabilities into open-source projects. This grounds the dataset in vulnerabilities observed in real-world contexts while harnessing known good build and test environments, enabling exploit-verification scripts to guarantee that an introduced vulnerability successfully alters a program's behaviour. Using GraftyVul, we generate 212 verified and exploitable vulnerable programs spanning five programming languages (Python, TypeScript, Java, Go, and C#) across 23 CWE categories. To evaluate fidelity, we introduce a language- and context-agnostic semantic embedding that compares vulnerabilities by sink, mechanism and host-feature rather than surface code. This approach outperforms standard code embeddings on cross-language clone and CWE classification. These embeddings demonstrate that GraftyVul samples retain a strong semantic signature to their source vulnerability. We additionally compare GraftyVul against 13 widely used datasets, where it attains competitive diversity while being the only reproducible-exploit dataset with broad language and CWE coverage. Finally, we illustrate GraftyVul's practical utility through an industrial case study evaluating a production vulnerability remediation system.

Index Terms—vulnerability datasets, large language models, LLM agents, vulnerability injection, semantic similarity, code clone detection, software security, benchmarking

I. INTRODUCTION

The growing complexity and ubiquity of software in daily life amplifies the risks associated with cybersecurity breaches [1]. Much of cybersecurity research depends on high quality datasets for benchmarking, building models, and improving detection and remediation tools [2]–[4]. The breadth and quality of these datasets limits the research they enable. Vulnerability datasets often support few languages [5], [6], do not contain a mechanism to trigger the vulnerability, known as a proof-of-concept (PoC) exploit [7]–[9], or are limited to a narrow range of vulnerabilities [10], [11].

Synthesising vulnerabilities provides an avenue for curating high quality reproducible benchmarks. Existing methods for synthesising vulnerability data fall into three main categories. Mutation approaches transform secure code by applying known vulnerability patterns [12]–[14]. Injection approaches insert vulnerabilities into existing programs [11], [15], while pure synthesis approaches generate vulnerable code entirely from scratch [16], [17]. These approaches span mutation, injection, and pure synthesis, and divide methodologically into rule-based and learning-based techniques. More recently, LLM-based methods have leveraged the reasoning capabilities of large language models to synthesise vulnerability data [16], [18], [19], using agentic workflows that decompose complex tasks and iteratively refine outputs through self-verification. Despite their differences, many of these approaches all create vulnerabilities in artificial, templated, or otherwise synthetic code, rather than in the real software where vulnerabilities naturally arise. Additionally, they might not have sufficiently robust vulnerability verification tests – giving rise to a lower quality dataset. Consequently, the resulting samples may lack the verifiability and complexity of vulnerabilities encountered in practice.

In this work, we are likewise interested in creating synthetic vulnerabilities using an agentic paradigm. However, rather than generating vulnerabilities from patterns, templates, or from scratch, our approach grafts real-world vulnerabilities sourced from an industry partner (Nullify) into pre-sourced and curated open-source projects. Nullify, a commercial security vendor, obtains these vulnerabilities by scanning its clients' software.

We employ pre-existing agentic infrastructure to characterise the identified vulnerabilities before feeding them into GraftyVul. This system grafts the vulnerability into a functional target program rather than synthesising it in isolation. By using high-quality target environments which have pre-existing tests and verifiers, GraftyVul can ensure that original target functionality remains intact and that build scripts can still compile and execute the program after the vulnerability is inserted. Then, our exploit verification script ensures that the vulnerability is inserted correctly by providing a “PoC” which can retrieve or modify a seeded secret through the injected vulnerability.

To measure the relationship between the newly synthesised vulnerability sample and the original real-world vulnerability, we can adopt code clone detection methods that demonstrate the semantic fidelity between the grafted and source vulnerabilities. However, existing methods for semantic code clones do not provide a sufficiently broad definition for detecting vulnerable code clones across contexts. Vulnerable code clone tools may employ graphs to characterise the vulnerability, which rely heavily on syntax and similar business logic, which does not translate well into cross-context scenarios [20]. Additional methods employ embeddings [21] which do not necessarily capture the fine grained characteristics our vulnerability grafts exhibit. Thus, we produce alternative semantic embeddings for demonstrating the semantic signature preserved in the synthesised samples when compared to the original vulnerability. We employ this metric to determine the intra-vulnerability similarity to determine if we are creating a diverse dataset; and likewise can compare this diversity against other existing benchmarks. Finally, we demonstrate GraftyVul's utility in evaluating Nullify's deployed LLM-driven autofix tool employed for vulnerability remediation.

In summary, we provide the following contributions:

• GraftyVul, an LLM-driven system that synthesises vulnerabilities analogous to real-world industry findings, each accompanied by a verified exploit. [GraftyVul will be made open-source upon publication.]

• A semantic similarity embedding approach that characterises a vulnerability sample in a language- and context-agnostic way.

• A comparison of GraftyVul against 13 other widely used vulnerability datasets across the properties relevant to security research and their diversity.

• A case study demonstrating the utility of GraftyVul's synthesised samples in production.

We find that GraftyVul maintains a strong semantic signature to the original industry vulnerability using the developed semantic similarity embedding, achieving 16% recall@1 against a 0.47% random baseline, while human evaluators can map the synthesised vulnerability to its source finding with an accuracy of 59.5%, approximately six times chance. Additionally, we utilize the Vendi score [22] on GraftyVul's semantic embedding to derive a score of 102 compared to a median of 109.2, more diverse than all but one reproducible dataset while being the only reproducible dataset with broad Common Weakness Enumeration (CWE) and language coverage across 13 other widely used vulnerability datasets, additionally providing executable tests and a verified PoC for each sample. Through benchmarking Nullify's deployed autofix tool on GraftyVul samples we identify recurring and actionable failure modes, including fixes that are secure but break legitimate functionality, and fixes that close the reported weakness but leave the underlying exposure intact.

References (41)