一句话:提出交叉验证基准方法,揭示基于语义保持变换增强训练的漏洞检测模型仍依赖无关特征,鲁棒性不泛化。
机器学习自动漏洞检测在测试集上可达到较高准确率,但这些结果是否泛化于数据集之外仍存疑。已有工作通过注入语义保持变换放大测试集,发现模型准确率显著下降,说明模型使用了无关特征;用放大训练数据可恢复准确率。本文复现并推进该研究,提出一种可操作的模型基准评测方法。具体地,作者提出交叉验证算法,在训练集或测试集放大阶段应用语义保持变换,并系统评估模型对未见变换的鲁棒性。使用11种变换和3种机器学习技术,实验发现:训练数据增强带来的鲁棒性提升只适用于训练时所用的特定变换;换言之,经过鲁棒化处理的模型在测试数据上预测漏洞时仍然依赖无关特征。该工作为更可靠地评估漏洞检测中的机器学习进展提供了基准方法。
Recent results of machine learning for automatic vulnerability detection have been very promising indeed: Given only the source code of a function f, models trained by machine learning techniques can decide if f contains a security flaw with up to 70% accuracy. But how do we know that these results are general and not specific to the datasets? To study this question, researchers proposed to amplify the testing set by injecting semantic preserving changes and found that the model’s accuracy significantly drops. In other words, the model uses some unrelated features during classification. In order to increase the robustness of the model, researchers proposed to train on amplified training data, and indeed model accuracy increased to previous levels. In this paper, we replicate and continue this investigation, and provide an actionable model benchmarking methodology to help researchers better evaluate advances in machine learning for vulnerability detection. Specifically, we propose a cross validation algorithm, where a semantic preserving transformation is applied during the amplification of either the training set or the testing set. Using 11 transformations and 3 ML techniques, we find that the improved robustness only applies to the specific transformations used during training data amplification. In other words, the robustified models still rely on unrelated features for predicting the vulnerabilities in the testing data.