chore: pnpm onlyBuiltDependencies allow-list (supply-chain hardening)#17
Merged
Conversation
Locks postinstall script execution to a known set of packages. Without this, pnpm 9.15 still defaults to running postinstall scripts of any package added to the tree — the vector behind the May 2026 Mini Shai-Hulud / @AntV / TanStack / node-ipc supply-chain attacks (each shipped a credential-stealing payload via postinstall). The list covers what genuinely needs native builds: sharp (image processing in web-preview), esbuild (Vite/vitest internal), fsevents (mac file watcher), @vitest/mocker. The @img/sharp-* variants are listed by platform because pnpm resolves a different one on Linux CI vs macOS dev vs Windows. Any new dep added later that ships a postinstall script will be deferred by pnpm until it's added to this list — forcing a conscious review before arbitrary code runs at install time. CI's --frozen-lockfile already prevents fresh-compromised versions from reaching the runner before they're flagged in the GitHub Advisory Database; this is the second layer for the case where an advisory hasn't landed yet. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0249271 to
a11d910
Compare
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
Locks postinstall script execution to an explicit allow-list. Without this, pnpm runs the postinstall script of any package in the tree — which is the vector behind every npm supply-chain attack in the May 2026 wave:
@tanstack/*packagesecharts-for-reactEven though
pnpm auditis currently clean for this repo (none of the affected packages are installed transitively), the vector itself is open until we restrict it.How it works
pnpm.onlyBuiltDependenciesinpackage.jsonwhitelists which packages may run install scripts. Any new dep with a postinstall script will be deferred by pnpm until it's added to this list — forcing a conscious review before arbitrary code runs.Allow-list contents
sharp+@img/sharp-*(per-platform variants)esbuildfsevents@vitest/mockerThe
@img/sharp-*are listed by platform (darwin-arm64 / linux-x64 / win32 / etc.) because pnpm resolves a different optional dep on each platform.Defense in depth
This sits alongside the protections already in place:
--frozen-lockfilein CI — fresh-compromised versions can't reach the runner without a Dependabot PRTest plan
rm -rf node_modules && pnpm install --frozen-lockfile) succeedspnpm buildsucceeds across all 3 packagespnpm test— 534 / 534 passingpnpm typecheckcleanpnpm auditclean🤖 Generated with Claude Code