Drop netlify-cli from the dependency tree - #131
Merged
Conversation
CVE-2023-45133 (arbitrary code execution in @babel/traverse) was reported against this repo in #130. The vulnerable package was real — 7.16.3, fixed in 7.23.2 — but it arrived four levels down through netlify-cli, which was pinned at ^6.14.7 while current is 27.x, and sat in `dependencies` despite being used by exactly one script for local dev. netlify-cli accounted for 1987 of the 2176 packages in the lockfile. 91% of the dependency graph, installed on every CI run and every deploy, to support `npm start` on a developer's laptop. `npm start` now calls `npx netlify dev`, which fetches it on demand. Upgrading in place was tried first and does not work at Node 20: netlify-cli 27 requires Node >= 22.13, and 26 — the newest line that supports Node 20 — pins @opentelemetry/api ~1.8.0 against vitest's ^1.9.0, which npm cannot resolve. Also removes `ai@^3.0.18`, which nothing imports. packages 2176 -> 135 lockfile 24706 -> 2047 lines audit 6 vulnerabilities (4 high) -> 2 low @babel/traverse is gone from the tree entirely, so the reported CVE is resolved at the source rather than pinned around. The 2 remaining advisories are vue, reached through aalib.js, which renders the terminal's ASCII art and has no maintained alternative — that needs its own decision. The tradeoff is that the CLI version is no longer pinned. For a tool that only runs `netlify dev` against a static site, and never in CI or the deploy, that is worth 94% of the dependency graph. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces #130, which reported CVE-2023-45133 (arbitrary code execution in
@babel/traverse).The report was right; the patch wasn't
@babel/traverse@7.16.3really was in our tree, and the CVE is genuinely fixed in 7.23.2. But #130 addedoverridestopackage.jsonwithout regeneratingpackage-lock.json, andoverridesonly affects resolution duringnpm install. CI runsnpm ci, which installs strictly from the lockfile — so the vulnerable version would have kept installing unchanged.The actual problem
@babel/traversearrived four levels down throughnetlify-cli, which was:^6.14.7while current is27.xdependencies, notdevDependenciesnpm start, for local devAll of that installed on every CI run and every Netlify deploy, to support running
netlify devon a laptop.Why not just upgrade it
Tried that first; it doesn't work at Node 20:
>=22.13.0, and CI +netlify.tomlare pinned to Node 20. Bumping Node is a production build change, not a dependency cleanup.@opentelemetry/api@~1.8.0, which collides with vitest's^1.9.0. npm can't resolve it without--legacy-peer-deps, and baking that into how everyone installs is worse than the disease.What this does instead
npm startcallsnpx netlify dev, fetching the CLI on demand. Also removesai@^3.0.18, which nothing imports — I grepped forrequire("ai"),from "ai", and@ai-sdkand there are no hits.npm audit@babel/traverseis gone from the tree entirely, so the CVE is resolved at the source rather than pinned around.npm audit fixcleared the remaining high-severity advisories (nanoid, postcss, undici).What's left
2 low-severity advisories for
vue, reached throughaalib.js— the library that renders the terminal's ASCII art. It's unmaintained and there's no drop-in replacement, so that needs its own decision rather than a quiet bump.Tradeoff
The CLI version is no longer pinned, so
npxwill fetch whatever is current. For a tool that only runsnetlify devagainst a static site, and never runs in CI or during the deploy, that seems worth 94% of the dependency graph. If you'd rather pin it, the alternative is a global install documented in the README.Test plan
npm installfrom a cleannode_modulesnpm test— 95/95npm run build—dist/identical in shape@babel/traverseandnetlify-cliare both absent from the regenerated lockfile🤖 Generated with Claude Code