arXiv:2508.11710cs.CRcs.AI2025-08

用AI模型跨语言检测代码漏洞,准确率超97%。

Code Vulnerability Detection Across Different Programming Languages with AI Models

  • 用CodeBERT等模型在漏洞代码上动态微调,提升检测能力。
  • 微调后模型准确率超97%,部分场景优于传统静态分析器。
  • 支持多语言、多漏洞类型,适合安全工具开发与研究者参考。

不同编程语言中的代码安全漏洞是源码检测中最关键且复杂的问题之一。基于规则的静态分析工具常因无法处理上下文依赖问题而误报率高。近年来,以CodeBERT和CodeLlama为代表的Transformer模型展现出更强的缺陷识别潜力。本文在多个代码漏洞数据集上实现这些模型的部署,通过在有漏洞与无漏洞代码片段上进行动态微调,构建具备预测能力的模型。方法包括数据收集、语言归一化、模型微调,以及集成学习与可解释性AI的融合。实验表明,经充分训练的CodeBERT模型在准确率上可达97%以上,甚至优于部分现有静态分析器。研究还发现,尽管模型召回率接近完美,但精确率可能下降;通过混合模型与验证流程可有效降低误报。结果证明,该AI方案具有跨语言、跨漏洞类别的泛化能力。然而,鲁棒性、可解释性与部署成熟度仍待提升。研究显示,人工智能有望显著增强漏洞检测工具的可信度、可用性与可扩展性。

原文摘要 · Abstract (English)

Security vulnerabilities present in a code that has been written in diverse programming languages are among the most critical yet complicated aspects of source code to detect. Static analysis tools based on rule-based patterns usually do not work well at detecting the context-dependent bugs and lead to high false positive rates. Recent developments in artificial intelligence, specifically the use of transformer-based models like CodeBERT and CodeLlama, provide light to this problem, as they show potential in finding such flaws better. This paper presents the implementations of these models on various datasets of code vulnerability, showing how off-the-shelf models can successfully produce predictive capacity in models through dynamic fine-tuning of the models on vulnerable and safe code fragments. The methodology comprises the gathering of the dataset, normalization of the language, fine-tuning of the model, and incorporation of ensemble learning and explainable AI. Experiments show that a well-trained CodeBERT can be as good as or even better than some existing static analyzers in terms of accuracy greater than 97%. Further study has indicated that although language models can achieve close-to-perfect recall, the precision can decrease. A solution to this is given by hybrid models and validation procedures, which will reduce false positives. According to the results, the AI-based solutions generalize to different programming languages and classes of vulnerability. Nevertheless, robustness, interpretability, and deployment readiness are still being developed. The results illustrate the probabilities that AI will enhance the trustworthiness in the usability and scalability of machine-learning-based detectors of vulnerabilities.

代码安全AI检测漏洞识别多语言

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