Skip to content

vex -g run inside a project names that project as the VEX product and attests not_affected for a package whose project copy is unpatched (only the global copy was checked) #2502

Backlog

Description

[agent] Found by the scheduled npm bug-hunt routine (ledger #302).

Summary

socket-patch vex -g (or --global-prefix) run from inside a project names that project as the VEX product, even though the run verified only the global copies. When the global copy of a package is patched and the project's own copy of the same package is not, the document says pkg:npm/<project>@<version> is not_affected, with the package as a subcomponent. Since v5.2.0 it also emits the package's own PURL as a standalone product, which Trivy and Grype match wherever they find that package. Fed to a scanner of the project, the document hides a vulnerability that is still installed there.

Plain vex (without -g) in the same directory correctly refuses (not_applied, exit 1). So the two commands disagree about the same project, and the one that attests the project is the one that never looked at it.

Impact

This is a false attestation. A user patches a global CLI (scan -g --mode agent) and then runs vex -g from their usual working directory, which is often a project. They get a document that says their app is not affected, and nothing warns them. If they attach it to the app's SBOM or scanner config, the finding disappears while the app still loads unpatched code.

Repro (Linux, npm 10.9.9 / Node 22, local mock patch API serving a marker patch for left-pad@1.3.0)

npm install -g --prefix "$G" left-pad@1.3.0
mkdir app && cd app && git init -q
echo '{"name":"app","version":"1.0.0","dependencies":{"left-pad":"1.3.0"}}' > package.json
npm install
socket-patch scan -g --global-prefix "$G/lib/node_modules" --mode agent --yes   # patches only the global copy
node -e "console.log(require('left-pad').__socket_marker)"                      # undefined: project copy is pristine
socket-patch vex -g --global-prefix "$G/lib/node_modules" -O v.json             # exit 0
socket-patch vex -O p.json                                                       # exit 1, not_applied (correct)

v.json (main d987721):

status: not_affected
products: pkg:npm/app@1.0.0  (subcomponents: pkg:npm/left-pad@1.3.0)
          pkg:npm/left-pad@1.3.0

The run prints only Using global npm packages at: … and Wrote OpenVEX document with 1 statement. There's no warning that the product it named is a different install from the one it checked.

Expected

CLI_CONTRACT.md, "Statement products": "A scanner matches a package product wherever it finds that package, so the document is only for the project it was made for." A -g run makes a document about the global installs, so it shouldn't auto-detect the cwd project as the product. Either:

  • require --product under global scope, as it already does outside a project (product_undetected), or
  • check the cwd project's copies too, and refuse or warn when they're unpatched.

CLI_CONTRACT.md, "Global scope never touches the project's state", already treats the cwd project as out of scope for a -g run. Product detection is the one place that still reads it.

This is a different case from the vlt known non-bug, where vex -g in a hosted/vendored project attests that project's applied patches. Here the project's copy isn't patched at all.

Versions

socket-patch npm Result
main d987721 (= v5.2.0) 10.9.9 reproduces 2/2: project product + standalone pkg:npm/left-pad@1.3.0 product, both not_affected
v5.1.0 10.9.9 reproduces: project product not_affected (no standalone package product yet)

Not a regression since v5.1.0. v5.2.0's standalone package products widen the impact. Product detection is OS-independent, so macOS and Windows should behave the same (not run: probe workflows are off).

Suspect code

crates/socket-patch-cli/src/commands/vex.rs:880: generate_vex calls resolve_product_id → detect_product(&common.cwd) (vex.rs:2616) with no common.is_global() check.

Handed over by the vlt routine (ledger entry 2026-12-03), confirmed by the npm routine.


Generated by Claude Code

Activity

  1. added
    bug
    bughunt
    on Dec 4, 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:triagedbugbughuntpm:npmpriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions