skills/hallucinated-packages-anti-pattern/SKILL.md
Security anti-pattern for hallucinated (non-existent) packages (CWE-1357). Use when generating or reviewing AI-assisted code that imports packages, dependencies, or libraries. CRITICAL AI-specific vulnerability with 5-21% hallucination rate. Detects dependency confusion and slopsquatting risks.
npx skillsauth add igbuend/grimbard hallucinated-packages-anti-patternInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Severity: Critical
AI models hallucinate non-existent software packages at rates of 5-21%. Attackers exploit this through slopsquatting: registering hallucinated package names with malicious code. Developers installing AI-suggested packages without verification execute attacker code, leading to malware execution, credential theft, and system compromise. This AI-specific supply chain attack exploits the trust gap between AI suggestions and package verification.
Never install AI-suggested packages without verifying existence, legitimacy, and reputation in official registries.
# An AI model generates the following code snippet and instruction:
# "To handle advanced image processing, you should use the `numpy-magic` library.
# First, install it using pip:"
#
# $ pip install numpy-magic
import numpy_magic as npmagic
def process_image(image_path):
# The developer assumes `numpy-magic` is a real, safe library.
# However, it doesn't exist, and an attacker has registered it on PyPI.
# The moment it was installed, the attacker's code ran.
# The import itself could also trigger malicious code.
processed = npmagic.enhance(image_path)
return processed
In this scenario, the developer follows the AI's instructions without question. The numpy-magic package is not a real library. An attacker, anticipating this hallucination, has published a malicious package with that exact name. The developer's pip install command downloads and executes the attacker's code, compromising their machine and potentially the entire project.
# SECURE: Verify the package before installing.
# Before installing `numpy-magic`, the developer performs a few checks.
# 1. Search for the package on the official repository (e.g., PyPI, npm).
# A search for "numpy-magic" on PyPI yields no results or shows a package
# with very low downloads and a recent creation date. This is a major red flag.
# 2. Look for signs of legitimacy.
# - Does the package have a link to a GitHub repository?
# - Is the repository active?
# - How many weekly downloads does it have? (Is it in the single digits or thousands?)
# - Who are the maintainers?
# - Are there any open issues or security advisories?
# 3. Search for the *functionality* instead of the package name.
# A search for "advanced numpy image processing" leads to well-known libraries
# like `scikit-image`, `OpenCV (cv2)`, or `Pillow (PIL)`, which are reputable.
# The developer chooses a legitimate, well-known library instead.
from skimage import io, filters
def process_image(image_path):
image = io.imread(image_path)
# Use a function from a verified, reputable library.
processed = filters.gaussian(image, sigma=1)
return processed
JavaScript/Node.js:
// VULNERABLE: AI suggests non-existent package
// AI: "Install express-jwt-secure for enhanced JWT security"
// $ npm install express-jwt-secure
const jwtSecure = require('express-jwt-secure'); // Malicious package!
app.use(jwtSecure.protect());
// SECURE: Verify before installing
// 1. Check npm: $ npm view express-jwt-secure
// Result: "404 Not Found" - hallucination detected!
// 2. Search for real alternatives: "express jwt authentication"
// 3. Use verified packages with high download counts
const jwt = require('jsonwebtoken'); // 20M+ weekly downloads
const expressJWT = require('express-jwt'); // 1M+ weekly downloads
app.use(expressJWT({
secret: process.env.JWT_SECRET,
algorithms: ['HS256']
}));
Java/Maven:
<!-- VULNERABLE: AI suggests non-existent dependency -->
<!-- AI: "Add apache-commons-cryptography for encryption" -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-cryptography</artifactId>
<version>1.0.0</version>
</dependency>
<!-- SECURE: Verify on Maven Central first -->
<!-- Search: https://search.maven.org/search?q=commons-cryptography -->
<!-- No results - hallucination! -->
<!-- Real alternative: Apache Commons Crypto -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-crypto</artifactId>
<version>1.2.0</version>
</dependency>
pip index versions <package-name> or visit pypi.orgnpm view <package-name> or visit npmjs.compip search or fuzzy matching toolsnpm view <package> time created dist-tags downloadsnpm audit / pip-audit for known vulnerabilitiessocket.dev for AI hallucination detectionosv-scanner for supply chain riskspackage-lock.json, Pipfile.lock, yarn.lock) to ensure that you are always installing the same version of a dependency.development
Security anti-pattern for Cross-Site Scripting vulnerabilities (CWE-79). Use when generating or reviewing code that renders HTML, handles user input in web pages, uses innerHTML/document.write, or builds dynamic web content. Covers Reflected, Stored, and DOM-based XSS. AI code has 86% XSS failure rate.
development
Security anti-pattern for XPath injection vulnerabilities (CWE-643). Use when generating or reviewing code that queries XML documents, constructs XPath expressions, or handles user input in XML operations. Detects unescaped quotes and special characters in XPath queries.
development
Security anti-pattern for weak password hashing (CWE-327, CWE-759). Use when generating or reviewing code that stores or verifies user passwords. Detects use of MD5, SHA1, SHA256 without salt, or missing password hashing entirely. Recommends bcrypt, Argon2, or scrypt.
development
Security anti-pattern for weak encryption (CWE-326, CWE-327). Use when generating or reviewing code that encrypts data, handles encryption keys, or uses cryptographic modes. Detects DES, ECB mode, static IVs, and custom crypto implementations.