cyberdef-vuln — QLoRA adapter for defensive vulnerability detection (Qwen2.5-7B)
A LoRA adapter (r=16, alpha=32, 4-bit QLoRA / nf4) on Qwen/Qwen2.5-7B-Instruct that classifies
whether a single code snippet is vulnerable. Given one function it emits VERDICT: VULNERABLE or
VERDICT: SAFE (with a CWE name where applicable). It is a classifier of given code for blue-team
triage — never a generator of exploits, and it does not "fix" code.
- Author: Pallav Pokhriyal (ORCID 0009-0001-5356-7663)
- Code, full results, exact recipe, and reproduction: https://github.com/pallav0107/cyberdef-llm
Verified results
Every number is recomputed from recorded per-case eval outputs (an integrity check in the repo rejects any score that disagrees with its recompute, so a hand-edited number cannot pass).
On the curated PrimeVul benchmark the adapter improves the base model's ranking of vulnerable
code: AUROC 0.786 vs base 0.658, with better calibration, and the edge transfers to an unseen
dataset (DiverseVul) across four seeds with non-overlapping base/tuned ranges — learned detection,
not memorisation. On the same logprob-scored harness it leads peer open models of similar size
(Qwen2.5-Coder-7B, Foundation-Sec-8B) and is first on CodeXGLUE Devign. Full tables, seeds, and the
integrity line are in RESULTS.md in the GitHub repo.
Honesty trail: an earlier increment trained on a synthetic corpus did not beat the base model on a recognized benchmark (Devign); that negative result is kept in the repo rather than hidden. Only the real-data PrimeVul adapter published here clears the recognized-benchmark bar.
Intended use and limitations
- Use: assistive, high-confidence triage of whether code may be vulnerable; best used with an abstention threshold — the adapter is calibrated to support "abstain when unsure."
- Not for: autonomous gating, exploit generation, or "fixing" code. It is an assistant, not an authority.
- Dangerous failure mode: a false
SAFEverdict. TreatSAFEas "no vulnerability found by this model," never as a guarantee, and always keep a human reviewer in the loop.
How to use
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base = "Qwen/Qwen2.5-7B-Instruct"
tok = AutoTokenizer.from_pretrained(base)
model = AutoModelForCausalLM.from_pretrained(base, device_map="auto")
model = PeftModel.from_pretrained(model, "pallav0101/cyberdef-vuln-qwen2.5-7b-primevul")
Training
QLoRA (4-bit nf4, r=16, alpha=32) on the PrimeVul train split only, leakage-deduped against the validation/test functions. Base model Qwen2.5-7B-Instruct (Apache-2.0). No model-generated or commercial-API outputs were used as training data. The exact recipe and leakage controls are in the GitHub repository.
License
Adapter: MIT. Base model Qwen2.5-7B-Instruct: Apache-2.0 (used under its terms).
Citation
See CITATION.cff in the repository. Pallav Pokhriyal, "cyberdef-vuln: a QLoRA study of defensive
vulnerability detection with small open models," 2026.