评估基于学习的代码漏洞检测模型的行级定位能力
Evaluating Line-level Localization Ability of Learning-based Code Vulnerability Detection Models
AI总结:
针对基于学习的代码漏洞检测模型仅能标记整段函数而无法精确定位漏洞行的问题,提出基于可解释性的检测对齐(DA)评估方法,发现模型预测持续受非漏洞行偏差影响。
摘要:
为了解决极其令人担忧的软件漏洞问题,系统安全通常被托付给机器学习(ML)算法。尽管此类模型现已具备成熟的检测能力,但受限于设计,它们只能将整个输入源代码函数标记为存在漏洞,而无法精确定位相关的代码行。然而,检测粒度对于在软件开发过程中支持人工操作员至关重要,可确保此类预测反映真实的代码语义,从而帮助调试、评估和修复检测到的漏洞。为了解决这一问题,近期的研究在提升检测器的定位能力方面取得了进展,从而缩小了漏洞检测的“窗口”并提供更细粒度的预测。然而,此类方法隐式地忽视了数据中存在的伪相关性和偏差,而这些因素往往对ML算法的性能产生主导影响。在本研究中,我们通过提出一种基于可解释性的评估程序来调查检测器如何满足这一要求。我们的方法定义为检测对齐(Detection Alignment, DA),它量化了最影响预测的输入源代码行与根据真实情况的漏洞实际定位之间的一致性。通过DA(这是一种与模型无关且适应不同检测任务的方法,不仅限于我们的用例),我们分析了多个基于学习的漏洞检测器和数据集。结果表明,此类模型的预测持续受到非漏洞行的影响,最终凸显了偏差和伪相关性的高影响。代码可在 https://github.com/pralab/vuln-localization-eval 获取。
英文摘要:
To address the extremely concerning problem of software vulnerability, system security is often entrusted to Machine Learning (ML) algorithms. Despite their now established detection capabilities, such models are limited by design to flagging the entire input source code function as vulnerable, rather than precisely localizing the concerned code lines. However, the detection granularity is crucial to support human operators during software development, ensuring that such predictions reflect the true code semantics to help debug, evaluate, and fix the detected vulnerabilities. To address this issue, recent work made progress toward improving the detector's localization ability, thus narrowing down the vulnerability detection "window" and providing more fine-grained predictions. Such approaches, however, implicitly disregard the presence of spurious correlations and biases in the data, which often predominantly influence the performance of ML algorithms. In this work, we investigate how detectors comply with this requirement by proposing an explainability-based evaluation procedure. Our approach, defined as Detection Alignment (DA), quantifies the agreement between the input source code lines that most influence the prediction and the actual localization of the vulnerability as per the ground truth. Through DA, which is model-agnostic and adaptable to different detection tasks, not limited to our use case, we analyze multiple learning-based vulnerability detectors and datasets. As a result, we show how the predictions of such models are consistently biased by non-vulnerable lines, ultimately highlighting the high impact of biases and spurious correlations. The code is available at https://github.com/pralab/vuln-localization-eval.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。