[论文解读] Automated software vulnerability detection with machine learning
一个基于数据驱动的机器学习方法使用源代码基础特征和构建特征来检测 C/C++ 函数的漏洞;最佳模型(TextCNN 特征输入到 Extra Trees 分类器)在 PR AUC 0.49 和 ROC AUC 0.87 上表现最佳。
Thousands of security vulnerabilities are discovered in production software each year, either reported publicly to the Common Vulnerabilities and Exposures database or discovered internally in proprietary code. Vulnerabilities often manifest themselves in subtle ways that are not obvious to code reviewers or the developers themselves. With the wealth of open source code available for analysis, there is an opportunity to learn the patterns of bugs that can lead to security vulnerabilities directly from data. In this paper, we present a data-driven approach to vulnerability detection using machine learning, specifically applied to C and C++ programs. We first compile a large dataset of hundreds of thousands of open-source functions labeled with the outputs of a static analyzer. We then compare methods applied directly to source code with methods applied to artifacts extracted from the build process, finding that source-based models perform better. We also compare the application of deep neural network models with more traditional models such as random forests and find the best performance comes from combining features learned by deep models with tree-based models. Ultimately, our highest performing model achieves an area under the precision-recall curve of 0.49 and an area under the ROC curve of 0.87.
研究动机与目标
- 激发并解决软件中可扩展漏洞检测的需求。
- 利用由静态分析器标注的大型开源代码数据集来训练 ML 模型。
- 比较基于源代码的特征与基于构建的特征在漏洞检测中的差异。
- 评估传统模型与深度学习模型,并探索模型融合以提升性能。
提出的方法
- 构建两个特征管线:(1) 从编译期间提取的 CFG、use-def 和 op-vec 的基于构建的特征;(2) 使用自定义 C/C++ 词法分析器的源代码特征,词袋模型和 word2vec 嵌入。
- 在从 Clang 静态分析器输出推导的函数级标签上训练多种分类器,将 buggy 与 good 视为地面真相。
- 评估三种基于源的模型:带 BoW 特征的 Extra Trees、带 word2vec 初始化的 TextCNN,以及将 TextCNN 特征输入 Extra Trees;并比较基于构建的固定大小构建特征向量的 Random Forest。
- 通过将基于构建的特征与源基 BoW 特征连接,研究组合模型。
- 使用两个数据集(Debian 和 GitHub),并执行严格的重复数据移除以确保评估有效性。
实验结果
研究问题
- RQ1是否可以仅通过源代码模式有效学习漏洞检测,还是构建派生的特征提供互补信息?
- RQ2深度学习表示(word2vec、TextCNN)在本任务上是否优于传统模型,模型融合是否提升性能?
- RQ3在具有不同特征的数据集(Debian 与 GitHub)上,基于源的与基于构建的方法有何比较?
主要发现
- 基于源的模型在 ROC AUC 上超过基于构建的模型,遍布各数据集。
- 最佳的基于源的模型(TextCNN 特征输入到 Extra Trees)在合并后的 Debian+Github 数据集上达到 ROC AUC 0.87 和 PR AUC 0.49。
- BoW+ET 在相同数据集上达到 ROC AUC 0.85 和 PR AUC 0.44;word2vec+CNN 达到 ROC AUC 0.87 和 PR AUC 0.45;CNN feat.+ET 达到 ROC AUC 0.87 和 PR AUC 0.49。
- 在基于构建的检测上,Debian 的 ROC AUC 为 0.76,PR AUC 为 0.21;GitHub 为 0.74 和 0.22。
- 组合模型(构建+源)通常优于单一来源,例如在 GitHub 上:Build 0.74/0.22,Source 0.81/0.29,Combined 0.82/0.32。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。