Skip to main content
QUICK REVIEW

[论文解读] LineVD: Statement-level Vulnerability Detection using Graph Neural Networks

David Hin, Andrey Kan|arXiv (Cornell University)|Mar 10, 2022
Software Engineering ResearchComputer Science被引用 32
一句话总结

LineVD 将语句级漏洞检测视为程序图上的节点分类,使用 CodeBERT 的代码嵌入和 GNN 来利用数据/控制依赖,相较于以往基于解释的模型取得显著提升。

ABSTRACT

Current machine-learning based software vulnerability detection methods are primarily conducted at the function-level. However, a key limitation of these methods is that they do not indicate the specific lines of code contributing to vulnerabilities. This limits the ability of developers to efficiently inspect and interpret the predictions from a learnt model, which is crucial for integrating machine-learning based tools into the software development workflow. Graph-based models have shown promising performance in function-level vulnerability detection, but their capability for statement-level vulnerability detection has not been extensively explored. While interpreting function-level predictions through explainable AI is one promising direction, we herein consider the statement-level software vulnerability detection task from a fully supervised learning perspective. We propose a novel deep learning framework, LineVD, which formulates statement-level vulnerability detection as a node classification task. LineVD leverages control and data dependencies between statements using graph neural networks, and a transformer-based model to encode the raw source code tokens. In particular, by addressing the conflicting outputs between function-level and statement-level information, LineVD significantly improve the prediction performance without vulnerability status for function code. We have conducted extensive experiments against a large-scale collection of real-world C/C++ vulnerabilities obtained from multiple real-world projects, and demonstrate an increase of 105\% in F1-score over the current state-of-the-art.

研究动机与目标

  • 通过使漏洞实现语句级定位,解决函数级漏洞预测的局限性。
  • 通过图神经网络利用语句之间的控制和数据依赖。
  • 整合函数级和语句级信息,以提高 SVD 的预测准确性。
  • 提供一种可扩展的、完全监督的方法,适用于现实世界的不平衡数据。

提出的方法

  • 将每个函数表示为一个图,其中节点为语句,边编码控制和数据依赖(PDG/CDG)。
  • 利用 CodeBERT 提取函数级和语句级嵌入,使用专门的分词和分类令牌来获取嵌入。
  • 应用图注意网络(GAT)在 PDG/CDG 边上传播语句间的上下文信息。
  • 训练一个共享分类器,将语句级 GNN 输出与函数级嵌入融合,包括逐元素交互以对齐预测。
  • 在语句标签上使用交叉熵损失进行优化,采用平衡函数级样本的训练策略,并在语句层面进行评估。

实验结果

研究问题

  • RQ1RQ1:与当前最先进的基于解释的 SVD 模型 IVDetect 相比,LineVD 如何改进语句级漏洞预测?
  • RQ2RQ2:不同的代码嵌入方法(CodeBERT、Doc2Vec、GloVe)如何影响语句级 SVD 的性能?
  • RQ3RQ3:使用 GNN(GCN 与 GAT)以及图类型(PDG 与 CDG)对性能的影响如何,函数级信息如何提供帮助?
  • RQ4RQ4:LineVD 在跨项目场景中,在测试数据来自尚未见过的项目时的表现如何?
  • RQ5RQ5:在真实世界数据中,LineVD 最能区分哪些语句类型?

主要发现

  • LineVD 将当前最先进的基于解释的模型在 F1 分数上提升了 105%。
  • LineVD 从联合学习函数级和语句级信息中受益,显著超越单一信息源的基线。
  • 在 PDG/CDG 加上 GNN(通常偏好 GAT)时,相较于非图基线,语句级漏洞检测得到提升。
  • LineVD 在 Real-world 数据集 Big-Vul 上,在不平衡数据与跨项目的分割下表现出有效性,该数据集约包含 ~10k 漏洞样本和 ~177k 非漏洞样本。
  • CodeBERT-based 嵌入在 LineVD 的框架内优于 Doc2Vec 和 GloVe,适用于语句级 SVD。
  • 该研究提供一个公开的复现实验包,包含数据集、代码和模型。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。