Repository navigation
Hosted scan with pnpm gitBranchLockfile pins the stale pnpm-lock.yaml and reports success, while pnpm installs unpatched bytes from pnpm-lock.<branch>.yaml #556
Description
Activity
- addedbugSomething isn't workingSomething isn't workingbughuntFound by a scheduled package-manager bug-hunt agentFound by a scheduled package-manager bug-hunt agentpm:pnpmpnpmpnpm
on Oct 2, 2026 mikolalysenko commented
on Oct 2, 2026 CollaboratorAuthorMore actions[agent] Triage: priority:p1 (pnpm). Hosted lock discovery only considers
pnpm-lock.yaml/shrinkwrap.yamland never consults pnpm'sgitBranchLockfilesetting, so the pin lands in a lock pnpm ignores on this branch. Distinct root cause from other open pnpm issues; no open PR covers it.
Generated by Claude Code
mikolalysenko commented
on Oct 2, 2026 CollaboratorAuthorMore actions[agent] More from the pnpm bug-hunt routine (ledger #303): vendored mode has the same lock-selection gap. Tested on main
203e092, Linux, pnpm 10.34.5 / 11.28.3 / 12.8.1, and it reproduced 2/2 on each.Setup:
maincommitspnpm-lock.yaml. Onfeature,gitBranchLockfile: trueis added topnpm-workspace.yamland an unpatched dep (ms@2.1.3) is added, so pnpm writespnpm-lock.feature.yaml.Running
scan --mode vendored --json --yesonfeature:- exits 0 with
status: success(applied+vendor_prebuilt_downloaded) and no warnings. - writes the
file:.socket/vendor/npm/<uuid>/is-number-7.0.0.tgzoverride intopackage.jsonpnpm.overridesandpnpm-workspace.yamloverrides:, and rewires the stalepnpm-lock.yaml. - leaves
pnpm-lock.feature.yaml, the lock pnpm actually uses on this branch, untouched (0 Socket references).
Result on a fresh checkout of the branch:
install 10.34.5 11.28.3 12.8.1 pnpm install --frozen-lockfilefails: "The current "overrides" configuration doesn't match the value found in the lockfile" same same pnpm install(non-frozen)patched (pnpm re-resolves the override into the branch lock) — patched So a "successful" vendor breaks every frozen install (CI) on the branch. Vendored mode needs to select the active branch lock as well. Alternatively, while
gitBranchLockfileis on, both modes could refuse with a diagnostic that names it.Separately, when the branch lock contains a patched dep that
pnpm-lock.yamllacks, vendored fails loudly ("pnpm-lock.yaml has no packages entry for left-pad@1.3.0",partial_failure). That message also points at the wrong lock.
Generated by Claude Code
- exits 0 with
mikolalysenko commented
on Oct 7, 2026 CollaboratorAuthorMore actions[agent] Claiming this issue as part of the pnpm open-issue sweep in draft PR #1007. Branch: agent/fix-pnpm-open-issues. Claim-ID: 2026-10-07T12:44:29Z-pnpm07
- added 3 commits that reference this issue
on Oct 7, 2026 mikolalysenko commented
on Oct 7, 2026 CollaboratorAuthorMore actions- added a commit that references this issue
on Oct 8, 2026
[agent] Found by the scheduled pnpm bug-hunt routine (ledger #303).
Summary
pnpm's
gitBranchLockfilesetting (git-branch-lockfile=truein.npmrcon pnpm ≤10,gitBranchLockfile: trueinpnpm-workspace.yaml) makes pnpm read and writepnpm-lock.<branch>.yamlinstead ofpnpm-lock.yaml. Hosted mode only looks at files named exactlypnpm-lock.yaml/shrinkwrap.yaml. That causes two failures:pnpm-lock.yamlcommitted on main, and a branch lock written once the feature branch changes deps):scan --mode hostedpins the stalepnpm-lock.yamland reportsstatus: success, redirected: 1. pnpm installs frompnpm-lock.feature.yaml, which still points at the registry, so a freshpnpm install --frozen-lockfilesilently installs the unpatched upstream bytes.vexhonestly declines (not_applied), so it's the only signal.redirected: 0and the warningredirect_pnpm_no_lockfile, whose remedy ("runpnpm installto generate one") cannot work, because pnpm will just rewrite the branch lock.Impact
On a feature branch with this setting, the user is told the patch is pinned (and the pin lands in a file they will commit), but CI and fresh checkouts on that branch install the vulnerable package. When the branch merges, pnpm's
mergeGitBranchLockfilesflow can carry the unpinned branch entry over the pinned main one.Repro (Linux, pnpm 12.8.1; local mock of the patch API serving a patched
is-number@7.0.0tarball)Only-branch-lock variant:
git init -b feature, enable the setting before the firstpnpm install. Hosted scan then givesredirected 0plusredirect_pnpm_no_lockfile.Expected vs actual
pnpm-lock.<current-branch>.yaml(and leave the stale lock alone, or pin both), or refuse with a dedicated warning code that names the setting.Matrix (Linux; each cell run twice)
.npmrcsetting produced no branch lock)pnpm-lock.yamlis the one used, patchedredirect_pnpm_no_lockfile)macOS and Windows weren't tested (no probe branch this run); the logic is filename-based, so they're likely the same. Vendored mode with this setting wasn't tested.
Suspect code
crates/socket-patch-core/src/formats/pnpm/hosted.rs:180–lock_keysmatches onlypnpm-lock.yaml/shrinkwrap.yaml.crates/socket-patch-core/src/formats/registry.rs:72– the hosted read set lists onlypnpm-lock.yaml.crates/socket-patch-core/src/patch/redirect/mod.rs:806–redirect_pnpm_no_lockfilefires without consideringpnpm-lock.*.yaml.Tested on main
61cfb9b(CLI 4.0.0).