[Chore] Harden .yarnrc.yml: scope install scripts to an explicit allowlist#1322
Merged
Conversation
iamalwaysuncomfortable
approved these changes
May 21, 2026
18e3944 to
240e705
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.
Motivation
Hardens the repo's Yarn supply chain config so dependency install scripts no
longer run by default:
.yarnrc.yml: setsenableScripts: false, so Yarn no longer runspostinstall/build scripts from arbitrary dependencies.package.json: adds adependenciesMetaallowlist (built: true) forthe packages that genuinely need install/build scripts:
@swc/core,esbuild,sharp,wasm-pack..yarnrc.yml: removesapprovedGitRepositories: ["**"], whichauto-approves any git hosted dependency. The tree has no git hosted
dependencies, so this is dead permissive config.
yarn.lock: records the allowlist in the workspace entry (a consequenceof
dependenciesMeta, required for--immutableinstalls).Why
By default Yarn executes arbitrary
postinstallscripts from every package inthe dependency tree. A single compromised dependency can run code on dev
machines and CI at install time.
enableScripts: falsemakes that opt-in:only allowlisted packages can run scripts.
Verified under Berry
Rebased onto
mainnetafter the Yarn Berry migration (#1323). On a cleaninstall (all
node_modulesremoved) withenableScripts: false:skipped (e.g.
core-js's funding banner postinstall no longer runs).yarn install --immutablepasses.yarn build:allis green, confirming the allowlist is complete.yarn test:sdk: 976 passing. The 17 failures are preexisting local envissues (missing CI secrets / no network), identical to before this change,
so no regressions.
Note
Medium Risk
Moderate risk because it changes Yarn install-time behavior: dependencies’ build/postinstall scripts will no longer run unless allowlisted, which can break installs/builds in dev/CI if the allowlist is incomplete.
Overview
Hardens Yarn supply chain settings by setting
.yarnrc.ymltoenableScripts: false(and removing the permissiveapprovedGitRepositoriessetting), so dependency install/build scripts no longer run by default.Adds a
dependenciesMetaallowlist inpackage.json(and correspondingyarn.lockmetadata) marking@swc/core,esbuild,sharp, andwasm-packasbuilt: trueso only these packages can run required build steps under Yarn Berry.Reviewed by Cursor Bugbot for commit 240e705. Bugbot is set up for automated code reviews on this repo. Configure here.