Key takeaways
Attackers register package names that AI tools invent, then wait for installs.
An install can run code on your machine, so a bad package is more than a bad import.
Verify that a package exists and is what you expect before installing it.
Commit lockfiles, install from them, and review dependency changes like code.
Limit what a malicious install could reach, such as secrets and credentials.
You ask your AI assistant for a quick way to sanitize some JSON. It writes a tidy snippet, adds import { sanitize } from "fast-json-sanitize" at the top, and tells you to run npm install fast-json-sanitize . The code looks right. The name sounds right. There's just one problem: nobody ever published that package.
Language models predict plausible text, and a plausible package name is just text. Sometimes the name they produce belongs to a real, well-known library. Sometimes it's a convincing invention.…