Files
pnpm/package.json
Zoltan Kochan 5f2bb9f5ba fix(security): verify npm registry signature before spawning a package-manager binary (#12292)
pnpm can be made to download and execute a native binary through two **repository-controlled** inputs, neither of which was authenticated before this change:

1. **pacquet install engine** — declaring `pacquet` (or `@pnpm/pacquet`) in `configDependencies` (in `pnpm-workspace.yaml`) opts in to pnpm's Rust install engine, and pnpm spawns the platform binary `@pacquet/<platform>-<arch>` during `pnpm install`.
2. **package-manager version switch** — the `packageManager` / `devEngines.packageManager` field makes pnpm download and run a specific pnpm version. This is **on by default** (`onFail` defaults to `download`) and also covers `pnpm self-update` and `pnpm with`.

In both cases the repository also controls the lockfile integrity and the registry the bytes are fetched from (via `.npmrc`), so matching the lockfile integrity proves nothing — it matches the hash the attacker wrote. A cloned, untrusted repository could therefore execute an arbitrary native binary just by running a normal pnpm command.

## Fix (corepack-style registry-signature verification)

pnpm now verifies the **npm registry signature** of the bytes it is about to spawn, **over the installed integrity**, against npm's public signing keys that **ship embedded in the pnpm CLI** (exactly as corepack does). If the bytes on disk were substituted or tampered with, npm's real signature does not validate over them.

- New reusable `verifyInstalledPackageSignatures()` in `@pnpm/deps.security.signatures` verifies `name@version:integrity` against `dist.signatures` using the embedded keys.
- Because the keys are **embedded** (not fetched), a registry the user did not vouch for cannot supply its own keypair to forge a signature. The signed packument is fetched from the **configured** registry, so an **npm mirror works transparently** — it proxies the same signed packument, with no configuration. There is intentionally **no runtime override or off-switch** for the keys.
- **pacquet** (`installing/commands`): verifies the `pacquet` shim and the host platform binary. It **fails the command** if the signature does not verify or cannot be checked (e.g. registry unreachable); the only graceful fallback to pnpm's own engine is when pacquet has no binary for the current platform.
- **pnpm engine** (`engine/pm/commands`): verifies `pnpm`, `@pnpm/exe`, and the host platform binary, **only on a store cache miss** (an actual download), so it adds no network round trip to every command. It **fails closed** — any verification failure, including an unreachable registry, refuses the version switch rather than running an unverified binary.

## Keeping the embedded keys fresh

The embedded keys live in a generated file. `deps/security/signatures/scripts/update-npm-signing-keys.mjs` keeps them in sync with npm's keys endpoint (`pnpm check:npm-signing-keys` / `--update`), and the **create-release-pr** workflow runs the check as a gate, so a key rotation cannot silently break verification — a stale key set blocks the release until refreshed.

## Pacquet parity

pacquet gained `configDependencies` support on `main` (#12285), but it has **no install-engine-spawn sink** — pacquet *is* the engine, and it does not select/spawn an alternate engine from `configDependencies` (its only config-dependency code-execution path is `updateConfig` plugin pnpmfiles, which it shares with pnpm and which this advisory does not cover). So CAND-PNPM-097 has no pacquet-side analog; no pacquet code change is needed.
2026-06-09 23:37:20 +02:00

76 lines
3.5 KiB
JSON

{
"name": "monorepo-root",
"private": true,
"scripts": {
"bump": "node __utils__/scripts/src/bump.ts && pn update-manifests",
"changeset": "changeset",
"prepare": "husky",
"pretest": "pn compile-only && pn prepare-fixtures",
"prepare-fixtures": "pn --dir=__fixtures__ prepareFixtures",
"lint": "pn spellcheck && pn lint:meta && pn lint:ts",
"spellcheck": "cspell \"**/*.ts\" \"**/README.md\" \".changeset/*.md\" --no-progress",
"lint:ts": "eslint \"**/src/**/*.ts\" \"**/test/**/*.ts\" --cache",
"test-all": "pn pretest && pn lint && pn test-pkgs-all",
"ci:test-all": "pn prepare-fixtures && pn test-pkgs-all",
"remove-temp-dir": "shx rm -rf ../pnpm_tmp",
"test-pkgs-all": "pn remove-temp-dir && pn --no-sort --workspace-concurrency=1 -r .test",
"test-branch": "pn pretest && pn lint && git remote set-branches --add origin main && git fetch origin main && pn test-pkgs-branch",
"ci:test-branch": "pn prepare-fixtures && pn test-pkgs-branch",
"test-pkgs-branch": "pn remove-temp-dir && pn --workspace-concurrency=1 --filter=...[origin/main] --no-sort --if-present .test",
"compile-only": "tsgo --build workspace/workspace-manifest-reader workspace/projects-reader && pnx node@runtime:26.3.0 __utils__/scripts/src/typecheck-only.ts && pn -F=pnpm compile",
"compile": "pn compile-only && pn update-manifests",
"build:pacquet": "cargo build --release --bin pacquet",
"make-lcov": "shx mkdir -p coverage && lcov-result-merger './packages/*/coverage/lcov.info' 'coverage/lcov.info'",
"update-manifests": "pn meta-updater && pn install",
"meta-updater": "pn --filter=@pnpm-private/updater compile && pn exec meta-updater",
"lint:meta": "pn meta-updater --test",
"copy-artifacts": "node __utils__/scripts/src/copy-artifacts.ts",
"make-release-description": "pn --filter=@pnpm/get-release-text run write-release-text",
"check:npm-signing-keys": "node deps/security/signatures/scripts/update-npm-signing-keys.mjs",
"update:npm-signing-keys": "node deps/security/signatures/scripts/update-npm-signing-keys.mjs --update",
"release": "pn --filter=@pnpm/exe run build-artifacts && pn --filter=@pnpm/exe publish --tag=next-11 --access=public --provenance && pn publish --filter=!pnpm --filter=!@pnpm/exe --access=public --provenance && pn publish --filter=pnpm --tag=next-11 --access=public --provenance",
"dev-setup": "pn -C=./pnpm/dev link -g"
},
"devDependencies": {
"@changesets/cli": "catalog:",
"@commitlint/cli": "catalog:",
"@commitlint/config-conventional": "catalog:",
"@commitlint/prompt-cli": "catalog:",
"@pnpm/eslint-config": "workspace:*",
"@pnpm/jest-config": "workspace:*",
"@pnpm/meta-updater": "catalog:",
"@pnpm/tgz-fixtures": "catalog:",
"@pnpm/tsconfig": "workspace:*",
"@types/jest": "catalog:",
"@types/node": "catalog:",
"@types/picomatch": "catalog:",
"@typescript/native-preview": "catalog:",
"c8": "catalog:",
"concurrently": "catalog:",
"cross-env": "catalog:",
"cspell": "catalog:",
"eslint": "catalog:",
"eslint-plugin-regexp": "catalog:",
"husky": "catalog:",
"jest": "catalog:",
"keyv": "catalog:",
"lcov-result-merger": "catalog:",
"rimraf": "catalog:",
"shx": "catalog:",
"typescript": "catalog:"
},
"packageManager": "pnpm@11.5.2",
"devEngines": {
"packageManager": {
"name": "pnpm",
"version": "11.5.2",
"onFail": "download"
},
"runtime": {
"name": "node",
"version": "26.3.0",
"onFail": "download"
}
}
}