Imagine hiring a bright, eager developer intern to boost your team’s productivity. They deliver code at lightning speed, impressing everyone—until you discover their work relies on mysterious packages they can’t explain. Where did these dependencies come from? Why don’t they exist in any trusted repository? Sounds frightening? Well, that’s exactly the kind of nightmare scenario that can unfold when using vibe coding without robust security measures. This practice, where developers leverage AI-powered Large Language Models (LLMs) like GitHub Copilot or ChatGPT to generate code based on natural language prompts, is transforming software development. But as a groundbreaking 2024 study from the University of Texas at San Antonio and collaborators reveals, it introduces serious security risks, particularly package hallucinations. Recent research in 2025 has further exposed the persistence of these threats, coining terms like slopsquatting and highlighting real-world vulnerabilities. This article explores these evolving dangers, their implications, and practical strategies to ensure vibe coding remains a boon, not a bane.
The Rise of Vibe Coding
Vibe coding is revolutionizing programming. LLMs, trained on vast datasets from GitHub and Stack Overflow, enable developers to generate everything from Python scripts to JavaScript apps with a single prompt. The 2024 study notes that 97% of developers now use generative AI, with 30% of code being AI-generated. It’s not just about speed; it’s about accessibility. Novices can build apps, while experts streamline complex tasks.
The appeal is irresistible. Picture typing, “Build a Python web server with user authentication,” and getting functional code instantly. Tools like GitHub Copilot, embedded in IDEs, suggest code in real-time, adapting to your project. GitHub’s 2024 Octoverse report shows Copilot users complete tasks 55% faster, with 74% reporting less stress. But AI-generated code can be flawed. The 2024 study and subsequent research highlight package hallucinations as a critical threat, now amplified by the emerging slopsquatting attack vector.
Package Hallucinations: A Growing Threat to the Software Supply Chain
Package hallucinations occur when LLMs generate code referencing non-existent packages—libraries absent from repositories like PyPI or npm. The 2024 study analyzed 576,000 code samples from 16 LLMs, finding 19.7% of recommended packages were fictitious, totaling 205,474 unique hallucinated names. Commercial models like GPT-4 hallucinated less (5.2%), while open-source models averaged 21.7%. JavaScript saw higher rates (21.3%) than Python (15.8%), due to npm’s vast ecosystem.
This threat has evolved with slopsquatting, a term coined by security researcher Seth Larson to describe attackers creating malicious packages named after hallucinated ones, as noted in a 2025 report. A March 2025 study by Lasso Security analyzed 47,803 “how-to” questions across five languages (Python, Node.js, Go, .NET, Ruby) using models like GPT-4 and Gemini Pro, finding hallucination rates from 22.2% (GPT-3.5) to 64.5% (Gemini). Real-world experiments underscore the danger: an IDC report describes a dummy package with a hallucinated name uploaded to a repository, downloaded 30,000 times in weeks. Similarly, an ITPro report noted Alibaba’s GraphTranslator inadvertently recommended a hallucinated ‘huggingface-cli’ package, which was then created and downloaded uncritically.
These incidents enable package confusion attacks. Attackers upload malicious packages matching hallucinated names, which trusting developers install, introducing malware that can spread through dependency chains. The 2023 PyTorch compromise, cited in the 2024 study, affected thousands, and 245,000 malicious packages were found in 2023, per Sonatype’s report. Slopsquatting bypasses traditional typosquatting, exploiting AI trust directly.
Why Do Package Hallucinations Happen?
LLMs hallucinate due to their probabilistic design, predicting tokens based on patterns, not facts. The 2024 study identifies flawed training data, architectural limits, and inference issues like high temperature settings as causes. Models prompted with post-2023 topics hallucinated 10% more, as training data lags. Alarmingly, 43% of hallucinations were persistent, repeated across queries, making them easy targets for attackers.
Language confusion also plays a role. The 2024 study found 8.7% of hallucinated Python packages were valid JavaScript packages, indicating language misinterpretation. Semantic analysis showed only 13.4% of hallucinations resembled valid names, suggesting complex generative errors, not mere typos. A Trend Micro analysis of a hallucinated JavaScript package, ‘ts-migrate-parser’, suggests training data contamination from GitHub references, blurring the line between hallucination and data poisoning.
The Broader Security Implications
Package hallucinations are part of vibe coding’s broader risks. A 2024 IEEE Transactions on Software Engineering study found AI-generated code is 20% more likely to have vulnerabilities like SQL injection. The Center for Security and Emerging Technology (CSET) November 2024 report notes 48% of code from five popular AI models contained vulnerabilities, exacerbating risks like slopsquatting. Developers, swayed by LLM fluency, often skip scrutiny—a phenomenon called “automation bias.” The 2024 study warns that trusting LLM package recommendations heightens vulnerability.
There’s also a productivity downside. While vibe coding saves time, debugging hallucinations erases gains. The 2024 Stack Overflow Developer Survey found 62% of developers spend significant time fixing AI errors, with 28% citing dependency issues. Dark Reading reports 60% of IT leaders view AI-coding errors as “very or extremely significant”. The OWASP Top 10 for LLMs emphasizes “Overreliance” as a key risk, particularly for junior developers.
Practical Strategies to Mitigate Risks
The 2024 study tested mitigation strategies, reducing hallucinations by up to 85%, and 2025 research builds on these. Here’s how developers can apply these, alongside recent best practices:
- Leverage Retrieval-Augmented Generation (RAG): RAG uses verified data, like curated package lists. The 2024 study’s vector database of 65,000 PyPI statements cut hallucinations by 52%. Lasso Security’s 2025 study used LangChain to instruct models to admit uncertainty, though results were modest. Use tools like LangChain for real-time validation against sources like libraries.io.
- Implement Self-Refinement Loops: Models like DeepSeek and GPT-4 Turbo detected their hallucinations with 75%+ accuracy. Post-generation, prompt the LLM to verify package validity. If invalid, regenerate without the package. This cut hallucinations by 19%. DevOps.com notes this “self-regulatory capability” is underutilized but promising.
- Fine-Tune Models for Accuracy: Fine-tuning on valid package-prompt pairs reduced hallucinations by 83% for DeepSeek, though code quality dropped 26%. Use pre-fine-tuned models from Hugging Face or fine-tune for specific needs, as suggested by CSET.
- Adjust Model Parameters: Lowering temperature to 0.7 or below minimized hallucinations. Test lower temperatures for critical tasks.
- Use Static Analysis Tools: Tools like Bandit or ESLint flag suspicious dependencies. Integrate into CI/CD pipelines. Snyk offers LLM-specific scans for AI code, as recommended by Hackread.
- Educate and Verify: Train developers to verify packages on PyPI/npm or use
pipdeptree. Mend.io stresses this for junior developers. OWASP emphasizes combating “Overreliance” through education. - Monitor Emerging Threats: Track platforms like X for researcher updates. @manuelbissey’s April 2025 post highlighted hallucination risks. Subscribe to feeds from Sonatype or ReversingLabs for supply chain threat intelligence.
The Road Ahead
Vibe coding is here to stay, but its risks require vigilance. The 2024 study and 2025 research expose package hallucinations and slopsquatting as pervasive threats that could erode trust in AI-assisted development. As LLMs advance—OpenAI’s o1 and Meta’s Llama 3 (2024) promise better code generation—research must focus on hallucination mitigation, exploring tokenizer enhancements and real-time feedback. Regulatory gaps, like the EU AI Act’s lack of specific code-generation rules, underscore the need for industry-led solutions, per Hofstra’s 2024 analysis.
Developers must embrace vibe coding cautiously. By combining proven strategies—RAG, self-refinement, and verification—with modern tools, you can leverage AI safely. When an LLM suggests a new package, pause, verify, and proceed. In vibe coding’s creative chaos, skepticism is your strongest shield.




