Skip to main content
QUICK REVIEW

[Paper Review] Code and Dataset for "Examining Zero-Shot Vulnerability Repair with Large Language Models"

Hammond Pearce, Benjamin Tan|arXiv (Cornell University)|Dec 3, 2021
Software Engineering ResearchComputer Science15 citations
TL;DR

This paper evaluates zero-shot vulnerability repair using off-the-shelf large language models (LLMs) like Codex and Jurassic-1 on synthetic, hand-crafted, and real-world security bugs. Despite achieving 100% repair success on synthetic and crafted scenarios, LLMs struggle with functional correctness in real-world examples, highlighting challenges in generating reliable, secure patches without fine-tuning or enhanced prompting strategies.

ABSTRACT

<strong>Code and Dataset for "Examining Zero-Shot Vulnerability Repair with Large Language Models"</strong> The following Zenodo contains the resources associated with the S&amp;P accepted paper ‘Examining Zero Shot Vulnerability Repair with Large Language Models’, https://arxiv.org/abs/2112.02125 In this resource, you can find the following. - 'important_results' directory:<br> This directory is for containing the final raw results as generated by the framework, including a global CSV of all generations and an HTML file containing all of the diffs generated for the 'high-confidence' real-world scenarios.<br> - final_results.csv<br> - This contains the final results of all generated software patches.<br> - Note the nomenclature differences with the manuscript tables. These are explained in the README in the framework.<br> - Original vs LLM-Generated Vulnerability Fixes.html<br> - This contains all of the diffs for the real-world patches versus the canonical developer-provided patches. - 'framework' directory:<br> This directory contains the complete archive of the code framework and all results at the time of the paper’s submission. It contains every language model prompt, suggestions, assembled repair patch and analysis data. It contains every script used for generation and analysis. It is a large archive, and within it contains an included README describing how to understand and use it.<br> - For convenience, we include a copy of the README external to the zipped archive. - 'resources' directory: <br> This directory contains the resources used by our large associated tools, including:<br> - 'gpt2-csrc' subdirectory:<br> Everything to do with the gpt2-csrc model, including the trained files, training scripts, and training data. - 'ExtractFix' subdirectory:<br> A docker image containing all ExtractFix scenarios, even those we did not use. Provided for interest (not required for usage).

Motivation & Objective

  • To assess whether off-the-shelf LLMs can generate secure, functional code patches for vulnerabilities without fine-tuning.
  • To investigate how prompt design—especially contextual cues and comment quality—affects repair quality.
  • To evaluate the feasibility and reliability of LLMs in real-world vulnerability repair scenarios using historical, real-world examples.
  • To identify challenges in generating functionally correct fixes when LLMs are prompted with real-world insecure code.
  • To provide an open-source dataset and evaluation framework to support future research in LLM-based program repair.

Proposed method

  • Evaluated five commercial black-box LLMs (e.g., OpenAI Codex, AI21 Jurassic-1) and two additional models (open-source and fine-tuned) on a diverse set of vulnerability scenarios.
  • Designed prompts with varying levels of contextual information, including comments, function names, and code structure, to assess their impact on repair quality.
  • Generated synthetic and hand-crafted security bugs based on common CWE categories (e.g., buffer overflows, use-after-free) to test LLMs in controlled settings.
  • Collected and evaluated real-world vulnerability examples from public repositories to assess generalization to production code.
  • Used automated testing and manual code review to verify functional correctness and security properties of generated patches.
  • Implemented a custom fine-tuned GPT-2 model (gpt2-csrc) on a curated dataset of secure code to compare zero-shot vs. fine-tuned performance.

Experimental results

Research questions

  • RQ1RQ1: Can off-the-shelf LLMs generate safe and functional code to fix security vulnerabilities in a zero-shot setting?
  • RQ2RQ2: Does varying the amount and quality of contextual information in the prompt affect the LLM’s ability to suggest correct fixes?
  • RQ3RQ3: What are the key challenges when using LLMs to repair real-world vulnerabilities compared to synthetic or crafted examples?
  • RQ4RQ4: How reliable are LLMs at generating functionally correct and secure patches across diverse vulnerability types?

Key findings

  • LLMs achieved 100% repair success on synthetic and hand-crafted vulnerability scenarios, demonstrating strong zero-shot capability in controlled settings.
  • Despite high success rates in synthetic cases, LLMs frequently generated functionally incorrect or insecure patches when applied to real-world historical vulnerability examples.
  • Prompt engineering—especially the inclusion of detailed comments and clear intent—improved repair quality, but did not eliminate functional flaws in real-world cases.
  • The models often introduced new bugs or failed to preserve correct control flow, even when the original vulnerability was simple and localized.
  • Fine-tuned models (e.g., gpt2-csrc) showed improved performance over zero-shot inference, suggesting that fine-tuning on secure code can enhance reliability.
  • The study reveals that while LLMs can understand vulnerability patterns, they lack robustness in generating correct, secure fixes for real-world code without additional safeguards or training.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.