Sub topic 2
Slopsquatting, Typosquatting, and Dependency Confusion
Assume you know basic pip or npm commands, public registries, and how AI coding assistants suggest code. This chapter focuses on comparing package-name attacks and checking a package before installation.
Three package-name attacks
Slopsquatting is the registration of package names invented by language models. A developer asks for a library, receives a plausible but nonexistent name, and publishes or installs it. An attacker registers that name first. The package can then contain malicious install-time code.
Typosquatting uses a misspelled version of a real package name, such as a one-letter change. Dependency confusion abuses package-manager search rules. An attacker publishes a public package with the same name as an internal package, hoping the resolver chooses the public one.
| Attack | Name source | Main mistake |
|---|---|---|
| Slopsquatting | A model-generated name | Trusting an unverified suggestion |
| Typosquatting | A misspelling | Typing or copying the wrong name |
| Dependency confusion | An internal package name | Allowing the wrong registry to win |
Walking through the attack chain
A typical slopsquatting chain looks like this:
The attacker depends on the name looking credible. The package may execute code during installation through a build step, preinstall hook, or setup script. Later imports can also trigger harmful behavior. A package can appear harmless during a quick review while contacting an external server or reading environment variables.
Agents and automatic installation
Coding agents increase exposure when they can edit dependency files, run package managers, or retry failed installs without approval. Auto-installation removes the human pause where a name, owner, and source should be checked. Generated code also spreads the same invented name across repositories, making it more valuable to register.
Checking before installation
Confirm the exact package name on the intended registry. Check its publisher, repository, release history, documentation, and dependency changes. A new package with no credible source or history deserves extra scrutiny.
python -m pip index versions PACKAGE_NAME
npm view PACKAGE_NAME time
npm view PACKAGE_NAME repositoryPrefer an existing lockfile and review dependency-file changes. Install in a disposable environment first, with network access restricted where practical. For npm, use npm ci with ignore-scripts when lifecycle scripts are unnecessary. For Python, use hash-pinned requirements and require-hashes mode.
Exercise
Which attack registers a package name that an AI assistant invented?
Show answer
Slopsquatting. Verify the name and its publisher before installing it.