用AI自动检测代码漏洞并给出修复建议,支持14种语言。
MalCodeAI: Autonomous Vulnerability Detection and Remediation via Language Agnostic Code Reasoning
- 通过微调大模型实现跨语言代码分解与语义分析。
- 漏洞检测验证损失低至0.199,能识别零日漏洞并生成修复方案。
- 输出可读性强,开发者实测满意度高,适合实际开发使用。
随着网络威胁日益复杂,传统漏洞检测工具已显局限。我们提出MalCodeAI,一种无需依赖编程语言的多阶段AI安全分析与修复系统。该系统基于微调的Qwen2.5-Coder-3B-Instruct模型,在MLX框架中通过低秩适配(LoRA)优化,支持14种编程语言的可扩展、高精度分析。第一阶段中,经过200轮迭代、6个可训练层、学习率2×10⁻⁵,功能分解与代码摘要的验证损失降至0.397。第二阶段,使用相同配置但学习率提升至4×10⁻⁵,漏洞检测与修复的验证损失达0.199,有效识别安全缺陷并提出可操作修复建议。系统支持红帽风格漏洞追踪、基于CVSS的风险评分,并具备零样本泛化能力,可发现复杂零日漏洞。15名开发者的定性评估显示,系统在实用性(均分8.06/10)、可解释性(均分7.40/10)和输出可读性(均分7.53/10)方面表现优异,证实其在真实开发流程中的实用价值。本工作推动了智能、可解释、以开发者为中心的软件安全解决方案发展。
原文摘要 · Abstract (English)
The growing complexity of cyber threats and the limitations of traditional vulnerability detection tools necessitate novel approaches for securing software systems. We introduce MalCodeAI, a language-agnostic, multi-stage AI pipeline for autonomous code security analysis and remediation. MalCodeAI combines code decomposition and semantic reasoning using fine-tuned Qwen2.5-Coder-3B-Instruct models, optimized through Low-Rank Adaptation (LoRA) within the MLX framework, and delivers scalable, accurate results across 14 programming languages. In Phase 1, the model achieved a validation loss as low as 0.397 for functional decomposition and summarization of code segments after 200 iterations, 6 trainable layers, and a learning rate of 2 x 10^(-5). In Phase 2, for vulnerability detection and remediation, it achieved a best validation loss of 0.199 using the same number of iterations and trainable layers but with an increased learning rate of 4 x 10^(-5), effectively identifying security flaws and suggesting actionable fixes. MalCodeAI supports red-hat-style exploit tracing, CVSS-based risk scoring, and zero-shot generalization to detect complex, zero-day vulnerabilities. In a qualitative evaluation involving 15 developers, the system received high scores in usefulness (mean 8.06/10), interpretability (mean 7.40/10), and readability of outputs (mean 7.53/10), confirming its practical value in real-world development workflows. This work marks a significant advancement toward intelligent, explainable, and developer-centric software security solutions.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。