You Asked for 12 Packages and Installed 175: What a Dependency List Actually Costs

The same four features needed twelve libraries one way and one the other. The install step ran code from two of them before we had read anything at all.

Asking for login, a database, file uploads and e-mail from libraries meant twelve direct dependencies and one hundred and seventy-five installed packages taking forty-four megabytes with two running their own code during the install, while the same four features against a backend meant one direct dependency and ten packages, and an install script that ran before any project code could read three credential-shaped environment variables until npm install was given ignore-scripts

You asked for four ordinary things: let people sign in, store some data, accept an upload, send an e-mail. The assistant produced a dependency list and the list worked.

Every package you install is a set of strangers whose code runs on your machine, and the install step runs some of it before you have read anything. The number of strangers is not the number of lines in your dependency list.

So we built those four features twice — once from libraries, once against a backend that already has them — and counted what each one actually installed.

Watch it instead

Dependencies that should not be there is number 9 in our countdown of the security holes that turn up most often in apps built with AI.

Video: 31,000 AI-Built Apps Scanned: The 10 Security Holes That Actually Get You Hacked.
Watch it instead 31,000 AI-Built Apps Scanned: The 10 Security Holes That Actually Get You Hacked.
From the Back4app channel. This guide is the long version of its ninth position. Open on YouTube →

How much code did each version install?

Fourteen times as much, for the same four features:

The same four features built two ways and counted from the lockfile: assembled from libraries it was twelve direct dependencies, 175 installed packages, 44 megabytes and two packages running their own code during the install, while against a backend that already has them it was one dependency, ten packages, 24 megabytes and one install script

Neither row is zero on that last column, and that is deliberate. The honest claim is not that one approach is safe — it is that one of them asks you to trust a hundred and seventy-five sets of maintainers and the other asks for ten.

How we measured: npm install inside node:22-alpine, with every count read from the generated lockfile rather than the dependency list, and install scripts detected by reading each installed package’s own manifest. Identical across two clean runs — the lab is in the repo.

What can a package do while it is installing?

Anything your shell can, and this is the part most people have never watched happen. We wrote a package whose only content is an install hook:

// Stack: npm | File: package.json
{ "name": "a-package-you-did-not-read", "scripts": { "postinstall": "node postinstall.js" } }

Then installed it into an environment shaped like a real laptop or a real build:

npm install                       it ran
  it ran, before any of your own code did
  environment variables it could read that look like credentials: 3
    GITHUB_TOKEN, PROVIDER_API_KEY, DATABASE_PASSWORD
  it also had the network, the file system, and your shell
npm install --ignore-scripts      it did not run

Nothing imported that file. It ran because installing is an action, not a download.

The flag works, and it is not free. Packages that compile native code or fetch a platform binary genuinely need those scripts — bcrypt and sharp, the two in our own list, are exactly that kind — so turning it on globally means allowing those back one at a time.

Why do invented package names matter?

Because the names are available, which is the entire precondition. A USENIX Security 2025 study generated 576,000 code samples from sixteen models and collected 205,474 unique package names that do not exist — and a large share of them recurred when the same prompt was run again.

Recurrence is what turns a mistake into an attack. A name that appears once is noise; a name that appears every time is a target somebody can register and wait on.

We checked eight plausible-looking names against the live registry, constructed here by hand from the shapes that get confused with real ones — a scope added or dropped, a plural, a hyphen. These were not harvested from a model, and the lab does not claim they were:

express-session           200         exists
expresssession            404         nobody owns this name
express-sessions          200         exists
@express/session          404         nobody owns this name
node-bcrypt               200         exists
bcrypt-js                 404         nobody owns this name
mongoose-client           200         exists
nodemailer-smtp           200         exists

Three of eight are unclaimed. Each one is a name an attacker can take this afternoon and publish anything under, including the install script from the section above.

Four features, two dependency lists
175packages installed from twelve you asked for
→
10for the same four features, against a backend
3 of 8plausible package names nobody has registered yet
Measured with npm in node:22-alpine on Docker 29.4.3, 29 October 2026, counted from the lockfile. Registry checks against the live npm registry. Identical across two clean runs.

What should you check before adding a package?

Three things, in under a minute, and the order matters. Does it exist with real download numbers — not a 200, actual traffic. Does the repository it links to exist and contain the code. Does a human maintainer appear anywhere.

A hallucinated name fails the first check instantly. A squatted name usually passes the first and fails the other two, because the attacker has downloads from people who already fell for it and nothing else.

Then commit your lockfile. It is the only record of exactly which versions you reviewed, and without it the next install can resolve to something you have never seen.

When is a long dependency list the right answer?

When the alternative is writing those libraries yourself, which is almost always worse. A hand-rolled password hash, a hand-rolled image resizer and a hand-rolled e-mail sender are three ways to have a bad week, and the measurement in our login comparison shows exactly how that goes.

The argument here is not against libraries. It is that four capabilities assembled from twelve libraries and four capabilities that arrive together are different amounts of trust, and only one of those numbers is usually looked at.

There is also a real cost on the other side worth stating plainly. Depending on a backend concentrates your risk rather than removing it: one provider instead of a hundred and seventy-five maintainers is fewer strangers and a larger single point of failure, which is a trade you should make on purpose rather than by accident.

What is worth running right now?

Open your project and count the packages in your lockfile, not the ones in your dependency list. On most projects the second number is a rounding error against the first, and seeing the gap once changes how the next dependency gets added.

Then list which of them run code at install time. If that number is not zero — and it will not be — you now know how many strangers get to run something on your build machine before your tests do.

Tagssecuritydependenciesnpmsupply-chainai-codingvibe-coding

Frequently asked questions

How many packages does npm install actually install?

Far more than you listed. We asked for twelve libraries covering login, a database, file uploads and e-mail; the lockfile afterwards listed 175 packages taking 44 MB. The same four features against a backend that already has them came to one direct dependency and ten packages.

Can an npm package run code when you install it?

Yes, and that is a documented feature rather than an exploit. A package can declare install, preinstall or postinstall scripts, and npm runs them. Ours ran before any of our own code, with three credential-shaped environment variables, the network and the file system in reach.

Does npm install --ignore-scripts make installing safe?

It stops that specific mechanism and it has a cost. With the flag, our package's install script did not run at all. But packages that compile native code or download a binary at install time genuinely need those scripts, so the flag breaks some of them and you have to allow those individually.

What is slopsquatting and why does it work?

It is registering a package name that AI assistants invent, so the next person who follows the suggestion installs the attacker's code. It works because the names are free: of eight plausible names we checked against the live registry, three were unregistered and could be claimed by anyone today.

Do AI coding assistants really suggest packages that do not exist?

A USENIX Security 2025 study generated 576,000 code samples from sixteen models and found 205,474 unique package names that do not exist. The detail that makes it exploitable is repetition: a large share of those names came back on every rerun of the same prompt, so an attacker can predict which to register.

How do I reduce the number of dependencies I have to trust?

Prefer capabilities you do not have to assemble. Login, storage, a database and e-mail are four separate libraries in one version of this and one client in the other, which is the difference between 175 packages and 10 — not because libraries are bad, but because each one is another set of maintainers.

Further reading

Reviewed & verified by Back4app Engineering, Editorial review at Back4app

Tested Oct 29, 2026 — Local: Docker 29.4.3 on macOS, arm64 · npm in node:22-alpine · npm registry, live · Node 22.21.1.

More from Back4app Engineering

AI Agent · conceptual

Two Kinds of AI Agent: One Builds the App, One Operates the Backend

Containers · error-guide

Why Your App Works Locally and Crashes When You Deploy It [Full Repo]

AI Agent · tutorial

How to Install and Run the BMAD Method in an AI Editor [Artifacts Included]