I ran the same swapped install twice, once plain and once under CI=true, expecting the CI run to refuse it. It did not. Same exit code, same bytes, same rewritten lockfile. CI=true changed nothing, and that non-result is the point of this piece: the environment variable is not a stricter mode, and the lockfile is not a control. The check that catches the swap lives elsewhere, and this run names it.

The tree is the Dec 4 D1 state, the one Friday's run proved installs the attacker's bytes silently: package.json points at repo B and its commit, while the lockfile still says repo A. No integrity field on either, because npm never writes one for a git dependency. Node v24.22.1, system npm 10.9.4, every install on its own fresh cache. sunnatulla_dev asked whether the npm ls --json against resolved diff catches the swap, and whether the local run's only signal really is the lockfile diff.

Plain npm install CI=true npm install
Exit 0 0
Installed bytes B (GIT-B-MARKER) B (GIT-B-MARKER)
Prepare script ran (PREPARE-B-RAN) ran (PREPARE-B-RAN)
npm output added 1 package, no mention of the swap identical, no mention of the swap
Lockfile after rewritten to repo B rewritten to repo B

Both installs take the attacker's bytes and run the attacker's prepare script, and both rewrite the lockfile to match what they installed. The output says nothing about the swap in either case. That is the whole answer to the second question: yes, the local run's only signal really is the lockfile diff, and the install destroys it. After a plain install, nothing on disk disagrees with anything. npm ls reports repo B, the lockfile says repo B, package.json says repo B. The only trace that a swap happened is the difference between the lockfile before the install and the lockfile after it, a git diff on the committed copy. If the lockfile is not under version control, or nobody diffs it, there is no signal left anywhere.

The npm ls diff catches the swap, but only in one narrow window.

Comparison Installed resolved Lockfile resolved Verdict
npm ls vs post-install lockfile repo B repo B no catch, they agree
npm ls vs pre-install lockfile repo B repo A catch, they differ

Before any install there is nothing to compare at all: npm ls --json on the uninstalled tree exits 1, missing, and reports only a required field, no resolved. After an install, the diff works only against the lockfile as it was before the install, the committed copy. Run it after a plain install against the lockfile on disk and it reports clean, because npm already rewrote that lockfile to match what it installed. A pipeline that installs first and diffs second runs its check after the evidence is gone. A pipeline that diffs the lockfile against the committed copy before installing sees the swap in the diff itself, which is the same lockfile-diff signal, not a new one. npm ls adds nothing to it.

pnpm's --frozen-lockfile is the comparison that already catches it. pnpm 12.26.0, installed locally in the run folder, nothing global. The original-state project, package.json pointing at repo A, installs cleanly and generates pnpm-lock.yaml. Swap package.json to repo B, keep the original lockfile, and run pnpm install --frozen-lockfile:

Error: ERR_PNPM_OUTDATED_LOCKFILE Cannot install with "frozen-lockfile" because pnpm-lock.yaml is not up to date with package.json. Failure reason: specifiers in the lockfile don't match specifiers in package.json: * gitdep-pkg (lockfile: git+file://…repo-a#c48c56…, manifest: git+file://…repo-b#7698c3…) 

Exit 1. Nothing is installed. The tree still holds A. pnpm names the exact mismatch, lockfile repo A against manifest repo B, before installing anything. The frozen lockfile is a control: package.json and the lockfile must agree before anything is installed. npm's lockfile is a record npm rewrites to match what it did.

pnpm has a second gate npm lacks here, and it showed up before the frozen check could even run. The first pnpm install on the original tree failed with ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED: a git-hosted package needs to run build scripts and is not on the allowBuilds allowlist. The dep had to be allowlisted before its prepare script would run at all. So pnpm stops the attacker's prepare script even if the swap gets through, and the frozen lockfile stops the swap itself. Two gates, where npm has neither.

Two things this run did not do. The pacote-bump-on-npm-10 arm was not re-run: Dec 5 already proved it infeasible as a drop-in swap, pacote 21 cannot even load in the npm 10 tree, and cryptostrapon confirmed they only tested npm as shipped. And only git+file:// dependencies were tested here; a git+https:// dep goes through the same npm code paths, but that was not run.

The claim, then: on npm, the lockfile is a record, not a control. CI=true does not make it one. npm ls does not make it one after the install has rewritten it. The check that catches the swap is a frozen lockfile, enforced before anything installs, and on npm that check lives elsewhere.

The full numbers behind this one are in the AheadKit guides. Everything I write here stays free, that part doesn't change. — Salam

More from AheadKit: programming books, packs and AI tools. Each page lists exactly what's inside before you pay.