Correct Code, Vulnerable Dependencies: A Large Scale Measurement Study of LLM-Specified Library Versions
This large-scale measurement study reveals that LLMs frequently specify vulnerable and incompatible third-party library versions in generated Python code due to systemic biases toward specific risky releases, highlighting a critical, previously overlooked risk surface in AI-assisted software development.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are hiring a super-smart, incredibly fast personal assistant to write code for your software projects. This assistant, powered by a Large Language Model (LLM), is great at writing the logic: "Here is how you lock a door," or "Here is how you send a message."
But there's a catch. To make the code work, the assistant needs to use "tools" (third-party libraries) that already exist. The problem this paper investigates is that the assistant doesn't just grab the tools; it grabs specific, outdated, and sometimes broken versions of those tools, and it does so without you realizing it.
Here is a breakdown of the study's findings using simple analogies:
1. The "Recipe" vs. The "Shopping List"
The researchers tested two ways of asking the assistant for code:
- The "Inline" Mode: You ask for a code snippet, and the assistant writes the code and adds a little note next to every tool saying, "Use Tool X, Version 1.0."
- The "Manifest" Mode: You ask the assistant to write a code snippet and a separate shopping list (a
requirements.txtfile) for the tools.
The Finding:
When asked for the "Inline" note, the assistant was very eager to specify exact versions (95% of the time). But when asked for the "Shopping List," it suddenly became lazy and vague, often leaving the version numbers blank (only 6% to 59% of the time).
- Analogy: It's like a chef who, when asked to write a recipe, says, "Use exactly 2015 vintage salt." But when asked to write a shopping list for the whole kitchen, they just write "Salt" and leave it up to you to figure out which year's salt to buy.
2. The "Expired Milk" Problem (Security Risks)
The study found that when the assistant does pick a specific version, it often picks one that is dangerous.
- The Stat: Between 37% and 56% of the time, the specific version the assistant picked had a known security flaw (a "CVE").
- The Severity: Most of these flaws were "Critical" or "High" severity.
- The Twist: These flaws weren't secret. They were public knowledge before the assistant was even trained. The assistant just didn't know to avoid them.
- Analogy: Imagine the assistant is a time traveler who always picks milk that expired three years ago. Even though the expiration date was printed on the carton years ago, the assistant keeps handing you that same expired milk, thinking it's fresh.
3. The "Convergence" Effect (Everyone Picks the Same Bad Thing)
You might think different AI models would pick different versions. They don't.
- The Finding: All ten models tested (from Google, OpenAI, Alibaba, etc.) converged on the exact same small set of risky versions. If the assistant picks "Tool X," it almost always picks "Version 2.31.0," even if newer, safer versions exist.
- Analogy: It's like if every single person in a city, regardless of their background, decided to buy the exact same pair of shoes that are known to have a broken sole. It's not a coincidence; it's a shared habit learned from the same old textbooks.
4. The "Broken Key" Problem (Compatibility)
Even if the tool isn't dangerous, it might not fit.
- The Finding: The versions the assistants picked often couldn't be installed or didn't work with the code they wrote.
- Static Check: The code wouldn't even install (like trying to put a square peg in a round hole).
- Dynamic Check: Even if it installed, the code would crash when you tried to run it.
- The Cause: The assistants love to pick very old versions of tools. These old versions rely on parts of the computer system that have been removed in modern computers.
- Analogy: The assistant writes a code that says, "Turn on the light," but it specifies a lightbulb from 1990 that requires a socket that doesn't exist in your 2026 house. The code is perfect, but the lightbulb won't screw in.
5. Why Can't We Just "Tell" the Assistant to Be Better?
The researchers tried a few things to fix this:
- The "Please Be Safe" Prompt: They told the assistant, "Please don't use versions with security holes."
- Result: It didn't work. The assistant still picked the bad versions.
- Why: The assistant isn't "forgetting" the rules; it's just not connected to a live database of safety warnings. It's like asking a student who memorized a textbook from 2023 to avoid a new law passed in 2025. They literally don't have the information in their head.
- The "External Anchor" Fix: When the researchers forced the assistant to use a pre-approved list of safe versions (like a strict shopping list provided by a human), the problems disappeared.
- Result: Security risks dropped, and the code actually worked.
The Bottom Line
The paper concludes that LLMs are great at writing the "logic" of code, but they are terrible at managing the "supply chain" of tools.
They act like a helpful but unreliable librarian who hands you a book that looks perfect but is actually a dangerous, outdated edition. You cannot trust the specific version numbers they suggest. You must treat them as a rough draft and always double-check the version numbers with a security tool before you use them.
The problem isn't that the AI is "stupid"; it's that the AI is trained on old data that makes it prefer popular-but-old versions, and it lacks a live connection to current safety warnings. Until the AI is connected to live safety tools, the human developer must be the one to check the expiration dates.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.