chore: add .npmrc to disable npm lifecycle scripts#38
Merged
Conversation
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.
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.
Summary
Adds
.npmrcwithignore-scripts=truenext totypescript/package-lock.jsonto prevent dependencies from running arbitrarypreinstall/install/postinstalllifecycle scripts duringnpm 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
typescript/.npmrccontainingignore-scripts=true.If a dependency needs lifecycle scripts
If any dependency (e.g.
esbuildviatsup) turns out to require a lifecycle script to function, we can selectively re-enable it with @lavamoat/allow-scripts:This adds a
lavamoat.allowScriptsallowlist topackage.json. CI then becomes:Test plan
typescriptjob (npm ci,npm run typecheck,npm run build) passespythonjob is unaffected