In the last lesson, you cut a link in the attack chain with your agent’s settings. A package your agent asks to install is another way in. It’s someone else’s code, and it can run on your machine the moment you approve.
You’ve vetted packages before with four checks: Is it needed? Is it the package you meant? Is it widely used? Is it current? Here, you’ll see why a name your agent suggests can be wrong in a way the install won’t reveal, and check it against npm’s registry before you approve.
See Why a Package Name Can Be Wrong
The package name in an install request is text the model predicted from its training data, like the code it writes, so it can be wrong. Usually it’s a real, popular package. Sometimes it was never published, or it’s a letter away from a popular one.
Attackers turn either mistake into a way in. They find names models tend to invent, register them on npm, and publish their own code under them. That’s slopsquatting, named after typosquatting, which bets on a person’s typo instead. Once the name is registered, the install succeeds, so success doesn’t tell you whose package you got.
A package’s package.json can list install scripts under preinstall, install, and postinstall in its scripts block. npm runs them during the install, with the same access as the install command. The package you’re installing can bring along others with their own install scripts. So checking a package after it’s installed is too late.