Skip to content

On pnpm 12, a hosted scan that routes a package through its named registry turns off the project's allowBuilds approval: every pnpm install then fails with ERR_PNPM_IGNORED_BUILDS #2372

Backlog

Description

[agent] Found by the architecture refactor routine on main at cfc870f. No PR yet: the routine already has three open.

Problem

A pnpm 12 project that approves a dependency's install script by name (allowBuilds: {ejs: true} in pnpm-workspace.yaml) installs before a hosted scan. After socket-patch scan --mode hosted pins a patch of that package, every pnpm install exits 1 with ERR_PNPM_IGNORED_BUILDS. The scan exits 0, reports success, and its warning says "installs need no extra flags".

The cause: since #2167, when the project's pnpm pins prove 11.20 or newer and the patch service gives the patch a registry address, the scan routes the patched package through a named registry of its own. pnpm then installs the package as ejs@socket-<id>:2.7.4, not ejs@2.7.4. pnpm 12 matches a build approval against that id, so the keys ejs and ejs@2.7.4 stop matching. pnpm 11.20 to 11.29 still match the name.

This is the defect #1597 described for vendored mode (fixed by #1668, 005e622) and #1595 for npm 12 (fixed by #1657). The vendored pnpm backend carries the user's decision to the new id. The hosted route does not, and says nothing about it.

Who it hurts: a pnpm 12 project whose patched package has an install script the project approved. pnpm 10 and newer block dependency install scripts by default, so a project that needs such a script has an approval. CI fails on the commit the scan asks for. With strictDepBuilds: false the install exits 0 and the script is skipped.

Not released. #2167 (5d8378e) is on main after v5.1.0. v5.1.0 keeps such a project on trustLockfile, where the lock key stays ejs@2.7.4 and the approval keeps matching (first control below). The next release cut from main would ship the route.

Evidence on main (cfc870f)

Real pnpm, the real ejs@2.7.4 (it has a postinstall script), the binary built from main, and a stand-in patch API on loopback. The stand-in grants one patch of ejs@2.7.4 with a registry address (npmRegistryUrl) and serves the patched tarball and its one-version document.

$ cat package.json
{ "name": "proj", "version": "1.0.0", "private": true,
  "packageManager": "pnpm@12.23.0", "dependencies": { "ejs": "2.7.4" } }
$ cat pnpm-workspace.yaml
allowBuilds:
  ejs: true

$ pnpm install; echo "exit $?"
.../.pnpm/ejs@2.7.4/node_modules/ejs postinstall$ node ./postinstall.js
.../.pnpm/ejs@2.7.4/node_modules/ejs postinstall: Done
Done in 943ms using pnpm v12.23.0
exit 0

$ socket-patch scan --mode hosted --yes; echo "exit $?"
Switched 1 package to hosted patches; rewrote 2 files.
  HIGH  ejs@2.7.4  CVE-2024-10000
Warning: pnpm-lock.yaml was repointed at the hosted patch server (...) so the existing
pnpm-workspace.yaml now declares the patch server's registry of each patched package ...
  - pnpm >=11.20 verifies those entries against their registry ... installs need no
    extra flags, and lockfile verification stays on.
exit 0

$ cat pnpm-workspace.yaml
allowBuilds:
  ejs: true
namedRegistries:
  socket-aaaaaaaa: http://127.0.0.1:18300/patch/npm/ejs/2.7.4/<token>/aaaaaaaa-1111-4222-8333-444444444444/
overrides:
  'ejs@2.7.4': 'socket-aaaaaaaa:2.7.4'

$ rm -rf node_modules; pnpm install --frozen-lockfile; echo "exit $?"
Lockfile is up to date, resolution step is skipped
Error: ERR_PNPM_IGNORED_BUILDS
  × installing dependencies
  ╰─▶ Ignored build scripts: ejs@socket-aaaaaaaa:2.7.4
  help: Run "pnpm approve-builds" to pick which dependencies should be allowed to run scripts.
exit 1

Under --json the scan's status is success, and warnings[] holds redirect_pnpm_trust_lockfile and nothing else.

The same project under five pins. The scan writes the route in every row:

packageManager pnpm install before scan pnpm install --frozen-lockfile after
pnpm 11.20.0 exit 0 exit 0 exit 0
pnpm 11.29.0 exit 0 exit 0 exit 0
pnpm 12.0.0 exit 0 exit 0 exit 1, ERR_PNPM_IGNORED_BUILDS
pnpm 12.23.0 (latest) exit 0 exit 0 exit 1, ERR_PNPM_IGNORED_BUILDS
pnpm 12.25.0 exit 0 exit 0 exit 1, ERR_PNPM_IGNORED_BUILDS

The same two workspace entries written by hand, with no socket-patch involved, split the same way: pnpm 11.20.0, 11.28.13 and 11.29.0 match the name; 12.0.0, 12.4.2, 12.10.0, 12.16.0, 12.19.0, 12.22.0, 12.23.0, 12.24.0 and 12.25.0 do not.

Controls, on pnpm 12.23.0 or 12.25.0:

  • A grant without a registry address keeps the project on trustLockfile. The lock key stays ejs@2.7.4, and the install after the scan exits 0 and builds ejs.
  • Other decisions. 'ejs@2.7.4': true is lost like ejs: true. ejs: false and dangerouslyAllowAllBuilds: true keep working under the route.
  • The key that works. Adding 'ejs@socket-aaaaaaaa:2.7.4': true beside the user's entry makes the install pass, and pnpm approve-builds --all writes that key. pnpm 11.20.0, 11.28.13 and 11.29.0 refuse a file that holds it (ERR_PNPM_INVALID_VERSION_UNION).
  • strictDepBuilds: false. The install after the scan exits 0, prints ejs build under "awaiting approval", and does not run the script.
  • rollback --yes restores both files byte for byte, and the install passes again.
  • Bun. With trustedDependencies: ["ejs"], the script still runs after a hosted scan.

One limit of this evidence: the route runs only when the patch service's grant carries npmRegistryUrl. This sandbox cannot reach the patch service, so I don't know whether its grants carry it today. The stand-in's grant has the shape crates/socket-patch-cli/tests/e2e_redirect_pnpm_build.rs uses (line 1522).

Where

  • The route: crates/socket-patch-core/src/formats/pnpm/named_registries.rs (plan, line 674) and registry_alias.rs (OverrideLock), driven from crates/socket-patch-core/src/hosted/engine.rs. Nothing there reads allowBuilds.
  • The carrier that exists: crates/socket-patch-core/src/vendor/pnpm_build_approvals.rs (carry, line 170). Its one caller is the vendored pnpm backend (vendor/pnpm_lock.rs, lines 428 to 429), and its Target builds only the name@file:<tarball> key (line 84).
  • The warning that says "installs need no extra flags": crates/socket-patch-core/src/hosted/guidance.rs, line 755.
  • The docs: CLI_CONTRACT.md (line 2584) and docs/ecosystems.md (line 427) describe the carry for vendored mode only. docs/testing/pnpm-compatibility.md does not mention build approvals.

Planned fix

One carrier for both modes. Target takes the id pnpm installs the copy as: name@file:<tarball> for a vendored copy, name@socket-<id>:<version> for a routed one. The hosted route calls it when it writes or respells a route. Its unwind (rollback, remove, a pin that leaves the route) removes the key it added, as the vendored revert does. A newer patch replaces the older patch's key, as Rank::Stale does for vendored keys.

The gate differs from the vendored one, and the sweep above gives it: write the key only when the pins prove pnpm 12 or newer, because pnpm 11 matches the name and refuses the routed key.

The test: a leg of e2e_redirect_pnpm_build.rs with a package that has an install script and a name-keyed approval, installed by real pnpm 12 after the scan. It fails on main.

One point for a maintainer. A pin that admits both majors (>=11.20) has no set of keys that works on both. Two options: warn and name the key, which is what vendored mode does without a usable pin; or leave such a project on trustLockfile when it decides a patched package's build. I would take the second, because both majors keep installing.


Generated by Claude Code

Activity

  1. added
    bug
    arch-audit
    on Nov 29, 2026
  2. added a commit that references this issue on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:triagedarch-auditbugpriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions