Organizations: School of Computer Science, University of Nottingham, Nottingham, United Kingdom · School of Informatics and Computing, Northern Arizona University, Flagstaff, United States of America · School of Computer Science, University of Nottingham, Ningbo, China
Recent work applies Large Language Models (LLMs) to source-code vulnerability detection, but most evaluations still rely on random train-test splits that ignore time and overestimate real-world performance. In practice, detectors are deployed on evolving code bases and must recognise future vulnerabilities under temporal distribution shift. This paper investigates continual fine-tuning of a decoder-style language model (microsoft/phi-2 with LoRA) on a CVE-linked dataset spanning 2018-2024, organised into bi-monthly windows. We evaluate eight continual learning strategies, including window-only and cumulative training, replay-based baselines and regularisation-based variants. We propose Hybrid Class-Aware Selective Replay (Hybrid-CASR), a confidence-aware replay method for binary vulnerability classification that prioritises uncertain samples while maintaining a balanced ratio of VULNERABLE and FIXED functions in the replay buffer. On bi-monthly forward evaluation Hybrid-CASR achieves a Macro-F1 of 0.667, improving on the window-only baseline (0.651) by 0.016 with statistically significant gains (p=0.026) and stronger backward retention (IBR@1 of 0.741). Hybrid-CASR also reduces training time per window by about 17 percent compared to the baseline, whereas cumulative training delivers only a minor F1 increase (0.661) at a 15.9-fold computational cost. Overall, the results show that selective replay with class balancing offers a practical accuracy-efficiency trade-off for LLM-based temporal vulnerability detection under continuous temporal drift.
Figures & tables
Component
Setting
Component
Setting
Base model
microsoft/phi-2
Learning rate
2×10−4
Classification head
Binary (2 logits)
Weight decay
0
LoRA rank r
16
Training epochs
3
LoRA α
32
Batch size (default)
32
LoRA dropout
0.05
Batch size (granularity)
4
Optimizer
AdamW
Evaluation frequency
Per epoch
Table 1: Training configuration maintained across all experimental conditions.
Figure 1: Distribution of vulnerability disclosures across bi-monthly windows (2018–2024), illustrating volume growth and temporal variability.
Strategy
Mechanism
Memory requirements
Replay-1P
Uniform sampling from previous window (Rebuffi et al., 2017).
Memory buffer storing samples from the immediately previous window.
Replay-3P
Uniform sampling from 3 previous windows (Rebuffi et al., 2017).
Memory buffer storing samples from the last 3 windows.
CASR
Uncertainty-based selective replay (Aljundi et al., 2019).
Memory buffer with prioritised vulnerable samples.
Hybrid-CASR
CASR + class balancing (this work).
Memory buffer with class-balanced sampling across VULNERABLE / FIXED.
LB-CL
Class-weighted loss (Wu et al., 2024).
No extra memory beyond model parameters.
OLoRA
Orthogonality constraints on LoRA updates (Lopez-Paz and Ranzato, 2017; Chaudhry et al., 2019).
LoRA adapter parameters (and small statistics for orthogonal subspace).
Table 2: Continual learning strategies with mechanisms and memory requirements.
Granularity
Windows
Mean F1
Std Dev
IQR
Min F1
Max F1
1-month
82
0.654
0.054
0.075
0.506
0.778
2-month
41
0.651
0.044
0.058
0.539
0.714
3-month
27
0.667
0.033
0.041
0.572
0.714
6-month
13
0.669
0.029
0.032
0.611
0.702
12-month
6
0.669
0.030
0.035
0.604
0.695
Table 3: Temporal granularity impact on vulnerability detection performance. All metrics are computed from forward evaluation on held-out windows.
Figure 2: Forward one-step F1 scores across different temporal granularities (1, 2, 3, 6, 12 months), showing variability and trends over chronological evaluation windows.
Figure 3: Forward F1 comparison across all methods using bi-monthly windows, highlighting differences in performance level and stability over time.
Method
IBR@1
IBR@3
IBR@5
IBR@6
Decay rate
AUC a
Replay-1P
0.791
0.747
0.734
0.729
7.8%
0.750
Hybrid-CASR
0.741
0.726
0.716
0.710
4.2%
0.723
CASR
0.734
0.719
0.707
0.706
3.8%
0.717
LB-CL
0.718
0.703
0.691
0.687
4.3%
0.700
Window-only
0.713
0.701
0.689
0.693
2.8%
0.699
Replay-3P
0.702
0.688
0.676
0.673
4.1%
0.685
Table 5: Knowledge retention measured by Immediate Backward Retention at multiple lags. Decay rate is defined as (IBR@1−IBR@6)/IBR@1 .
Figure 4: Plasticity–stability trade-off, showing the relationship between forward learning capability and performance consistency. Methods in the upper-right region achieve the best balance.
Method
Time (s)
Time (min)
Speedup
GPU (MB)
F1/min
Efficiency
Hybrid-CASR
432
7.2
1.20 ×
19,847
0.093
124%
Window-only
520
8.7
1.00 ×
13,525
0.075
100%
Cumulative
8,291
138.2
0.06 ×
13,525
0.005
6%
Table 6: Resource consumption and efficiency. Metrics are averaged across 41 bi-monthly training windows.
Method
2019_M05–06 F1
Δ F1
2020_M05–06 F1
Δ F1
Window-only
0.539
—
0.548
—
Hybrid-CASR
0.598
+0.059
0.612
+0.064
CASR
0.606
+0.067
0.597
+0.049
Replay-1P
0.584
+0.045
0.588
+0.040
Cumulative
0.585
+0.046
0.574
+0.026
LB-CL
0.557
+0.018
0.561
+0.013
Table 7: Method performance on challenging temporal windows. Values show F1 and improvement over the window-only baseline.
Whether LLMs scoring well on vulnerability benchmarks genuinely reason about security or merely pattern-match on contaminated data remains unresolved. We present CWE-Trace, a framework for LLM vulnerability detection built from 834 manually curated Linux kernel samples spanning 74 CWEs. The framework enforces a strict temporal split (pre-2025 historical set / post-cutoff leakage-free set), preserves context-aware vulnerable--patched pairs, and introduces two diagnostic metrics: the Directional Failure Index (DFI) and Hierarchical Distance and Direction (HDD). We evaluate eight vanilla LLMs and 15 LoRA fine-tuned variants across non-targeted detection, targeted detection, and CWE classification. Our analysis yields two key results. First, data contamination provides no measurable advantage. Function-level analysis shows that 84% of nominally contaminated samples carry no usable memorization signal: vulnerable functions are absent or cross-mapped across datasets, and ~31% of contaminated samples carry CWE misclassification. Second, backbone directional priors dominate fine-tuning. Models exhibit stable, systematic failure modes (DFI ranging from -85.5 to +94.8 pp) that persist from historical to post-cutoff data and resist correction. Fine-tuning shifts the output threshold without changing the decision policy. This is calibration without comprehension: output distributions adapt to training data while the underlying security reasoning remains absent. The weakest backbone at binary detection (DeepSeek-R1) gains the most in coarse CWE classification, revealing that detection and understanding are decoupled capabilities. The best detection score reaches only 52.1% (+2.1 pp above chance); exact CWE ranking remains below 1.3% Top-1 accuracy, confirming that current LLMs lack reliable security reasoning for systems software, regardless of fine-tuning strategy.
Arastoo Zibaeirad, Marco Vieira
University of North Carolina at Charlotte, Charlotte, NC, USA
Automated vulnerability detection is a fundamental task in software security, yet existing learning-based methods still struggle to capture the structural dependencies, domain-specific vulnerability knowledge, and complex program semantics required for accurate detection. Recent Large Language Models (LLMs) have shown strong code understanding ability, but directly prompting them with raw source code often leads to missed vulnerabilities or false alarms, especially when vulnerable and benign functions differ only in subtle semantic details. To address this, we propose VulTriage, a triple-path context augmentation framework for LLM-based vulnerability detection. VulTriage enhances the LLM input through three complementary paths: a Control Path that extracts and verbalizes AST, CFG, and DFG information to expose control and data dependencies; a Knowledge Path that retrieves relevant CWE-derived vulnerability patterns and examples through hybrid dense--sparse retrieval; and a Semantic Path that summarizes the functional behavior of the code before the final judgment. These contexts are integrated into a unified instruction to guide the LLM toward more reliable vulnerability reasoning. Experiments on the PrimeVul pair test set show that VulTriage achieves state-of-the-art performance, outperforming existing deep learning and LLM-based baselines on key pair-wise and classification metrics. Further ablation studies verify the effectiveness of each path, and additional experiments on the Kotlin dataset demonstrate the generalization ability of VulTriage under low-resource and class-imbalanced settings. Our code is available at https://github.com/vinsontang1/VulTriage
Wenxin Tang, Xiang Zhang, Junliang Liu +11
Tsinghua University · Henan University · Dalian Maritime University +8
Large language models are increasingly used for vulnerability detection, yet their reliability under different prompt formulations remains uncharacterized. We present PromptAudit, a controlled evaluation framework that isolates prompt effects by fixing the dataset, decoding, and parsing while varying only the prompting strategy. Using five prompting strategies across five open-weight models on 1,000 CVEs (6,074 code samples spanning 16 programming languages), we evaluate accuracy, recall, abstention, coverage, and effective F1. We find that standard chain-of-thought prompting achieves the strongest overall operational performance, while few-shot prompting provides model-dependent benefits that are most pronounced for prompt-sensitive models. In contrast, adaptive chain-of-thought frequently suppresses recall and self-consistency induces excessive abstention, sharply reducing effective performance. These results show that vulnerability detection behavior is jointly determined by the model and the prompt, and that prompt sensitivity is a first-class system property that must be explicitly characterized in evaluation and deployment.
Steffen J. Camarato, Yahya Hmaiti, Mandana Ghadamian +1
University of Central Florida Orlando, Florida, USA