从通才到专才:探索CWE特定的漏洞检测
From Generalist to Specialist: Exploring CWE-Specific Vulnerability Detection
AI总结:
本文针对漏洞类型异质性问题,提出并验证为每个CWE训练专用分类器,再以多分类方式构建统一检测系统,性能优于单一二分类器。
摘要:
使用机器学习进行漏洞检测(VD)面临一项重大挑战:漏洞类型极其多样。每个通用弱点枚举(Common Weakness Enumeration,CWE)都代表一个独特的漏洞类别,具有不同的特征、代码语义和模式。采用二分类方法将所有漏洞视为单一标签,可能会过度简化问题,因为它无法捕捉每个CWE特有的细微差别和上下文。因此,单个二分类器可能只会依赖表层文本模式,而不能理解每种漏洞类型的复杂之处。近期报告表明,即便是拥有数千亿参数的最先进大型语言模型(LLM),也难以很好地泛化以检测漏洞。我们的工作研究了一种不同方法,利用CWE特定分类器来解决漏洞类型的异质性。我们假设,为每个CWE训练独立分类器,将使模型能够捕捉与每个漏洞类别相关的独特特征和代码语义。为证实这一点,我们开展了一项消融研究:为每个CWE训练单独的分类器,并独立评估其性能。结果表明,CWE特定分类器优于在所有漏洞上训练的单个二分类器。在此基础上,我们探索使用多分类方法将这些分类器组合成统一漏洞检测系统的策略。尽管缺乏大规模、高质量的漏洞检测数据集仍是主要障碍,但我们的结果表明,多分类检测可能是未来实现实用漏洞检测的更好路径。我们用于生成结果的所有模型和代码均已开源。
英文摘要:
Vulnerability Detection (VD) using machine learning faces a significant challenge: the vast diversity of vulnerability types. Each Common Weakness Enumeration (CWE) represents a unique category of vulnerabilities with distinct characteristics, code semantics, and patterns. Treating all vulnerabilities as a single label with a binary classification approach may oversimplify the problem, as it fails to capture the nuances and context-specific to each CWE. As a result, a single binary classifier might merely rely on superficial text patterns rather than understanding the intricacies of each vulnerability type. Recent reports showed that even the state-of-the-art Large Language Model (LLM) with hundreds of billions of parameters struggles to generalize well to detect vulnerabilities. Our work investigates a different approach that leverages CWE-specific classifiers to address the heterogeneity of vulnerability types. We hypothesize that training separate classifiers for each CWE will enable the models to capture the unique characteristics and code semantics associated with each vulnerability category. To confirm this, we conduct an ablation study by training individual classifiers for each CWE and evaluating their performance independently. Our results demonstrate that CWE-specific classifiers outperform a single binary classifier trained on all vulnerabilities. Building upon this, we explore strategies to combine them into a unified vulnerability detection system using a multiclass approach. Even if the lack of large and high-quality datasets for vulnerability detection is still a major obstacle, our results show that multiclass detection can be a better path toward practical vulnerability detection in the future. All our models and code to produce our results are open-sourced.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。