arXiv:2508.16419cs.SEcs.LG2025-08被引 3

评测大模型在Python和C++中发现从基础错误到安全漏洞的能力

Can LLMs Find Bugs in Code? An Evaluation from Beginner Errors to Security Vulnerabilities in Python and C++

  • 采用多阶段提示策略模拟真实调试场景
  • 对语法语义错误检测准确率超90%,安全漏洞识别率不足60%
  • 适合初学者学习与代码初审,不适用于高危漏洞深度检测

大型语言模型(如ChatGPT-4、Claude 3、LLaMA 4)在软件开发中应用日益广泛,涵盖代码生成与调试。然而其在检测多样软件缺陷,特别是复杂安全漏洞方面的实际效果仍不明确。本研究对三款主流大模型进行系统性实证评估,使用包含基础编程错误、经典安全漏洞及生产级复杂缺陷的基准数据集,涵盖来自SEED Labs、OpenSSL(通过Suresoft GLaDOS数据库)和PyBugHive的真实代码,经本地编译与测试验证。采用新型多阶段上下文感知提示协议模拟真实调试环境,并通过分级评分体系衡量检测准确率、推理深度与修复质量。结果显示,所有模型在小范围代码中对语法与语义问题检测表现优异,准确率超过90%;但在涉及复杂安全漏洞和大规模生产代码时性能下降,其中ChatGPT-4与Claude 3较LLaMA 4提供更深入的上下文分析。这揭示了大模型在代码分析中的潜力与当前局限。

原文摘要 · Abstract (English)

Large Language Models (LLMs) such as ChatGPT-4, Claude 3, and LLaMA 4 are increasingly embedded in software/application development, supporting tasks from code generation to debugging. Yet, their real-world effectiveness in detecting diverse software bugs, particularly complex, security-relevant vulnerabilities, remains underexplored. This study presents a systematic, empirical evaluation of these three leading LLMs using a benchmark of foundational programming errors, classic security flaws, and advanced, production-grade bugs in C++ and Python. The dataset integrates real code from SEED Labs, OpenSSL (via the Suresoft GLaDOS database), and PyBugHive, validated through local compilation and testing pipelines. A novel multi-stage, context-aware prompting protocol simulates realistic debugging scenarios, while a graded rubric measures detection accuracy, reasoning depth, and remediation quality. Our results show that all models excel at identifying syntactic and semantic issues in well-scoped code, making them promising for educational use and as first-pass reviewers in automated code auditing. Performance diminishes in scenarios involving complex security vulnerabilities and large-scale production code, with ChatGPT-4 and Claude 3 generally providing more nuanced contextual analyses than LLaMA 4. This highlights both the promise and the present constraints of LLMs in serving as reliable code analysis tools.

代码检测大模型安全漏洞Python

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