一句话:系统评估数据采样对深度学习漏洞检测的影响,发现原始数据随机过采样最佳,且模型常不能基于真实漏洞语句推理。
针对深度学习漏洞检测(DLVD)在真实不平衡数据上性能骤降(平均F1下降73%)的问题,本文系统研究数据采样对DLVD的影响,涵盖检测效果与模型能否依据真实漏洞语句进行正确推理两方面。实验比较过采样/欠采样、原始数据/隐空间采样及SMOTE、OSS等策略。结果表明:过采样通常优于欠采样,原始数据采样优于隐空间采样,原始数据随机过采样最佳;OSS无助于缓解不平衡;若追求召回率,随机欠采样最优。原始随机过采样也能改善模型学习真实漏洞模式,但至少33%的案例中模型无法基于真实漏洞语句进行推理。最后给出可操作建议与研究路线图。
Recent progress in Deep Learning (DL) has sparked interest in using DL to detect software vulnerabilities automatically and it has been demonstrated promising results at detecting vulnerabilities. However, one prominent and practical issue for vulnerability detection is data imbalance. Prior study observed that the performance of state-of-the-art (SOTA) DL-based vulnerability detection (DLVD) approaches drops precipitously in real world imbalanced data and a 73% drop of F1-score on average across studied approaches. Such a significant performance drop can disable the practical usage of any DLVD approaches. Data sampling is effective in alleviating data imbalance for machine learning models and has been demonstrated in various software engineering tasks. Therefore, in this study, we conducted a systematical and extensive study to assess the impact of data sampling for data imbalance problem in DLVD from two aspects: i) the effectiveness of DLVD, and ii) the ability of DLVD to reason correctly (making a decision based on real vulnerable statements). We found that in general, oversampling outperforms undersampling, and sampling on raw data outperforms sampling on latent space, typically random oversampling on raw data performs the best among all studied ones (including advanced one SMOTE and OSS). Surprisingly, OSS does not help alleviate the data imbalance issue in DLVD. If the recall is pursued, random undersampling is the best choice. Random oversampling on raw data also improves the ability of DLVD approaches for learning real vulnerable patterns. However, for a significant portion of cases (at least 33% in our datasets), DVLD approach cannot reason their prediction based on real vulnerable statements. We provide actionable suggestions and a roadmap to practitioners and researchers.