arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.06279cs.SEcs.AI
收藏

正确的代码,易受攻击的依赖项:一项大规模的LLM指定库版本测量研究

Correct Code, Vulnerable Dependencies: A Large Scale Measurement Study of LLM-Specified Library Versions

Intelligent Software Research Center, Institute of Software, Chinese Academy of Sciences, Beijing, China(智能软件研究中心,软件研究所,中国科学院,北京,中国);University of Chinese Academy of Sciences, Beijing, China(中国科学院大学,北京,中国);Key Laboratory of System Software (Chinese Academy of Sciences), Beijing, China(中国科学院系统软件重点实验室,北京,中国)

Chengjie Wang, Jingzheng Wu, Xiang Ling, Tianyue Luo, Chen Zhao

AI总结:

研究LLM生成代码中库版本的安全性和兼容性风险,发现版本选择存在系统性偏差,且版本选择影响漏洞暴露和兼容性故障。

摘要:

大型语言模型(LLMs)如今广泛参与软件开发流程,生成的代码通常包含带有特定版本标识的第三方库(TPL)导入。这些版本选择可能带来安全和兼容性风险,但尚未被系统研究。本文首次对LLM生成的Python代码中版本级风险进行了大规模测量研究,评估了10个LLM在PinTrace基准上的表现。LLM在直接提示时倾向于指定版本标识(26.83%-95.18%),而在创建manifest文件时降至6.45%-59.19%。在指定的版本中,36.70%-55.70%的任务包含至少一个已知CVE,62.75%-74.51%的CVE具有高或严重严重性。72.27%-91.37%的CVE在模型知识截止前已公开披露。统计显示所有模型都收敛到相同的少量高风险版本,表明系统性偏差而非孤立模型错误。静态兼容性率为19.70%-63.20%,安装失败是主要原因。动态测试用例通过率6.49%-48.62%。进一步实验证实这些失败归因于版本选择而非代码质量,且外部锚定版本约束显著减少漏洞暴露和兼容性故障。研究揭示LLM版本选择作为LLM开发中的首要风险表面,此前被忽视。

英文摘要:

Large language models (LLMs) are now largely involved in software development workflows, and the code they generate routinely includes third-party library (TPL) imports annotated with specific version identifiers. These version choices can carry security and compatibility risks, yet they have not been systematically studied. We present the first large-scale measurement study of version-level risk in LLM-generated Python code, evaluating 10 LLMs on PinTrace, a curated benchmark of 1,000 Stack Overflow programming tasks. LLMs tend to specify version identifiers when directly prompted at 26.83%-95.18%, while down to 6.45%-59.19% in creating a manifest file directly. Among the specified versions, 36.70%-55.70% of tasks contain at least one known CVE, and 62.75%-74.51% of them carry Critical or High severity ratings. In 72.27%-91.37% of cases, the associated CVEs were publicly disclosed before the model's knowledge cutoff. The statistics show all models converge on the same small set of risky release versions, indicating a systemic bias rather than isolated model error. Static compatibility rates range from 19.70% to 63.20%, with installation failure as the dominant cause. The dynamic test cases confirm the pattern by 6.49%-48.62% pass rates. Further experiments confirm that these failures are attributable to version selection rather than code quality, and that externally anchored version constraints substantially reduce both vulnerability exposure and compatibility failures. Our findings reveal LLM version selection as a first-class, previously overlooked risk surface in LLM-based development. We disclosed these findings to the community of the evaluated models, and several confirmed the issue. All the code and dataset have been released for open science at https://github.com/dw763j/PinTrace.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑