AI-Generated Code Risks: A Threat to Software Supply Chains

▼ Summary
– AI-generated code often references fake software libraries, posing significant security risks and enabling sophisticated supply chain attacks.
– Dependency confusion attacks are exacerbated by AI models promoting fake libraries, allowing attackers to execute harmful code and steal data.
– The findings underscore the need for developers to verify dependencies and sources to prevent supply chain breaches, despite the convenience of AI tools.
AI-generated code poses serious security risks by frequently referencing fake software libraries, opening the door for sophisticated supply chain attacks that could compromise sensitive data and systems. Recent research reveals this alarming trend, showing how artificial intelligence tools often invent non-existent dependencies such as critical code components required for programs to function properly.
The study analyzed over half a million code samples produced by 16 leading large language models. Shockingly, 440,000 of the referenced dependencies were entirely fictional, with open-source models being the worst offenders—21% of their suggested libraries simply didn’t exist. These “hallucinated” packages create a perfect opportunity for hackers to exploit, inserting malicious code into projects under the guise of legitimate dependencies.
Dependency confusion attacks, where malicious actors upload counterfeit packages with names matching real ones but higher version numbers, become far more dangerous when AI models unknowingly promote these fake libraries. Once a developer unknowingly integrates a poisoned package, attackers can execute harmful code, steal data, or establish backdoors. This method was first demonstrated in 2021, successfully infiltrating networks at major corporations like Apple, Microsoft, and Tesla.
Joseph Spracklen, a lead researcher on the project, warns that attackers can easily weaponize these AI-generated suggestions. By publishing malicious packages under the same names as hallucinated dependencies, they trick developers into installing compromised code. Without thorough verification, unsuspecting users could inadvertently execute harmful payloads on their systems.
The findings highlight a critical vulnerability in modern software development, where overreliance on AI-generated code could expose organizations to devastating supply chain breaches. As AI tools become more integrated into coding workflows, developers must remain vigilant—double-checking dependencies and verifying sources before implementation. The convenience of AI assistance shouldn’t come at the cost of security.
(Source: Ars Technica)