用图神经网络提升C++漏洞检测准确率并解释原因
Explainable Vulnerability Detection in C/C++ Using Edge-Aware Graph Attention Networks
- 构建代码属性图,用双通道嵌入捕捉语义与结构信息
- 在ReVeal数据集上达88.25%准确率、48.23%F1值,优于前人方法
- 可定位关键代码区域,让漏洞判断过程透明可信
检测源码中的安全漏洞仍具挑战,尤其因真实数据集中漏洞函数样本稀少导致类别不平衡。现有学习方法多追求召回率,造成误报率高,难以融入开发流程;且多数缺乏可解释性。本文提出ExplainVulD,一种基于图的C/C++漏洞检测框架。该方法构建代码属性图,使用双通道嵌入表示节点,融合语义与结构信息,并通过考虑边类型嵌入的边缘感知注意力机制区分程序关系。为缓解类别不平衡,采用类别加权交叉熵损失训练。在ReVeal数据集上,30次独立运行平均准确率达88.25%,F1得分为48.23%,相较先前的ReVeal模型分别提升4.6%和16.9%。该框架还优于静态分析工具,在准确率上相对提升14.0~14.1%,F1得分提升132.2~201.2%。此外,ExplainVulD能识别每函数中最具影响力的代码区域,支持安全审查的透明性与可信度。
原文摘要 · Abstract (English)
Detecting security vulnerabilities in source code remains challenging, particularly due to class imbalance in real-world datasets where vulnerable functions are under-represented. Existing learning-based methods often optimise for recall, leading to high false positive rates and reduced usability in development workflows. Furthermore, many approaches lack explainability, limiting their integration into security workflows. This paper presents ExplainVulD, a graph-based framework for vulnerability detection in C/C++ code. The method constructs Code Property Graphs and represents nodes using dual-channel embeddings that capture both semantic and structural information. These are processed by an edge-aware attention mechanism that incorporates edge-type embeddings to distinguish among program relations. To address class imbalance, the model is trained using class-weighted cross-entropy loss. ExplainVulD achieves a mean accuracy of 88.25 percent and an F1 score of 48.23 percent across 30 independent runs on the ReVeal dataset. These results represent relative improvements of 4.6 percent in accuracy and 16.9 percent in F1 score compared to the ReVeal model, a prior learning-based method. The framework also outperforms static analysis tools, with relative gains of 14.0 to 14.1 percent in accuracy and 132.2 to 201.2 percent in F1 score. Beyond improved detection performance, ExplainVulD produces explainable outputs by identifying the most influential code regions within each function, supporting transparency and trust in security triage.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。