logo
AI Code Hallucinations Increase the Risk of ‘Package Confusion' Attacks

AI Code Hallucinations Increase the Risk of ‘Package Confusion' Attacks

WIRED30-04-2025

Apr 30, 2025 3:08 PM A new study found that code generated by AI is more likely to contain made-up information that can be used to trick software into interacting with malicious code. Photo-Illustration:AI-generated computer code is rife with references to non-existent third-party libraries, creating a golden opportunity for supply-chain attacks that poison legitimate programs with malicious packages that can steal data, plant backdoors, and carry out other nefarious actions, newly published research shows.
The study, which used 16 of the most widely used large language models to generate 576,000 code samples, found that 440,000 of the package dependencies they contained were 'hallucinated,' meaning they were non-existent. Open source models hallucinated the most, with 21 percent of the dependencies linking to non-existent libraries. A dependency is an essential code component that a separate piece of code requires to work properly. Dependencies save developers the hassle of rewriting code and are an essential part of the modern software supply chain. Package hallucination flashbacks
These non-existent dependencies represent a threat to the software supply chain by exacerbating so-called dependency confusion attacks. These attacks work by causing a software package to access the wrong component dependency, for instance by publishing a malicious package and giving it the same name as the legitimate one but with a later version stamp. Software that depends on the package will, in some cases, choose the malicious version rather than the legitimate one because the former appears to be more recent.
Also known as package confusion, this form of attack was first demonstrated in 2021 in a proof-of-concept exploit that executed counterfeit code on networks belonging to some of the biggest companies on the planet, Apple, Microsoft, and Tesla included. It's one type of technique used in software supply-chain attacks, which aim to poison software at its very source in an attempt to infect all users downstream.
'Once the attacker publishes a package under the hallucinated name, containing some malicious code, they rely on the model suggesting that name to unsuspecting users,' Joseph Spracklen, a University of Texas at San Antonio Ph.D. student and lead researcher, told Ars via email. 'If a user trusts the LLM's output and installs the package without carefully verifying it, the attacker's payload, hidden in the malicious package, would be executed on the user's system.'
In AI, hallucinations occur when an LLM produces outputs that are factually incorrect, nonsensical, or completely unrelated to the task it was assigned. Hallucinations have long dogged LLMs because they degrade their usefulness and trustworthiness and have proven vexingly difficult to predict and remedy. In a paper scheduled to be presented at the 2025 USENIX Security Symposium, they have dubbed the phenomenon 'package hallucination.'
For the study, the researchers ran 30 tests, 16 in the Python programming language and 14 in JavaScript, that generated 19,200 code samples per test, for a total of 576,000 code samples. Of the 2.23 million package references contained in those samples, 440,445, or 19.7 percent, pointed to packages that didn't exist. Among these 440,445 package hallucinations, 205,474 had unique package names.
One of the things that makes package hallucinations potentially useful in supply-chain attacks is that 43 percent of package hallucinations were repeated over 10 queries. 'In addition,' the researchers wrote, '58 percent of the time, a hallucinated package is repeated more than once in 10 iterations, which shows that the majority of hallucinations are not simply random errors, but a repeatable phenomenon that persists across multiple iterations. This is significant because a persistent hallucination is more valuable for malicious actors looking to exploit this vulnerability and makes the hallucination attack vector a more viable threat.'
In other words, many package hallucinations aren't random one-off errors. Rather, specific names of non-existent packages are repeated over and over. Attackers could seize on the pattern by identifying nonexistent packages that are repeatedly hallucinated. The attackers would then publish malware using those names and wait for them to be accessed by large numbers of developers.
The study uncovered disparities in the LLMs and programming languages that produced the most package hallucinations. The average percentage of package hallucinations produced by open source LLMs such as CodeLlama and DeepSeek was nearly 22 percent, compared with a little more than 5 percent by commercial models. Code written in Python resulted in fewer hallucinations than JavaScript code, with an average of almost 16 percent compared with a little over 21 percent for JavaScript. Asked what caused the differences, Spracklen wrote:
'This is a difficult question because large language models are extraordinarily complex systems, making it hard to directly trace causality. That said, we observed a significant disparity between commercial models (such as the ChatGPT series) and open-source models, which is almost certainly attributable to the much larger parameter counts of the commercial variants. Most estimates suggest that ChatGPT models have at least 10 times more parameters than the open-source models we tested, though the exact architecture and training details remain proprietary. Interestingly, among open-source models, we did not find a clear link between model size and hallucination rate, likely because they all operate within a relatively smaller parameter range.
'Beyond model size, differences in training data, fine-tuning, instruction training, and safety tuning all likely play a role in package hallucination rate. These processes are intended to improve model usability and reduce certain types of errors, but they may have unforeseen downstream effects on phenomena like package hallucination.
'Similarly, the higher hallucination rate for JavaScript packages compared to Python is also difficult to attribute definitively. We speculate that it stems from the fact that JavaScript has roughly 10 times more packages in its ecosystem than Python, combined with a more complicated namespace. With a much larger and more complex package landscape, it becomes harder for models to accurately recall specific package names, leading to greater uncertainty in their internal predictions and, ultimately, a higher rate of hallucinated packages.'
The findings are the latest to demonstrate the inherent untrustworthiness of LLM output. With Microsoft CTO Kevin Scott predicting that 95 percent of code will be AI-generated within five years, here's hoping developers heed the message.
This story originally appeared on Ars Technica.

Orange background

Try Our AI Features

Explore what Daily8 AI can do for you:

Comments

No comments yet...

Related Articles

The AI Trade Is Back in Play: 2 Stocks to Buy for Summer Sizzle!
The AI Trade Is Back in Play: 2 Stocks to Buy for Summer Sizzle!

Yahoo

time44 minutes ago

  • Yahoo

The AI Trade Is Back in Play: 2 Stocks to Buy for Summer Sizzle!

Written by Joey Frenette at The Motley Fool Canada The AI (artificial intelligence) trade is getting heated as we move towards the midpoint of the year, with the S&P 500 now just a good day or two away from completing its so-called V-shaped recovery from the brutal spring correction (nearly a bear market for the S&P 500 as the TSX Index held its own relatively well) worsened by Trump's sweeping tariff war with most of the world. If you're a tad jittery after the volatility experienced a few months ago, you're not alone. It's hard to justify buying the stock on strength as tariff talks continue to dominate the headlines. In any case, I think there are great value names that don't entail paying all too high a premium for long-term AI exposure. In this piece, we'll have a look at two great names for investors seeking growth at a reasonable price (GARP). As GARP clashes with the AI trade, I think the following names could be timely bets for the medium and long term. Apple (NASDAQ:AAPL) stock seems stuck in a bear market, with shares falling below the $200 level again following what can only be described as a less-than-exciting 2025 edition of WWDC (Worldwide Developers' Conference). I saw the whole thing, and it was lighter in the AI than expected. After facing criticism for overpromising with its Apple Intelligence, which may be an early flop depending on who you ask, I think it's no surprise that the latest WWDC was a bit lighter on the AI promises. Does that mean Apple is ready to step away from the AI race? Of course not! Rather, I think Apple's just underpromising so that it can overdeliver a year or two from now. Indeed, there's a high bar to pass for the next-level Siri to land. And it's not yet above the high bar set by Apple. Despite the less-exciting and relatively AI-light WWDC, I still consider Apple to be a top AI play that'll be worth the wait. For now, there's Liquid Glass technology to get excited about as Apple applies more polish to its model that it wants to get right, even if it means showing up even later to the AI party. After slipping more than 23% from its highs over AI jitters and underwhelming post-WWDC, I think it's time to start thinking about doing some buying. Indeed, the stock is down nearly 7% in the past year, with a forward price-to-earnings multiple of 25.1 times, which is way too low for a firm that's going slow and steady in this AI race. I think slow and steady may very well win the race. But, of course, time will tell. I've been pounding the table on Shopify (TSX:SHOP) and its AI potential for quite some time now (likely well over a year). And recently, I highlighted that some analysts covering the stock are starting to take notice. Indeed, Wall Street is catching on to the company's AI prowess. And with that, I believe, could accompany multiple expansion as the firm continues investing heavily in AI technologies to level up its product. Personally, I think Shopify is the most innovative tech firm in Canada and perhaps in the e-commerce scene. As such, investors may wish to watch the name to buy on any dips over the coming weeks and months. Shopify is the real deal. And to discount its AI powers, I think, would be a mistake. The post The AI Trade Is Back in Play: 2 Stocks to Buy for Summer Sizzle! appeared first on The Motley Fool Canada. More reading Made in Canada: 5 Homegrown Stocks Ready for the 'Buy Local' Revolution [PREMIUM PICKS] Market Volatility Toolkit Best Canadian Stocks to Buy in 2025 Beginner Investors: 4 Top Canadian Stocks to Buy for 2025 5 Years From Now, You'll Probably Wish You Grabbed These Stocks Subscribe to Motley Fool Canada on YouTube Fool contributor Joey Frenette has positions in Apple. The Motley Fool has positions in and recommends Shopify. The Motley Fool recommends Apple. The Motley Fool has a disclosure policy. 2025 Error in retrieving data Sign in to access your portfolio Error in retrieving data Error in retrieving data Error in retrieving data Error in retrieving data

MicroStrategy's Michael Saylor On Bitcoin's Quantum Computing Risk: 'I Don't Worry About It'
MicroStrategy's Michael Saylor On Bitcoin's Quantum Computing Risk: 'I Don't Worry About It'

Yahoo

time2 hours ago

  • Yahoo

MicroStrategy's Michael Saylor On Bitcoin's Quantum Computing Risk: 'I Don't Worry About It'

Benzinga and Yahoo Finance LLC may earn commission or revenue on some items through the links below. With increased attention and adoption has come increased scrutiny of Bitcoin risks. Among the risks gaining increased attention in recent months is the threat of quantum computing. The fear is that supercomputers will soon emerge that can break Bitcoin's cryptography, putting user assets at risk. But as scary as this potential reality sounds, MicroStrategy (NASDAQ:MSTR) Chair Michael Saylor has said that he is not losing sleep over it. If there is anyone that should be concerned, it is Saylor. Don't Miss: — no wallets, just price speculation and free paper trading to practice different strategies. Grow your IRA or 401(k) with Crypto – . Over the past five years, he has spearheaded an aggressive Bitcoin treasury strategy at the erstwhile business software intelligence firm, which has seen it accumulate 582,000 BTC, currently worth over $63 billion. 'I don't worry about it,' he told CNBC last week, referring to the potential quantum computing threat to Bitcoin. Saylor claimed the recent fuss over quantum computing developments and how it could impact Bitcoin was a marketing ploy by projects seeking to position their assets as an alternative to Bitcoin. 'It's mainly marketing by people that want to sell you the next quantum yo-yo token,' he said. 'Look, Google and Microsoft aren't going to sell you a quantum computer that cracks modern cryptography because it would destroy Google and Microsoft and the US government and the banking system.' Trending: New to crypto? on Coinbase. Saylor said that quantum computing was unlikely to become a genuine concern for Bitcoin for another 10 or 20 years. And then, he said, that like Microsoft (NASDAQ:MSFT), Google and the traditional banking system, Bitcoin would simply upgrade its software. Saylor's unnerved stance comes despite recent Google research suggesting that it may now take 20 times fewer quantum resources to crack RSA encryption, which likely indicates a faster-than-expected timeline for cracking Bitcoin's Elliptic Curve Cryptography as well. Quantum computing firm Project 11 launched a competition in April to settle the question of how urgent the threat is to Bitcoin. The firm challenged teams and individuals to attempt to break the longest ECC key they can from a selection of 1 to 25 bits for a chance to win 1 BTC. The competition will end on April 5, 2026. Unlike Saylor, Project 11 said that it believed quantum computers could break Bitcoin's wallet encryption within the decade, putting billions in user assets in exposed wallet addresses at risk. The firm estimates that 6.3 million BTC, currently worth over $648 billion, is at risk. Read Next:Deloitte's fastest-growing software company partners with Amazon, Walmart & Target – Image: Shutterstock This article MicroStrategy's Michael Saylor On Bitcoin's Quantum Computing Risk: 'I Don't Worry About It' originally appeared on Error in retrieving data Sign in to access your portfolio Error in retrieving data Error in retrieving data Error in retrieving data Error in retrieving data

Analysis-Meta's $14.8 billion Scale AI deal latest test of AI partnerships
Analysis-Meta's $14.8 billion Scale AI deal latest test of AI partnerships

Yahoo

time2 hours ago

  • Yahoo

Analysis-Meta's $14.8 billion Scale AI deal latest test of AI partnerships

By Jody Godoy (Reuters) -Facebook owner Meta's $14.8 billion investment in Scale AI and hiring of the data-labeling startup's CEO will test how the Trump administration views so-called acquihire deals, which some have criticized as an attempt to evade regulatory scrutiny. The deal, announced on Thursday, was Meta's second-largest investment to date. It gives the owner of Facebook a 49% nonvoting stake in Scale AI, which uses gig workers to manually label data and includes among its customers Meta competitors Microsoft and ChatGPT creator OpenAI. Unlike an acquisition or a transaction that would give Meta a controlling stake, the deal does not require a review by U.S. antitrust regulators. However, they could probe the deal if they believe it was structured to avoid those requirements or harm competition. The deal appeared to be structured to avoid potential pitfalls, such as cutting off competitors' access to Scale's services or giving Meta an inside view into rivals' operations - though Reuters exclusively reported on Friday that Alphabet's Google has decided to sever ties with Scale in light of Meta's stake, and other customers are looking at taking a step back. In a statement, a Scale AI spokesperson said its business, which spans work with major companies and governments, remains strong, as it is committed to protecting customer data. The company declined to comment on specifics with Google. Alexandr Wang, Scale's 28-year-old CEO who is coming to Meta as part of the deal, will remain on Scale's board but will have appropriate restrictions placed around his access to information, two sources familiar with the move confirmed. Large tech companies likely perceive the regulatory environment for AI partnerships as easier to navigate under President Donald Trump than under former President Joe Biden, said William Kovacic, director of the competition law center at George Washington University. Trump's antitrust enforcers have said they do not want to regulate how AI develops, but have also displayed a suspicion of large tech platforms, he added. "That would lead me to think they will keep looking carefully at what the firms do. It does not necessarily dictate that they will intervene in a way that would discourage the relationships," Kovacic said. Federal Trade Commission probes into past "aquihire" deals appear to be at a standstill. Under the Biden administration, the FTC opened inquiries into Amazon's deal to hire top executives and researchers from AI startup Adept, and Microsoft's $650 million deal with Inflection AI. The latter allowed Microsoft to use Inflection's models and hire most of the startup's staff, including its co-founders. Amazon's deal closed without further action from the regulator, a source familiar with the matter confirmed. And, more than a year after its initial inquiry, the FTC has so far taken no enforcement action against Microsoft over Inflection, though a larger probe over practices at the software giant is ongoing. A spokesperson for the FTC declined to comment on Friday. David Olson, a professor who teaches antitrust law at Boston College Law School, said it was smart of Meta to take a minority nonvoting stake. "I think that does give them a lot of protection if someone comes after them," he said, adding that it was still possible that the FTC would want to review the agreement. The Meta deal has its skeptics. U.S. Senator Elizabeth Warren, a Democrat from Massachusetts who is probing AI partnerships involving Microsoft and Google, said Meta's investment should be scrutinized. 'Meta can call this deal whatever it wants - but if it violates federal law because it unlawfully squashes competition or makes it easier for Meta to illegally dominate, antitrust enforcers should investigate and block it," she said in a statement on Friday. While Meta faces its own monopoly lawsuit by the FTC, it remains to be seen whether the agency will have any questions about its Scale investment. The U.S. Department of Justice's antitrust division, led by former JD Vance adviser Gail Slater, recently started looking into whether Google's partnership with chatbot creator was designed to evade antitrust review, Bloomberg News reported. The DOJ is separately seeking to make Google give it advance notice of new AI investments as part of a proposal to curb the company's dominance in online search. Sign in to access your portfolio

DOWNLOAD THE APP

Get Started Now: Download the App

Ready to dive into the world of global news and events? Download our app today from your preferred app store and start exploring.
app-storeplay-store