
Structured Security Explanations for Learning-Based Vulnerability Detection
VulnLens is a framework for binary C/C++ function-level vulnerability detection. A label-blind LLM Explainer describes each function from seven fixed perspectives (data flow, memory access, object lifetime, arithmetic and type behavior, control flow, shared state, external-resource access). A supervised Detector fuses code and explanations by cross-attention. It reaches 75.5% accuracy and 77.2% F1 on a 526-function PrimeVul test set, and 66.4% accuracy on SecVulEval without retraining.
What it is
VulnLens is a function-level vulnerability detector for C/C++ from Fares Trad, Yizhou Chen, Hung Viet Pham, Zeyu Sun and Gias Uddin (arXiv 2610.37797, 27 October 2026). An LLM first writes structured, label-blind descriptions of what a function does. A separately trained classifier then decides whether the function is vulnerable. The LLM never issues the verdict.
How it works
- Explainer: GPT-5.4 in the main experiment. It gets the function plus non-label metadata such as project and file name. It gets no label and no CWE, and its prompts forbid words like "vulnerable", "safe" and "exploitable". Missing context, such as caller constraints, is recorded as missing rather than guessed.
- Output format: one JSON object per perspective, with scope, relevant inputs and state, grounded observations, program relationships, missing context and a short summary. There is no label or confidence field. Semgrep and Cppcheck output was not fed to the Explainer in the principal run.
- Detector: a frozen DeepSeek-R1-Distill-Qwen-7B encodes the code and the seven explanations. Only the cross-attention, LayerNorm, projection and classification parameters are trained. The explanations are fused into the code representation one at a time through sequential cross-attention.
- Worked example: the QEMU function
i2c_ddc_rx(CVE-2019-3812, CWE-125) readsedid_blob[s->reg]and incrementsreg. GPT-5.4 given only the code called it not vulnerable. The memory-access explanation noted that no visible check boundss->reg, and the Detector flagged it.
Results beyond the summary
- On the 526-function PrimeVul-derived test set (ten CWE categories), VulnLens beats DeepSeek V4 Pro by 4.2 points of accuracy and Gemini 2.5 Pro by 2.2 points of F1. It beats GPT-5.5 by 7.4 points of accuracy and 14.2 points of F1.
- Against a separately trained code-only detector, adding matched explanations raises F1 by 7.3 points.
- On SecVulEval, never used for training or retraining, it reaches 66.4% accuracy and 65.8% F1. That is 7.6 points of accuracy and 20.0 points of F1 above DeepSeek V4 Pro, and 16.6 points of accuracy and 7.8 points of F1 above Gemini 2.5 Pro.
- Two reviewers audited the GPT-5.4 explanations and rated 98.6% on average as fully correct (97.6% and 99.5%).
Preconditions
- Training needs a labeled function-level dataset.
- Each function needs seven LLM calls, one per perspective, at both training and inference time.
- Evaluation covers C/C++ only. The authors say the framework could extend to other languages but do not test it.
Caveats
- Absolute accuracy is 75.5% in-distribution and 66.4% on the transfer set, so errors remain frequent.
- The fetched text stops partway through the fusion section. It does not show the ablations on explanation source, backbone and prompt design, the failure cases, or the cost analysis, and none of these are assessed here.
- The headline gains are measured against direct-LLM baselines and one code-only detector. The text does not show the static-analyzer comparison numbers.
Organisations named here
- PrimeVul
- SecVulEval
- VulnLens
Technologies named here
- DeepSeek V4 Pro
- Gemini 2.5 Pro
- LLM
- C
- C++
- DeepSeek
- Gemini
- PrimeVul
- SecVulEval
- VulnLens
Techniques named here
- Explanation-augmented vulnerability detection
- Sequential cross-attention
Related in AI Security
