arXiv:2512.18567cs.SEcs.AI2025-12被引 6

首次大规模实证研究AI生成代码的分布与安全风险。

AI Code in the Wild: Measuring Security Risks and Ecosystem Shifts of AI-Generated Code in Modern Software

  • 构建高精度检测工具,区分人类与AI生成代码。
  • 发现AI集中于模板代码,但漏洞模式跨项目复现。
  • 适合作为开发者、安全团队和模型研究者参考。

大型语言模型(LLM)在代码生成中日益普及,但其真实使用情况与安全影响仍不明确。本文开展首个大规模实证研究,构建高精度检测流水线与代表性基准,对前1000个GitHub仓库(2022–2025年)的开发提交及7000+关联CVE的代码变更进行分析。通过标注提交、文件与函数的人类/人工智能轴线,追踪AI生成代码在项目中的传播路径与漏洞生命周期。结果显示:第一,AI生成代码已占新代码相当比例,但集中在胶水代码、测试、重构与文档等模板性内容,核心逻辑与安全关键配置仍以人工编写为主;第二,部分CWE类别在AI标记代码中显著高发,且近似不安全模板在无关项目间重复出现,表明存在由共享模型引发的“AI诱导漏洞”;第三,在人机协作编辑链中,AI引入大量变更,而人类充当安全守门人;当审查较浅时,AI引入缺陷留存更久,暴露于网络可访问表面,并扩散至更多文件与仓库。研究数据集与分析工具将开源。

原文摘要 · Abstract (English)

Large language models (LLMs) for code generation are becoming integral to modern software development, but their real-world prevalence and security impact remain poorly understood. We present the first large-scale empirical study of AI-generated code (AIGCode) in the wild. We build a high-precision detection pipeline and a representative benchmark to distinguish AIGCode from human-written code, and apply them to (i) development commits from the top 1,000 GitHub repositories (2022-2025) and (ii) 7,000+ recent CVE-linked code changes. This lets us label commits, files, and functions along a human/AI axis and trace how AIGCode moves through projects and vulnerability life cycles. Our measurements show three ecological patterns. First, AIGCode is already a substantial fraction of new code, but adoption is structured: AI concentrates in glue code, tests, refactoring, documentation, and other boilerplate, while core logic and security-critical configurations remain mostly human-written. Second, adoption has security consequences: some CWE families are overrepresented in AI-tagged code, and near-identical insecure templates recur across unrelated projects, suggesting "AI-induced vulnerabilities" propagated by shared models rather than shared maintainers. Third, in human-AI edit chains, AI introduces high-throughput changes while humans act as security gatekeepers; when review is shallow, AI-introduced defects persist longer, remain exposed on network-accessible surfaces, and spread to more files and repositories. We will open-source the complete dataset and release analysis artifacts and fine-grained documentation of our methodology and findings.

代码生成AI安全漏洞分析

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