Current vulnerability detection methods based on graph neural networks struggle to effectively model long-range dependencies and deep semantic features in code, whereas approaches leveraging large language models lack explicit structural awareness of programs, resulting in insufficient capabilities for vulnerability localization and interpretability. An explainable vulnerability analysis framework DEPVulDet, that integrates program dependency semantic embedding with decoder-based reasoning, is proposed. A dedicated encoder is employed to capture control and data-flow semantic features from program dependencies, which is then aligned into the semantic space of a large language model of the decoder via a lightweight linear mapping mechanism. The decoder is used to perform vulnerability detection based on the mapped representations, while a chain-of-thought-inspired multi-turn dialogue training strategy is introduced to enhance the model’s logical reasoning and explanatory capability regarding vulnerability locations, contextual dependencies, and root causes. Experimental results show the accuracy of DEPVulDet reaches 69.6% and 95.7% respectively, with its F1-scores standing at 71.5% and 48.1%, exhibiting superior performance over the comparison methods on various evaluation metrics.
首先将自然语言(“Please check the following code for any potential vulnerabilities”)通过解码器的词嵌入层进行编码,得到自然语言嵌入表示。随后,将源代码通过编码模型嵌入并经映射模型转换,得到代码语义嵌入。将二者进行拼接操作,形成解码器的完整输入表示:
算法1展示了如何提取漏洞函数的漏洞线索。首先,分析补丁文件,通过差异分析来确定漏洞行。随后,使用静态分析工具Joern提取目标函数的PDG。在PDG中,从漏洞行节点出发,使用广度优先搜索算法(Breadth First Search, BFS)遍历k跳范围内的关联节点,确定与漏洞相关的数据依赖和控制依赖。最后,从CVE等漏洞数据库中检索专业的漏洞技术解释,形成完整的漏洞线索三元组。
WENX C, CHENY P, GAOC Y, et al. Vulnerability detection with graph simplification and enhanced graph representation learning[C]//Proceedings of 2023 IEEE/ACM 45th International Conference on Software Engineering. Piscataway,USA: IEEE, 2023:2275-2286.
[2]
ZHANGG D, YAOT Y, QINJ W, et al. CodeSAGE: a multi-feature fusion vulnerability detection approach using code attribute graphs and attention mechanisms[J]. Journal of Information Security and Applications, 2025,89:No.103973.
[3]
LIZ, ZOUD Q, XUS H, et al. SySeVR: a framework for using deep learning to detect software vulnerabilities[J]. IEEE Transactions on Dependable and Secure Computing, 2022,19(4):2244-2258.
LEKSSAYSA, MOUHCINEH, TRANK, et al. LLMxCPG:context-aware vulnerability detection through code property graph-guided Large Language Models[DB/OL]. (2025-07-22)[2025-12-08].
[6]
QUANV L A, PHATC T, VAN NGUYENK,et al. XGV-BERT: leveraging contextualized language model and graph neural network for efficient software vulnerability detection[J]. The Journal of Supercomputing, 2025,81(6):No.750.
[7]
WENX C, GAOC Y, GAOS Z, et al. SCALE: constructing structured natural language comment trees for software vulnerability detection[C]//Proceedings of the 33rd ACM SIGSOFT International Symposium on Software Testing and Analysis. New York, USA: ACM, 2024:235-247.
[8]
LUG L, JUX L, CHENX, et al. GRACE: empowering LLM-based software vulnerability detection with graph structure and in-context learning[J]. Journal of Systems and Software, 2024,212:No.112031.
[9]
JIANGZ H, SUNW F, GUX Y, et al. DFEPT: data flow embedding for enhancing pre-trained model based vulnerability detection[DB/OL]. (2024-10-24)[2025-06-07].
[10]
CAIZ L, CAIY W, CHENX, et al. CSVD-TF: cross-project software vulnerability detection with TrAdaBoost by fusing expert metrics and semantic metrics[J]. Journal of Systems and Software, 2024,213:No.112038.
[11]
VASILAKISN, BENETOPOULOSA, HANDAS, et al. Supply-chain vulnerability elimination via active learning and regeneration[C]//Proceedings of the 2021 ACM SIGSAC Conference on Computer and Communications Security. New York, USA: ACM, 2021:1755-1770.
[12]
DEVLINJ, CHANGM W, LEEK, et al. Bert: pre-training of deep bidirectional transformers for language understanding[DB/OL].(2018-10-11 2025-07-07].
[13]
GUOD Y, RENS, LUS, et al. GraphCodeBERT: pre-training code representations with data flow[DB/OL]. (2020-09-17)[2025-12-10].
[14]
DETTMERST, PAGNONIA, HOLTZMANA, et al. QLoRA: efficient finetuning of quantized LLMs[C]//Proceedings of Advances in Neural Information Processing Systems. New York, USA:Curran Associates, Inc.,2026,36:10088--10115.
[15]
HUE J, SHENY L, WALLISP, et al. LoRA: low-rank adaptation of large language models[DB/OL]. (2021-06-17)[2025-07-07].
[16]
LIUB C, CHENC Y, GONGZ, et al. MFTCoder: boosting code LLMs with multitask fine-tuning [DB/OL].(2024-08-24)[2025-12-08].
[17]
FANJ H, LIY, WANGS H,et al. A C/C++ code vulnerability dataset with code changes and CVE summaries [C]//Proceedings of the 17th International Conference on Mining Software Repositories. New York, USA:ACM,2020. DOI:10.1145/3379597.3387501 .
[18]
ZHOUY Q, LIUS Q, SIOWJ K, et al. Devign: effective vulnerability identification by learning comprehensive program semantics via graph neural networks [C]//Proceedings of the 33rd International Conference on Neural Information Processing Systems. Red Hook, USA: Curran Associates Inc., 2019:No.915.
[19]
KIMY. Convolutional neural networks for sentence classification [C]//Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing. Stroudsburg, USA: ACL, 2014. DOI:10.3115/v1/D14-1181 .
[20]
LIUZ X, TANGZ J, ZHANGJ W, et al. Pre-training by predicting program dependencies for vulnerability analysis tasks[C]//Proceedings of the IEEE/ACM 46th International Conference on Software Engineering. New York,USA: ACM, 2024:1863-1875.
[21]
WANGY, WANGW S, JOTYS, et al. CodeT5: identifier-aware unified pre-trained encoder-decoder models for code understanding and generation[C]//Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing. Stroudsburg, USA: ACL, 2021:8696-8708.
[22]
ROZIÈREB, GEHRINGJ, GLOECKLEF, et al. Code Llama: open foundation models for code[DB/OL].(2023-08-24)[2025-12-08].