New Two-Layer Detector Spots 'Slopsquatting' Attacks from AI-Hallucinated Python Package Names
Summarized by AI from reporting by ArXiv cs.CL, published under our editorial policy.
Researchers propose a two-layer detector that catches 'slopsquatting' attacks, where AI coding assistants hallucinate non-existent Python package names that adversaries can pre-register on PyPI to compromise the software supply chain.

Key takeaways
- Slopsquatting occurs when a code-generating language model fabricates a Python package name that an adversary has pre-registered on PyPI, enabling a supply chain compromise.
- The proposed detector uses a first layer that performs a deterministic PyPI existence check and a second layer that is a Random Forest classifier trained on ten features from the package name and its PyPI metadata.
- An import name reconciler bridges the two detection layers, resolving cases such as 'import cv2' where the package name is a common alias.
Researchers have proposed a two-layer detector designed to catch 'slopsquatting,' a security vulnerability that arises when a code-generating language model fabricates a Python package name. An adversary who has pre-registered that name on the Python Package Index (PyPI) can convert the hallucination into a supply chain compromise.
How Slopsquatting Turns AI Hallucinations Into Supply Chain Attacks
Slopsquatting occurs when a code-generating language model (like those used in AI coding assistants) invents a package name that doesn't exist. If a hacker has already registered that name on PyPI, they can distribute malicious code when users try to install the suggested package. For example, if an AI suggests 'import fakepackage' and a hacker has registered 'fakepackage' on PyPI, users might unknowingly install harmful software.
The Two-Layer Detection System: PyPI Check Plus Random Forest Classifier
The researchers propose a two-layer detector to counter this issue. The first layer performs a deterministic PyPI existence check, verifying whether the suggested package name is registered. The second layer is a Random Forest classifier trained on ten features derived from the package name and its PyPI metadata. These features include the package's name structure, metadata, and other indicators of potential malicious intent. An import name reconciler bridges the two layers, resolving cases such as 'import cv2' where the name might be a common alias.
Why This Matters for Developers Using AI Coding Assistants
For developers using AI coding assistants, this research highlights a hidden risk in AI-generated code. While these tools can speed up coding, they can also suggest non-existent or malicious package names. This tool helps developers catch these risks before they become security issues. It's particularly important for open-source projects and individual developers who rely on AI to generate or suggest code snippets.
Practical Steps to Protect Against Slopsquatting Today
If you use AI coding assistants, you can start by manually verifying any package names suggested by the AI. Check if the package exists on PyPI and look for any red flags in the package's metadata. Additionally, you can stay updated on the latest security tools and practices to protect your projects. For now, there isn't a publicly available tool based on this research, but keeping an eye on developments in this area can help you stay ahead of potential risks.
Frequently asked
- What is slopsquatting?
- Slopsquatting is a security risk where AI-generated code suggests non-existent package names that hackers can pre-register on PyPI to distribute malicious software.
- How does the new tool detect slopsquatting?
- The tool uses a two-layer system: a PyPI existence check and a Random Forest classifier trained on package name and metadata features.
- Is there a publicly available tool based on this research?
- As of now, there isn't a publicly available tool based on this research, but developers can manually verify package names suggested by AI coding assistants.