Back to search

Universidade de Coimbro

Automated Patch Generation for Software Vulnerabilities Using Large Language Models

Abstract

dc:description.abstract

Large Language Models (LLMs) have advanced the automation of code generation and analysis, offering a potential answer to the backlog of security vulnerabilities in critical software. Their reliability, however, remains in question: syntactic correctness is not semantic correctness and models struggle to repair security flaws without introducing new defects, particularly in memory-unsafe languages such as C and C++. This gap calls for validation that establishes by execution, not by inspection, that a repair closes the vulnerability it targets.In this dissertation we establish a systematic methodology for the generation and validation of security patches, composed of five integrated phases: automated construction of a curated vulnerability dataset, vulnerability reproduction within isolated environments, context-aware patch synthesis using diverse LLM configurations, multi-layered validation combining dynamic Proof-of-Concept (PoC) execution with Static Application Security Testing (SAST) and automated reporting, coupled by an iterative feedback loop that returns validation diagnostics to the generation phase whenever a candidate fails. Because no stage is specialised to a weakness type, a vulnerability enters on the availability of a runnable reproduction artefact and is adjudicated by a differential execution oracle over the observable behaviour of the vulnerable and patched builds, acceptance further requiring that the patch add no static-analysis findings of high or critical severity.The methodology was implemented as an open-source, configuration-driven and project-agnostic pipeline for C/C++ systems software, in which a new project is described by configuration rather than programmed. We evaluated it on three widely deployed projects, GNU C Library (glibc), OpenSSL and tcpdump, across eight LLMs, six of them in three independent repetitions. Of 361 vulnerabilities aggregated, 246 reached reproduction and 178 were confirmed reproducible, verdicts an independent differential oracle scored at a lenient precision of 0.961 and a recall of 0.980. The campaign produced 924 validated patches, 48.5% passing on first validation, 30.5% from over-generation and 21.0% from validator-driven retries. Success proved strongly defect-dependent, from 60.8% of tcpdump’s validated vulnerabilities to 6.7% on OpenSSL, and scaled with model capability, the strongest hosted model repairing at roughly three cents per vulnerability and self-hosted 32-billion-parameter models reaching just under half that yield at no marginal cost. The patches seldom introduced new high-severity weaknesses and no positive evidence was found that these results rest on training-data memorisation.

Author and committee

dc:creator, dc:contributor.*
Author dc:creator
  • Almeida, Tiago Nuno Matos Cabo Lopes de
Advisor dc:contributor.advisor
  • Campos, João Rodrigues de

Subjects

dc:subject × 8

Rights

dc:rights
Statement dc:rights
  • openAccess
Language dc:language.iso
eng

Identifiers

dc:identifier.*
Dc Identifier Tid
204414970

Chain of custody

source
Harvested from
Universidade de Coimbro
Base URL
estudogeral.sib.uc.pt/oai/request
Last updated
2026-11-26
Source record
OAI-PMH GetRecord
citation

Almeida, Tiago Nuno Matos Cabo Lopes de. Automated Patch Generation for Software Vulnerabilities Using Large Language Models. 2026. https://hdl.handle.net/10316/124698