arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2512.18567cs.SEcs.AI
收藏

AI 代码在现实世界中的应用:衡量 AI 生成代码在现代软件中的安全风险和生态系统变化

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

Peking University(北京大学);Tencent(腾讯)

Bin Wang, Wenjie Yu, Yilu Zhong, Hao Yu, Keke Lian, Chaohua Lu, Hongfang Zheng, Dong Zhang, Hui Li

AI总结:

本文研究了AI生成代码在现实世界中的安全风险和生态系统变化,通过大规模实证分析揭示了AI代码在软件开发中的分布、安全影响及人类与AI协作中的安全机制。

摘要:

大型语言模型(LLMs)用于代码生成正在成为现代软件开发的重要组成部分,但其在现实世界中的普及程度和安全影响仍然了解甚少。我们提出了首次大规模的实证研究,探讨现实世界中的 AI 生成代码(AIGCode)。我们构建了一个高精度的检测管道和一个具有代表性的基准,以区分 AI 生成代码和人工编写代码,并将其应用于(i)来自顶级 1000 个 GitHub 仓库的开发提交(2022-2025 年)和(ii)7000 多个与最近 CVE 相关的代码更改。这使我们能够对提交、文件和函数进行标记,并在人类/AI 轴上追踪 AI 生成代码在项目和漏洞生命周期中的移动。我们的测量显示了三种生态模式。首先,AI 生成代码已经是新代码的重要组成部分,但其采用是结构化的:AI 集中于粘合代码、测试、重构、文档和其他样板代码,而核心逻辑和安全关键配置主要由人工编写。其次,采用有安全影响:某些 CWE 家族在 AI 标记的代码中过度表示,且近似的不安全模板在无关项目中反复出现,表明“AI 引发的漏洞”通过共享模型传播,而非共享维护者。第三,在人类-AI 编辑链中,AI 引入了高吞吐量的更改,而人类则充当安全守门人;当审查较浅时,AI 引入的缺陷会持续更久,暴露在可网络访问的表面,并传播到更多文件和仓库。我们将开源完整的数据集,并发布分析工具和我们方法和发现的详细文档。

英文摘要:

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分析而来,可能存在错误,请以论文正文为准。

↑