[Paper Review] Evaluating Large Language Models for Line-Level Vulnerability Localization
This paper presents the first comprehensive evaluation of large language models (LLMs) for line-level vulnerability localization across C/C++ and smart contract code. It compares prompting, discriminative fine-tuning, and generative fine-tuning with LoRA across 19 LLMs, finding that fine-tuning significantly outperforms prompting in high-data settings, while prompting excels in low-data scenarios; context expansion strategies like sliding windows and right-forward embedding improve performance, and models show transferability across CWEs and projects, though performance drops on novel vulnerability patterns.
Recently, Automated Vulnerability Localization (AVL) has attracted growing attention, aiming to facilitate diagnosis by pinpointing the specific lines of code responsible for vulnerabilities. Large Language Models (LLMs) have shown potential in various domains, yet their effectiveness in line-level vulnerability localization remains underexplored. In this work, we present the first comprehensive empirical evaluation of LLMs for AVL. Our study examines 19 leading LLMs suitable for code analysis, including ChatGPT and multiple open-source models, spanning encoder-only, encoder-decoder, and decoder-only architectures, with model sizes from 60M to 70B parameters. We evaluate three paradigms including few-shot prompting, discriminative fine-tuning, and generative fine-tuning with and without Low-Rank Adaptation (LoRA), on both a BigVul-derived dataset for C/C++ and a smart contract vulnerability dataset.} Our results show that discriminative fine-tuning achieves substantial performance gains over existing learning-based AVL methods when sufficient training data is available. In low-data settings, prompting advanced LLMs such as ChatGPT proves more effective. We also identify challenges related to input length and unidirectional context during fine-tuning, and propose two remedial strategies: a sliding window approach and right-forward embedding, both of which yield significant improvements. Moreover, we provide the first assessment of LLM generalizability in AVL, showing that certain models can transfer effectively across Common Weakness Enumerations (CWEs) and projects. However, performance degrades notably for newly discovered vulnerabilities containing unfamiliar lexical or structural patterns, underscoring the need for continual adaptation.
Motivation & Objective
- To evaluate the effectiveness of large language models (LLMs) in line-level vulnerability localization (AVL), a critical task for accelerating software vulnerability diagnosis.
- To compare different LLM paradigms—few-shot prompting, discriminative fine-tuning, and generative fine-tuning with LoRA—across diverse model architectures and sizes.
- To investigate the generalizability of LLMs across different Common Weakness Enumerations (CWEs) and software projects.
- To identify and address challenges in LLM fine-tuning for AVL, particularly input length and unidirectional context limitations.
- To provide practical guidance for deploying LLM-based AVL systems in real-world software security workflows.
Proposed method
- Evaluated 19 state-of-the-art LLMs, including commercial (e.g., ChatGPT, GPT-4o) and open-source models (e.g., CodeLlama), across encoder-only, encoder-decoder, and decoder-only architectures with sizes from 60M to 70B parameters.
- Applied three paradigms: few-shot prompting (zero-shot and few-shot), discriminative fine-tuning, and generative fine-tuning with and without Low-Rank Adaptation (LoRA).
- Used two datasets: BV-LOC (10,811 C/C++ functions from BigVul) and SC-LOC (1,369 Solidity functions from recent smart contract audits), plus BV-LOC-LF for temporal generalization.
- Proposed two context expansion strategies: a sliding window approach and right-forward embedding to mitigate unidirectional context limitations during fine-tuning.
- Conducted extensive ablation studies and comparisons against strong baselines like VELVET and LineVul to validate performance gains.
- Assessed model generalizability across CWEs and projects, and evaluated performance on newly discovered vulnerabilities with unfamiliar patterns.
Experimental results
Research questions
- RQ1How do different LLM paradigms—prompting, discriminative fine-tuning, and generative fine-tuning—perform in line-level vulnerability localization across diverse model architectures and data scales?
- RQ2What is the impact of model size, architecture type (encoder-only, encoder-decoder, decoder-only), and fine-tuning techniques (with/without LoRA) on AVL performance?
- RQ3To what extent can LLMs generalize across different Common Weakness Enumerations (CWEs) and software projects in vulnerability localization?
- RQ4How do input length and unidirectional context during fine-tuning affect LLM performance, and can context expansion strategies mitigate these limitations?
- RQ5How do LLMs perform on novel vulnerabilities with unfamiliar lexical or structural patterns, and what are the implications for continual adaptation in real-world deployment?
Key findings
- Discriminative fine-tuning achieves substantial performance gains over existing learning-based AVL methods when sufficient training data is available, outperforming prompting and baseline deep learning models.
- In low-data settings, few-shot prompting with advanced LLMs like ChatGPT and GPT-4o achieves competitive recall, outperforming most baseline models in F1-score.
- The proposed sliding window and right-forward embedding strategies significantly improve performance by mitigating the limitations of unidirectional context and long input handling during fine-tuning.
- Fine-tuned LLMs demonstrate strong generalizability across different CWEs and projects, indicating transferability of learned vulnerability patterns.
- Performance degrades notably on newly discovered vulnerabilities with unfamiliar lexical or structural patterns, highlighting the need for continual adaptation mechanisms.
- LoRA and model size are critical factors in optimizing LLMs for AVL, with larger models and LoRA fine-tuning yielding better results, especially in low-data regimes.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.