Defend against fast-detonate supply-chain attacks.
The May 2026 TanStack compromise was live in npm for under 7 minutes. The March Axios RAT was up for about 3 hours. Anything that resolves to latest or a loose semver range during that window installs the malicious version. These configuration changes buy you a window to verify before you install. Pick the tab for your ecosystem.
Wait before installing newly-published versions
Every major Node package manager now supports a minimum release age gate: pnpm 10, npm 11.5, and Bun 1.3. Set it to 1 day at minimum, 3 days for security-sensitive projects.
Always install from a lockfile in CI
The lockfile is your audit trail. If something compromised slips in, it lands visibly in a diff, not silently via a transitive bump.
npm ci # not "npm install"
pnpm install --frozen-lockfile
yarn install --immutable
pip install --require-hashes -r requirements.txtnpm install in CI can pull a newly-published malicious version even when your lockfile says otherwise. The ci / frozen / immutable flags refuse to resolve anything outside the lockfile.Pin exact versions for dependencies you care about
Use exact pins (no ^ / ~) for high-blast-radius packages. Renovate or Dependabot still bumps them, but in PRs you can review, not silently at install time.
{
"dependencies": {
"@tanstack/react-router": "1.169.4",
"axios": "1.14.0"
}
}1.14.1. Anyone with ^1.14.0 pulled it on next install. Anyone pinned to 1.14.0 did not.Rotate CI/CD secrets to short-lived OIDC tokens
Replace long-lived NPM_TOKEN and cloud-provider keys with OIDC-issued credentials, scoped to the specific job and time-bounded.
Refuse post-install scripts for untrusted dependencies
If your project does not need any native compilation, this is free protection. If it does, allowlist only the specific packages that need a build step.
# npm
npm install --ignore-scripts
# pnpm — interactive consent
pnpm config set ignore-scripts true
# yarn 4+
yarn config set enableScripts falsepostinstall or preinstall. Disabling scripts blocks the initial execution outright. You can re-enable per-package via pnpm onlyBuiltDependencies or an allowlist.Audit packages before adoption, not after
Add a dependency-review GitHub Action to your repo to flag risky additions at PR time.
Spot something inaccurate or have a recommendation we have missed? Get in touch.