By the end of this lesson you will spot fake packages before they are installed, run npm audit, keep your test and live databases apart, and approve risky commands one at a time.
You need: a JavaScript project (with a package.json file) and your coding agent · Time: 7 minutes
A package is ready-made code that your app downloads from the internet, like a recipe you did not write. The AI adds packages all the time with
npm install some-name.The problem: AI models sometimes invent package names that sound right but do not exist. A large study tested 16 code models on 576,000 code samples and found:
- 19.7% of suggested packages did not exist.
- Open models invented packages far more often (about 21.7%) than commercial ones (about 5.2%).
- Over 205,000 different fake names appeared, and 43% of them came back every time the same prompt was repeated ten times.
That repetition is the danger. An attacker can register the invented name with harmful code inside and wait for an AI to recommend it. This is called slopsquatting. (Socket on the study)
Why?A harmful package runs on your computer and in your app, with access to your files and keys. Checking a name takes one minute. Cleaning up after a bad package can take days.
Log in free to read the rest of this lesson
Every lesson is free. A free account unlocks all of them and saves your progress.
Still to come in this lesson:
- Check a package before you install it
- Run npm audit
- Keep test and live databases apart
- Approve commands one by one
- Back up before every migration
- Recap