TL;DR
Large Language Models (LLMs) frequently suggest specific library versions that are outdated, incompatible, or riddled with known security vulnerabilities. This paper introduces PinTrace, a benchmark of 1,000 tasks, to reveal that LLM-generated code carries a "version-level risk" where models systematically converge on a small set of risky dependencies, often ignoring critical CVEs disclosed long before their training cutoffs.
What Problem Does This Paper Address?
As AI coding assistants like GitHub Copilot and Claude Code become standard in developer workflows, we’ve focused heavily on whether the logic they generate is secure (avoiding SQL injection, etc.) or if they hallucinate non-existent packages. However, there is a third, overlooked risk surface: version selection.
Even if an LLM generates functionally correct code using a real library, it often "pins" a specific version (e.g., cryptography==41.0.3). If that version is vulnerable or incompatible with the user's environment, it creates a silent supply chain risk. The authors argue that because LLMs are trained on massive web crawls, they develop a "systemic bias" toward older, popular versions that have had more time to accumulate unpatched vulnerabilities.
Methods
The researchers evaluated 10 prominent LLMs (including GPT-5.4, Claude-Sonnet-4.6, and DeepSeek-V3.2) using a five-stage analysis pipeline:
- Generation: Models generate code under two modes: Inline (version comments in code) and Explicit (generating a
requirements.txt). - Extraction & Validation: Version identifiers are parsed and checked against the PyPI registry to ensure they actually exist.
- Vulnerability Check: Valid versions are cross-referenced with the Open Source Vulnerability (OSV) database to identify known CVEs and their severity.
- Compatibility Check: The team performed both static type checking and dynamic execution (using isolated virtual environments) to see if the suggested versions actually work with the generated code and modern Python runtimes.
Datasets
- PinTrace: A new, curated benchmark introduced in this paper. it consists of 1,000 real-world programming tasks derived from Stack Overflow (2020–2026), balanced to ensure a diverse range of third-party libraries (TPLs).
- BigCodeBench: Used to provide ground-truth test suites for dynamic execution verification.
- OSV Database: The source for mapping library versions to specific CVE records.
Key Insights and Ideas
- Format Over Intent: LLMs don't specify versions because of engineering wisdom; they do it because the prompt format makes it look "natural." In inline mode, models specified versions up to 95% of the time, but dropped as low as 6% when asked for a
requirements.txt. - The Salience-Vulnerability Coupling: There is a structural lag. Models prefer versions that appear most frequently in their training data. These "high-salience" versions are typically 9 to 31 months old, meaning they are old enough to have well-documented (and often critical) vulnerabilities.
- Systemic Convergence: This isn't a random "hallucination" problem. Different model families (OpenAI, Anthropic, Alibaba) all converged on the exact same set of risky versions (e.g.,
django==6.0.1), suggesting the bias is baked into the common training data used across the industry. - Grounding, Not Safety: Most CVEs in the suggested versions were public before the models' knowledge cutoffs. The models "know" about the vulnerabilities in the abstract but fail to map that knowledge to specific version strings during code generation.
Key Results
- High Vulnerability Exposure: Between 36.7% and 55.7% of tasks contained at least one version with a known CVE. Shockingly, 62%–74% of these were rated as Critical or High severity.
- Compatibility Collapse: Suggested versions frequently failed to install or run. Dynamic pass rates collapsed to between 6.5% and 48.6% in inline mode.
- Root Cause: A diagnosis experiment proved these failures were due to the version choice itself, not bad code logic. Swapping the LLM's choice for a "neighboring" version often fixed the errors.
- Mitigation Limits: Simply telling the LLM "don't use vulnerable versions" (prompt engineering) provided almost no improvement. However, external version anchoring (injecting known-safe versions into the prompt) significantly reduced risk.
Limitations and Future Work
The study is currently scoped to the Python/PyPI ecosystem. While the authors suspect similar risks exist in npm (JavaScript) or Cargo (Rust), the specific exposure rates and failure patterns might differ. Additionally, the study focused on single-turn generation; future work could explore how "agentic" workflows or multi-turn refinements affect version-level risks.
The authors conclude that developers should treat LLM-specified versions as unverified suggestions and always route them through Software Composition Analysis (SCA) tools before deployment.
Summary updated