Skip to main navigation Skip to search Skip to main content

Detecting Code Vulnerabilities using LLMs

Research output: Chapter in Book/Conference paperConference paperpeer-review

Abstract

Large language models (LLMs) have emerged as a promising tool for detecting code vulnerabilities, potentially offering advantages over traditional rule-based methods. This paper proposes an enhanced framework for vulnerability detection using LLMs, incorporating various prompt engineering strategies to improve performance. We evaluate several techniques, including role-based prompting, zero-shot chain-of-Thought, and structured prompting approaches, on the DiverseVul dataset of C/C++ vulnerabilities. Our experiments assess the framework's performance across different code structures, contextual information levels, and LLM capabilities. Our results show that using our dynamic prompt engineering technique, you can improve the F1 score by up to 100% with GPT-3.5, a widely used LLM model. We also observe that GPT-4o, Gemini 2.0 Flash, and Meta Llama 3.1 generally outperform GPT-3.5, and all models are very poor when it comes to correctly identifying the type of vulnerability in the code, with the best F1 score of 0.16 observed. However, our follow-up experiments on LLM-based vulnerability correction (i.e., patching) show a 45.77% success rate using GPT-4o, demonstrating promising results in leveraging LLMs for enhancing software security and providing insights into optimizing prompt engineering for vulnerability detection tasks.

Original languageEnglish
Title of host publicationProceedings - 2025 55th Annual IEEE/IFIP International Conference on Dependable Systems and Networks, DSN 2025
EditorsMarcello Cinque, Domenico Cotroneo, Luigi De Simone, Matthias Eckhart, Patrick P. C. Lee, Saman Zonouz
Place of PublicationUSA
PublisherIEEE, Institute of Electrical and Electronics Engineers
Pages401-414
Number of pages14
ISBN (Electronic)9798331512019
DOIs
Publication statusPublished - 2025
Event55th Annual IEEE/IFIP International Conference on Dependable Systems and Networks, DSN 2025 - Naples, Italy
Duration: 23 Jun 202526 Jun 2025

Publication series

NameProceedings - 2025 55th Annual IEEE/IFIP International Conference on Dependable Systems and Networks, DSN 2025

Conference

Conference55th Annual IEEE/IFIP International Conference on Dependable Systems and Networks, DSN 2025
Country/TerritoryItaly
CityNaples
Period23/06/2526/06/25

Fingerprint

Dive into the research topics of 'Detecting Code Vulnerabilities using LLMs'. Together they form a unique fingerprint.

Cite this