arXiv:2503.09433cs.CRcs.AI2025-03被引 21

构建代码漏洞检测基准测试,评估静态分析、LLM等工具效果

CASTLE: Benchmarking Dataset for Static Code Analyzers and LLMs towards CWE Detection

  • 设计涵盖25类常见漏洞的250个微型程序测试集
  • 发现LLM在小段代码中表现优异但大代码时准确率下降
  • 提出公平评估指标CASTLE Score,适合安全研究者参考

识别源码中的漏洞对关键软件组件至关重要。现有方法包括静态分析、动态分析、形式化验证以及近期兴起的大语言模型(LLMs)。本文提出CASTLE(CWE Automated Security Testing and Low-Level Evaluation)基准框架,用于评估不同方法的漏洞检测能力。我们使用手工构造的250个微基准程序数据集,覆盖25种常见CWE,评估了13个静态分析工具、10个LLMs和2个形式化验证工具。提出新的CASTLE Score评估指标以实现公平比较。结果表明:ESBMC(形式化验证工具)误报率最低,但对模型检验以外的漏洞(如弱加密或SQL注入)处理不佳;静态分析工具误报率高,增加开发者人工验证负担;LLMs在小代码片段中表现优异,但随着代码规模增大,准确率下降且幻觉现象增多。这表明LLMs未来可在代码补全等实时场景中发挥关键作用,提供防错指导。数据集已公开于https://github.com/CASTLE-Benchmark。

原文摘要 · Abstract (English)

Identifying vulnerabilities in source code is crucial, especially in critical software components. Existing methods such as static analysis, dynamic analysis, formal verification, and recently Large Language Models are widely used to detect security flaws. This paper introduces CASTLE (CWE Automated Security Testing and Low-Level Evaluation), a benchmarking framework for evaluating the vulnerability detection capabilities of different methods. We assess 13 static analysis tools, 10 LLMs, and 2 formal verification tools using a hand-crafted dataset of 250 micro-benchmark programs covering 25 common CWEs. We propose the CASTLE Score, a novel evaluation metric to ensure fair comparison. Our results reveal key differences: ESBMC (a formal verification tool) minimizes false positives but struggles with vulnerabilities beyond model checking, such as weak cryptography or SQL injection. Static analyzers suffer from high false positives, increasing manual validation efforts for developers. LLMs perform exceptionally well in the CASTLE dataset when identifying vulnerabilities in small code snippets. However, their accuracy declines, and hallucinations increase as the code size grows. These results suggest that LLMs could play a pivotal role in future security solutions, particularly within code completion frameworks, where they can provide real-time guidance to prevent vulnerabilities. The dataset is accessible at https://github.com/CASTLE-Benchmark.

漏洞检测LLM安全静态分析基准测试

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。