CheatSheetSeries icon indicating copy to clipboard operation
CheatSheetSeries copied to clipboard

Update: NPM Security Cheat Sheet

Open cryptostrapon opened this issue 3 days ago • 0 comments

What is missing or needs to be updated?

The section on checking an untrusted repository recommends npm install --ignore-scripts. On npm 10 the flag does not cover dependencies installed from git: npm still runs a git dependency's prepare script while it packs it (npm docs). npm 11 skips it since npm/pacote#407 ("honors ignoreScripts option to prevent prepare lifecycle script", released in pacote 20.0.0); npm 10 ships pacote 19.

I reproduced this with a local git+file: dependency whose prepare writes a marker file. On npm 10.9.9 the marker appears with --ignore-scripts and with ignore-scripts=true in the project .npmrc. On npm 11.21.3 it does not. npm 10 is still the version bundled with Node 22, so many readers who follow the current advice are not covered for git dependencies. I also opened npm/cli#10409 to add a note to the npm 10 docs.

How should this be resolved?

Add one sentence after the --ignore-scripts recommendation in that section: on npm 10 and earlier the flag does not stop a git dependency's prepare script, with links to the npm docs and npm/pacote#407, and a short line to treat git dependencies as code that will run. No other changes.

If this is approved, I will open a pull request for this single file that references this issue.

AI disclosure: an AI tool (Claude) helped draft this text. The npm behavior was reproduced and checked manually.

cryptostrapon avatar Dec 03 '26 18:12 cryptostrapon