Skip to content

After a vendored scan of an npm project, the npm install that the next steps and vex name can print "up to date" and leave the package unpatched (a node_modules/.cache or an earlier agent-mode run is enough); only npm ci installs the patch #2339

Backlog

Description

[agent] Found by the architecture refactor routine (ledger discussion #2244, lead L71) while running a vendored npm project through its next steps with real npm. Run on main at cfc870f with the binary built from it, npm 10.9.9 on Node 22, and the repository's fixture vendor service.

Problem

A vendored scan of an npm project rewrites package-lock.json and ends with Run \npm install` to update the installed tree. In a working tree where anything created or removed an entry in node_modules/since the last install, thatnpm installprintsup to dateand reinstalls nothing. The package undernode_modules/stays the registry's unpatched copy. Running it again, or with--force, changes nothing. npm ci` is what installs the patched tarball.

What makes a tree like that:

  • a node_modules/.cache directory that appears after the install. webpack's filesystem cache creates it on the first build (run here); babel-loader, Prettier's --cache, Storybook and nyc keep their caches in the same directory (not run);
  • an earlier agent-mode run of socket-patch on the same tree (it stages each file beside the one it replaces, which touches the package directory), including one that was rolled back.

vex notices the mismatch and warns with vendored_tree_out_of_sync, whose remedy is the same no-op: "re-run your package manager's install to resync it". vendor --revert has the mirror image: it says Run \npm install` to resync the installed tree, npm prints up to date, and the vendored copy stays installed while list` says the project has no patches.

Who it hurts: a developer adopting vendored mode on a machine that has built the project before. The scan says Patched 1 package, fixing 1 vulnerability, they run the command it names, npm says up to date, and they keep running and testing the vulnerable code locally. A clean checkout and npm ci (most CI) install the patched tarball, so this is about the working tree and about any pipeline that runs npm install over a kept node_modules.

Yarn 1.22.22, pnpm 10.28.0 and Bun 1.4.4 reinstall the package from the same starting state with their plain install; this is npm only.

Evidence

A project with left-pad 1.3.0 and webpack, and a patch that makes left-pad return socket-patched-1.

$ npm ci
added 117 packages in 1s
$ mkdir node_modules/.cache
$ socket-patch scan --mode vendored --yes; echo "exit $?"
Vendored 1 package.
  HIGH  left-pad@1.3.0  CVE-2026-0001
Next steps:
  1. Commit .socket/vendor/ and the updated lockfiles to make the patches portable.
  2. Run `npm install` to update the installed tree, then run `socket-patch vex` to verify the installed patches.

Patched 1 package, fixing 1 vulnerability (1 high).
exit 0
$ npm install
up to date in 324ms
$ node -p 'require("left-pad")("7", 3, "0")'
007
$ socket-patch vendor --check; echo "exit $?"
pkg:npm/left-pad@1.3.0: committed artifact and wiring verified
exit 0
$ socket-patch vex --product pkg:npm/wp-app@1.0.0 -O vex.json; echo "exit $?"
Warning: pkg:npm/left-pad@1.3.0: the installed tree does not match its vendored artifact; the attestation is based on the committed .socket/vendor artifact (the project's lockfile or package-manager config wires it in), but the live tree carries different bytes — re-run your package manager's install to resync it.
Wrote OpenVEX document with 1 statement to vex.json
exit 0
$ npm install; npm install --force
up to date in 232ms
up to date in 245ms
$ node -p 'require("left-pad")("7", 3, "0")'
007
$ npm ci
added 117 packages in 1s
$ node -p 'require("left-pad")("7", 3, "0")'
socket-patched-1

The notice about the missing API token and two summary lines are left out.

The same scan and npm install from different starting states:

Before the vendored scan npm install afterwards Installed left-pad
npm ci and nothing else (control) changed 1 package patched
mkdir node_modules/.cache up to date unpatched
one npx webpack build with cache: { type: 'filesystem' } up to date unpatched
a directory created and removed under node_modules/ up to date unpatched
scan --mode agent, then rollback up to date unpatched
scan --mode agent, left applied up to date patched (the agent copy)

The other direction, over a tree that holds the vendored copy and a node_modules/.cache newer than the install:

$ socket-patch vendor --revert --yes
Reverted 1 vendored package.
Run `npm install` to resync the installed tree with the restored lockfile (it may still hold the vendored bytes if you reinstalled after vendoring).
$ npm install
up to date in 356ms
$ node -p 'require("left-pad")("7", 3, "0")'
socket-patched-1
$ socket-patch list
No patches in this project. Run `socket-patch scan`.

Cause

npm keeps a record of what it installed in node_modules/.package-lock.json and trusts it only while no directory under node_modules/ is newer than the file (assertNoNewer in its shrinkwrap.js: "out of date, updated: node_modules"). Otherwise it reads the tree from disk, and for each package it finds it fills in resolved and integrity from the project's package-lock.json when the version matches (add in the same file: "if we have metadata about this node, and it's a match, then try to decorate it"). A vendored patch keeps the version and changes those two fields. So the rewritten lock itself tells npm that the copy on disk came from the vendored tarball, and npm finds nothing to change. That no-op run then writes the claim into node_modules/.package-lock.json, which is why every later npm install agrees.

In socket-patch, three messages name the command for this state:

  • the vendored next step: flavor_install_command maps package-lock to npm install (CLI commands/vendor.rs, lines 4989 to 5014). Its comment says "a successful vendor must say how to update it";
  • the revert hint: flavor_revert_install_command and format_revert_install_hint (the same file, lines 5016 to 5027 and 917 to 922);
  • vex's vendored_tree_out_of_sync detail: "re-run your package manager's install to resync it" (CLI commands/vex.rs, lines 2140 to 2148).

The class has been fixed for the neighbours, one at a time:

The vendored npm flavor still names the plain install, and its unit test pins it: assert_eq!(flavor_install_command("package-lock"), Some("npm install")) (commands/vendor.rs, line 8040).

Planned fix

  1. flavor_install_command names npm ci for the package-lock flavor, as hosted mode and the contract's line 850 do. The revert hint follows through flavor_revert_install_command.
  2. vex's vendored_tree_out_of_sync detail gains an npm note beside the Hatch and PDM ones: a plain npm install can report up to date and keep the old copy, so run npm ci.
  3. Tests: the mapping, the two messages, and one real-npm test of the sequence above where the suite already runs npm (a vendored project, a directory created under node_modules/, the named command, then the installed bytes).

The contract settles the wording, so this is not a decision issue. It changes text on stdout and the detail of one warning; no JSON key, code or exit status.

The routine has three PRs open and awaiting review, so no PR is opened for this yet.

Not checked: npm 11 and 12 (the two functions are unchanged in npm 10.9.9; later majors were not run), a workspace member's own node_modules, and hosted mode with real npm (the benchmark's npm project has a stand-in node_modules that npm prunes). Hosted mode rewrites the same two lock fields and keeps the version, so a user who answers its next step with npm install instead of the npm ci it names should meet the same no-op. Seen beside it: npm install left-pad@1.3.0 re-resolves the package from the registry and removes the vendored wiring from the lock, so it is not a remedy either.


Generated by Claude Code

Activity

  1. added
    bug
    arch-audit
    on Nov 28, 2026
  2. added a commit that references this issue on Nov 28, 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