Skip to content

chore: add .npmrc to disable npm lifecycle scripts#38

Merged
pjb157 merged 1 commit into
mainfrom
chore/npmrc-ignore-scripts
Apr 30, 2026
Merged

chore: add .npmrc to disable npm lifecycle scripts#38
pjb157 merged 1 commit into
mainfrom
chore/npmrc-ignore-scripts

Conversation

@imparandodev
Copy link
Copy Markdown

@imparandodev imparandodev Bot commented Apr 30, 2026

Summary

Adds .npmrc with ignore-scripts=true next to typescript/package-lock.json to prevent dependencies from running arbitrary preinstall/install/postinstall lifecycle scripts during npm install.

This is a mitigation for a recurring class of npm supply chain attacks (e.g. the 2025 "Shai-Hulud 2.0" worm — Wiz Research / Datadog Security Labs). With lifecycle scripts disabled, a compromised dependency cannot execute on developer machines or in CI at install time before it has a chance to be detected.

What changes

  • New file: typescript/.npmrc containing ignore-scripts=true.

If a dependency needs lifecycle scripts

If any dependency (e.g. esbuild via tsup) turns out to require a lifecycle script to function, we can selectively re-enable it with @lavamoat/allow-scripts:

npm i -D @lavamoat/allow-scripts
npx --no allow-scripts setup
npx --no allow-scripts auto

This adds a lavamoat.allowScripts allowlist to package.json. CI then becomes:

npm ci && npx --no allow-scripts

Test plan

  • CI typescript job (npm ci, npm run typecheck, npm run build) passes
  • CI python job is unaffected

Add an .npmrc with ignore-scripts=true next to typescript/package-lock.json
to prevent dependencies from running arbitrary preinstall/install/postinstall
scripts during npm install. This mitigates supply chain attack vectors such
as the 2025 "Shai-Hulud 2.0" npm worm by reducing the chance that a
compromised dependency executes before it is detected.

If specific dependencies later require lifecycle scripts (e.g. esbuild),
we can opt them in via @lavamoat/allow-scripts.
@pjb157 pjb157 merged commit bb73b8b into main Apr 30, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant