Skip to content

vendor --check and vex call a vendored pnpm package patched when no file the project's pnpm reads declares its override: after a move from pnpm 9 to 11 or 12 every frozen install fails and a plain pnpm install puts the upstream package back #2382

Done

Description

[agent] Found by the architecture refactor routine on main at cfc870f, with real pnpm 9.15.9, 10.28.0, 11.29.0 and 12.23.0.

The problem

pnpm installs a lock only when the lock's overrides: equal the overrides its settings declare. When they differ, a frozen install stops with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH, and a plain pnpm install resolves again: it takes the package from the registry, rewrites the lock without the vendored entry and exits 0. Which file holds those settings depends on the pnpm major: pnpm.overrides in package.json for pnpm 9, either file for pnpm 10, overrides: in pnpm-workspace.yaml alone for pnpm 11 and 12.

vendor --check and vex read a vendored pnpm package from pnpm-lock.yaml alone. With the override declared in no file the project's pnpm reads:

  • socket-patch vendor --check exits 0: "committed artifact and wiring verified";
  • socket-patch vex exits 0 and attests not_affected;
  • socket-patch vendor --dry-run prints "1 package is already vendored; nothing to do.";
  • every frozen install (CI) fails, and the install pnpm then suggests ("Update your lockfile using pnpm install --no-frozen-lockfile") puts the upstream package back with no word about the patch.

Two ways a project gets there with no hand edit of a wiring file:

  1. A pnpm upgrade. Under pnpm 9, vendor writes package.json and pnpm-lock.yaml and no pnpm-workspace.yaml. Move the project to pnpm 11 or 12 and no file pnpm reads declares the override. Nothing in the checkout changed.
  2. pnpm-workspace.yaml left out of the commit on pnpm 11 or 12. It is a new file after the first vendored run, and package.json and the lock are the two a reviewer expects to see change.

The rule is already in the code and the contract for the other package managers that pair a lock with a manifest:

The fixtures agree. With the lock vendored and the manifest put back, vex refuses Cargo ("no [patch] entry in Cargo.toml […] not counted") and Bundler ("Gemfile declares alpha with no source of its own […] not counted"), and attests pnpm.

With the lock on, pnpm_vendored_ref (the same file, line 1581) makes the reference from the lock entry, and the per-backend audit of vendor --check (check_npm_wiring, core vendor/npm_flavor.rs) looks only for dependencies the lock does not resolve. The writer knows the rule: its closing line says "pnpm >=11 reads the vendored override only from pnpm-workspace.yaml", and a wet vendor over such a tree writes the missing override back.

Evidence

With real pnpm

A project that depends on left-pad 1.3.0, installed by each pnpm, with a stand-in patch record that appends a comment to index.js. socket-patch is the binary built from main, with the vendor suite's fixture service. Each row starts from the tree vendor wrote under that pnpm and takes the override out of one place; "installed" is what node_modules/left-pad/index.js holds afterwards.

pnpm Override missing from vendor --check vex pnpm install --frozen-lockfile pnpm install
9.15.9 nowhere (as vendored: package.json and the lock) exit 0 not_affected patched patched
9.15.9 package.json exit 0 not_affected ERR_PNPM_LOCKFILE_CONFIG_MISMATCH upstream, exit 0, lock unwired
10.28.0 package.json or pnpm-workspace.yaml (one of them) exit 0 not_affected patched patched
10.28.0 both exit 0 not_affected ERR_PNPM_LOCKFILE_CONFIG_MISMATCH upstream, exit 0, lock unwired
11.29.0 package.json exit 0 not_affected patched patched
11.29.0 pnpm-workspace.yaml exit 0 not_affected ERR_PNPM_LOCKFILE_CONFIG_MISMATCH upstream, exit 0, lock unwired
12.23.0 pnpm-workspace.yaml exit 0 not_affected ERR_PNPM_LOCKFILE_CONFIG_MISMATCH upstream, exit 0, lock unwired

The upgrade, with no file touched: the tree pnpm 9.15.9's vendored run left (package.json, pnpm-lock.yaml, .socket/), with no node_modules.

$ socket-patch vendor --check                      # exit 0
pkg:npm/left-pad@1.3.0: committed artifact and wiring verified

$ socket-patch vex --product pkg:npm/app@1.0.0     # exit 0
Emitted 1 VEX statement
  "status": "not_affected",
  "impact_statement": "Patched via Socket patch 11111111-… (vendored)"

$ pnpm install --frozen-lockfile                   # pnpm 11.29.0, exit 1
[WARN] The "pnpm" field in package.json is no longer read by pnpm. The following keys were ignored: "pnpm.overrides". See https://pnpm.io/settings for the new home of each setting.
[ERR_PNPM_LOCKFILE_CONFIG_MISMATCH] Cannot proceed with the frozen installation. The current "overrides" configuration doesn't match the value found in the lockfile
Update your lockfile using "pnpm install --no-frozen-lockfile"

$ pnpm install                                     # exit 0
[WARN] The "pnpm" field in package.json is no longer read by pnpm. The following keys were ignored: "pnpm.overrides". […]
dependencies:
+ left-pad 1.3.0 deprecated
Done in 682ms using pnpm v11.29.0

$ grep -c socket/vendor pnpm-lock.yaml
0
$ grep -c PATCHED node_modules/left-pad/index.js
0

$ socket-patch vendor --check                      # exit 1, now that the lock is unwired
pkg:npm/left-pad@1.3.0: wiring missing: no lockfile or config references .socket/vendor/npm/11111111-… any more, so a fresh install gets the unpatched package; re-run `socket-patch vendor` to rewire it

pnpm says what it ignored. socket-patch says nothing until pnpm has rewritten the lock.

pnpm 12.23.0 gives the same two results (Error: ERR_PNPM_LOCKFILE_CONFIG_MISMATCH, then the upstream package).

On pnpm 11.29.0 with pnpm-workspace.yaml deleted, a wet socket-patch vendor reports "Vendored 1 package." and writes the file back with the override, after vendor --dry-run said there was nothing to do.

A test that fails on main

For any suite that loads vendor_ecosystem_fixtures:

/// pnpm installs a lock only when the lock's `overrides:` equal the ones its
/// settings declare. With the override declared nowhere, a frozen install
/// fails (ERR_PNPM_LOCKFILE_CONFIG_MISMATCH) and a plain one resolves the
/// package from the registry again.
#[test]
fn pnpm_lock_without_its_override_is_not_verified() {
    let f = Fixture::new("pnpm");
    let manifest = std::fs::read(f.root.join("package.json")).unwrap();
    let (code, stdout, stderr) = f.vendor(&[], &[]);
    assert_eq!(code, 0, "{stdout}\n{stderr}");
    std::fs::write(f.root.join("package.json"), &manifest).unwrap();
    std::fs::remove_file(f.root.join("pnpm-workspace.yaml")).unwrap();
    assert!(std::fs::read_to_string(f.root.join("pnpm-lock.yaml"))
        .unwrap()
        .contains(".socket/vendor/npm/"));

    let (code, ..) = f.run(&["vendor", "--check"], &[]);
    let (_, vex, _) = f.run(&["vex", "--product", "pkg:npm/app@1.0.0"], &[]);
    let attested = vex.matches("\"status\": \"not_affected\"").count();
    assert_eq!((code, attested), (1, 0), "(vendor --check exit code, not_affected statements)");
}
test pnpm_lock_without_its_override_is_not_verified ... FAILED
assertion `left == right` failed: (vendor --check exit code, not_affected statements)
  left: (0, 1)
 right: (1, 0)

Not run: pnpm 7 and 8 (the legacy lock), a workspace with members, Rush, a project that pins its pnpm with packageManager, and hosted mode's registry route, whose locks carry overrides: too.

Planned fix

One rule for both lock states: a vendored pnpm reference counts only when the override map the project's pnpm reads names its artifact. The lock-off reader already answers which map that is (node_modules/.modules.yaml, else packageManager, else the lock's grammar; either map when none says), so the change is to consult it with the lock on as well.

  • vex withholds the reference and names the file that lacks the override.
  • vendor --check fails the entry with the same sentence and the remedy (socket-patch vendor, then commit the file).
  • vendor --dry-run counts the package as one it would re-wire.
  • The contract's pnpm row gains the confirmation the Yarn Berry, Cargo and Bundler rows have.

One thing this does not settle, for a maintainer: a project vendored under pnpm 9 has no pnpm-workspace.yaml, and when nothing records the pnpm major the rule above accepts the package.json override, so the upgrade case is caught only once the checkout says which pnpm it uses. Whether vendor should write the workspace override under pnpm 9 as well is a change to what vendored mode writes, and #360 shows the two maps interact, so I have left it out of the plan.

Related: #2381 is the same gap between the writer's rule and the two verifiers, for NuGet's lock pin.


Generated by Claude Code

Activity

  1. added
    bug
    arch-audit
    on Nov 30, 2026
  2. added a commit that references this issue on Nov 30, 2026
  3. mikolalysenko commented on Dec 1, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Claiming this for the architecture refactor routine. Branch: arch-refactor/2382-pnpm-override-confirms-vendored.

    Re-run on main at 1b3f422: the issue's test still fails the same way, (vendor --check exit code, not_affected statements) is (0, 1) where (1, 0) is right.


    Generated by Claude Code

  4. mikolalysenko commented on Dec 1, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] #2396 is ready for review. It makes vendor --check and vex ask where the project's pnpm reads its overrides, measured on real pnpm 8.15.9 to 12.23.0. Two things in this issue's text turned out different on the real tool:

    • pnpm reads overrides: from pnpm-workspace.yaml from 10.5.1 on, not from 10.5: 10.2.0, 10.4.1 and 10.5.0 refuse a lock whose override is only there.
    • On pnpm 10.5.1 to 10.x, package.json is read in place of the workspace file whenever it declares any override (pnpm.overrides, or the top-level resolutions), so "either file" holds only while package.json declares none.

    What #2396 does not do, each seen while testing it:

    1. vendor does not restore a package.json override while the workspace file carries one the lock records. With pnpm older than 10.5.1 (9.15.9, 10.2.0, 10.4.1, 10.5.0), or beside a resolutions table (10.28.0), socket-patch vendor prints "already vendored; nothing to do" and the frozen install still fails. The writer skips the package.json copy when the lock records a workspace override key, which its own surgery makes true on any pnpm. Stop attesting a vendored pnpm package whose override no settings file declares #2396 gives the entry to add by hand in that case; vendor --revert followed by vendor also repairs it. A fix belongs in the writer and needs the committed pins there.
    2. vendor --dry-run still previews "already vendored" over a tree whose wet run rewrites the declaration (planned-fix bullet 3 of this issue).
    3. The lock-off reader goes by major. With pnpm's lockfile setting off, a workspace override is accepted for every pnpm 10. Read, not run.
    4. Hosted mode's registry route also writes overrides: to the lock and the workspace file; its references are not checked against the declaration. Read, not run.
    5. The contract's pnpm row is not updated in Stop attesting a vendored pnpm package whose override no settings file declares #2396, because two open PRs change that file; the PR body has the sentence.

    The question this issue leaves for a maintainer still stands: whether vendor should write the workspace override under pnpm 9 as well. With #2396 the upgrade from pnpm 9 to 11 is caught once package.json names the pnpm (packageManager, devEngines, engines.pnpm); a project with no pin is judged leniently.


    Generated by Claude Code

  5. added 2 commits that reference this issue on Dec 1, 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