Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
pnpm 10.x reference skill covering workspaces, catalogs, patches, peer deps, overrides, and CI/CD caching strategies.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/features-supply-chain-security.md
1---2name: pnpm-supply-chain-security3description: Build-script approval (allowBuilds), minimum release age, trust policy, and exotic-subdep blocking for safer installs4---56# pnpm Supply-Chain Security78pnpm blocks several attack vectors by default. Agents installing dependencies must understand these, since installs can fail or prompt on them.910## Build-script approval (allowBuilds)1112By default pnpm does **not** run dependency lifecycle scripts (`preinstall`/`install`/`postinstall`). Packages must be explicitly approved. Approval lives in one `allowBuilds` map in `pnpm-workspace.yaml`.1314```yaml title="pnpm-workspace.yaml"15allowBuilds:16esbuild: true17core-js: false18# version selectors are supported19[email protected] || 21.6.5: true20```2122- Packages **not listed** are unreviewed and blocked by default.23- `strictDepBuilds: true` (default) ⇒ unreviewed builds make install exit non-zero (`ERR_PNPM_IGNORED_BUILDS`). Set `false` to warn instead.24- During install, unreviewed packages with build scripts are auto-added to `pnpm-workspace.yaml` with a placeholder so you can set `true`/`false`.2526> `allowBuilds` replaces the removed `onlyBuiltDependencies`, `neverBuiltDependencies`, `ignoredBuiltDependencies`, `onlyBuiltDependenciesFile`, and `ignoreDepScripts`.2728### Approving builds2930```bash31pnpm approve-builds # interactive prompt32pnpm approve-builds --all # approve all pending33pnpm approve-builds esbuild fsevents !core-js # ! = deny34pnpm add --allow-build=esbuild my-bundler # approve while adding35pnpm add -g --allow-build=esbuild esbuild # global (replaces approve-builds -g)36```3738### Escape hatch (dangerous)3940```yaml title="pnpm-workspace.yaml"41dangerouslyAllowAllBuilds: true # runs ALL build scripts now and in the future — avoid42```4344## Minimum release age4546Delay installing freshly published versions so malicious releases (usually pulled within an hour) are avoided. Applies to **all** deps, including transitive.4748```yaml title="pnpm-workspace.yaml"49minimumReleaseAge: 1440 # minutes; default 1440 (1 day) since v1150minimumReleaseAgeExclude: # always install newest of these immediately51- webpack52- '@myorg/*'53- [email protected] # exempt a specific version54```5556- `minimumReleaseAgeStrict` — when no in-range version satisfies the age, fail (default when you set `minimumReleaseAge` yourself) vs. fall back.57- `minimumReleaseAgeIgnoreMissingTime` — skip the check for registries that omit the `time` field (default `true`).5859## Trust policy6061Fail if a package's trust level **decreased** vs earlier releases (e.g. was published by a trusted publisher, now only has provenance or nothing).6263```yaml title="pnpm-workspace.yaml"64trustPolicy: no-downgrade # off (default) | no-downgrade65trustPolicyExclude:66- '[email protected]'67trustPolicyIgnoreAfter: 525600 # ignore the check for pkgs published > N minutes ago68```6970## Block exotic transitive sources7172```yaml title="pnpm-workspace.yaml"73blockExoticSubdeps: true # default74```7576When `true`, only **direct** dependencies may use exotic sources (git repos, direct tarball URLs); all transitive deps must come from a trusted source (registry, local path, workspace link, or trusted GitHub repos).7778## Lockfile integrity7980Since v11, a downloaded tarball whose hash doesn't match `pnpm-lock.yaml` is a hard error (`ERR_PNPM_TARBALL_INTEGRITY`) — protecting committed lockfiles from a compromised registry/proxy. `--force` and `pnpm update` do **not** bypass it.8182```bash83pnpm install --update-checksums # narrow opt-in after verifying the new bytes84```8586## Trusted store/cache8788The content-addressable store, global virtual store, and metadata cache are part of pnpm's trust domain. Share them only between mutually trusting users/jobs and protect with filesystem permissions. `verifyStoreIntegrity` (default `true`) detects accidental corruption but does not make a writable-by-untrusted store safe.8990## Key Points9192- Dependency build scripts are blocked until approved via `allowBuilds` / `pnpm approve-builds`; unreviewed builds fail by default (`strictDepBuilds`).93- `minimumReleaseAge` (default 1 day in v11) delays new releases; `trustPolicy: no-downgrade` blocks trust regressions; `blockExoticSubdeps` limits transitive git/tarball sources.94- Tarball integrity mismatches are fatal; use `--update-checksums` only after verification.95- Treat the store/cache as trusted shared state.9697<!--98Source references:99- https://pnpm.io/settings#allowbuilds100- https://pnpm.io/cli/approve-builds101- https://pnpm.io/settings#minimumreleaseage102- https://pnpm.io/settings#trustpolicy103- https://pnpm.io/settings#blockexoticsubdeps104- https://pnpm.io/supply-chain-security105-->106