arXiv:2509.20277cs.CRcs.AI2025-09被引 1

LLM生成代码存安全隐患,可能危及软件供应链安全

Investigating Security Implications of Automatically Generated Code on the Software Supply Chain

  • 通过分析43万+提示词,检测LLM生成代码中的供应链威胁
  • 发现所有11类威胁均持续存在,部分可导致软件被劫持
  • 提出链式确认与中间件防护机制,降低虚假代码风险

近年来,各类软件供应链(SSC)攻击对全球社区构成重大威胁。若开发者将存在漏洞的不安全代码片段集成到产品中,可能导致严重后果。尤其是大语言模型(LLMs)在开发领域广泛应用,但其生成代码时存在虚构、误导和依赖过时训练数据等固有问题,可能引发严重的供应链威胁。本文研究了这些固有问题带来的安全风险,系统分析了源码中外部组件及持续集成配置文件相关的三类共11种潜在威胁。实验发现,部分威胁可使攻击者劫持软件与工作流,另一些则可能长期潜伏并破坏软件安全性。为评估影响与严重性,我们设计工具SSCGuard,基于在线收集的SSC相关问题生成439,138个提示词,并分析GPT与Llama系列四个主流LLM的响应。结果表明,所有识别出的威胁均持续存在。为此,我们提出一种基于提示的防御机制‘Chain-of-Confirmation’以减少虚构内容,并设计一种中间件级防御方案,向用户提示各类SSC威胁。

原文摘要 · Abstract (English)

In recent years, various software supply chain (SSC) attacks have posed significant risks to the global community. Severe consequences may arise if developers integrate insecure code snippets that are vulnerable to SSC attacks into their products. Particularly, code generation techniques, such as large language models (LLMs), have been widely utilized in the developer community. However, LLMs are known to suffer from inherent issues when generating code, including fabrication, misinformation, and reliance on outdated training data, all of which can result in serious software supply chain threats. In this paper, we investigate the security threats to the SSC that arise from these inherent issues. We examine three categories of threats, including eleven potential SSC-related threats, related to external components in source code, and continuous integration configuration files. We find some threats in LLM-generated code could enable attackers to hijack software and workflows, while some others might cause potential hidden threats that compromise the security of the software over time. To understand these security impacts and severity, we design a tool, SSCGuard, to generate 439,138 prompts based on SSC-related questions collected online, and analyze the responses of four popular LLMs from GPT and Llama. Our results show that all identified SSC-related threats persistently exist. To mitigate these risks, we propose a novel prompt-based defense mechanism, namely Chain-of-Confirmation, to reduce fabrication, and a middleware-based defense that informs users of various SSC threats.

代码生成供应链安全LLM安全

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