Skip to content

vendor --check prints the git token from an npm lock entry it reports as an unpatched copy, which #2445 redacts everywhere else #2476

Backlog

Description

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

Summary

#2445 (closing #2287) made refusals, hosted warnings and vex notes redact the credentials of URLs quoted from a lockfile. vendor --check was missed. When a vendored npm project also installs a git copy of the same release, vendor --check quotes that lock entry's resolved URL in full, token included. This happens in the human output and in the --json event's reason. The neighbouring commands redact the same URL: scan --mode vendored, vex, repair, apply --check, list and remove.

Impact: vendor --check is the command the docs suggest for CI gating. A private git dependency installed with a token (git+https://x-access-token:<token>@github.com/...) is a common CI setup, and npm writes that token verbatim into package-lock.json. Each failing check then prints the token into the CI log and into any stored --json document.

Repro (real npm 10.9.9, Linux; npm 12.2.3 the same with --allow-git=all)

mkdir app && cd app && git init -q
echo '{"name":"app","version":"1.0.0"}' > package.json
npm i left-pad@1.3.0 'lp@git+https://x-access-token:ghp_S3CRETTOKEN@github.com/stevemao/left-pad.git#v1.3.0'
grep S3CRET package-lock.json          # npm itself records the token in `resolved`
echo node_modules > .gitignore && git add -A && git commit -qm init
# any org/API serving a patch for pkg:npm/left-pad@1.3.0 (a local mock of the org routes here)
socket-patch scan --mode vendored --yes      # warning prints "git+https://<redacted>@github.com/..."  (good)
socket-patch vex                             # warning prints "<redacted>"                             (good)
socket-patch vendor --check                  # prints the token (bad)
socket-patch vendor --check --json | grep S3CRET   # events[0].reason carries the token (bad)

Actual (vendor --check, exit 1):

pkg:npm/left-pad@1.3.0: copy unpatched: package-lock.json: pkg:npm/left-pad@1.3.0 is wired to a Socket patch but lock entry `node_modules/lp` is not installed from the registry (it resolves to "git+https://x-access-token:ghp_S3CRETTOKEN@github.com/stevemao/left-pad.git#ff8e7ba8b4122829cf66125ca8445cac7f073bce"); npm installs it from that spec, so that copy stays UNPATCHED and nothing is attested; re-vendoring cannot reach that copy, ...

--json: {"action":"failed","purl":"pkg:npm/left-pad@1.3.0","reason":"copy unpatched: ... git+https://x-access-token:ghp_S3CRETTOKEN@github.com/...","errorCode":"vendor_check_failed"}

Expected: the same git+https://<redacted>@github.com/... form that scan and vex print for this entry in the same run. That is the behaviour #2287 / #2445 set for every message that quotes a lock URL. The exit code and the refusal itself are correct.

Where it reproduces

Build npm vendor --check leaks scan / vex / repair / apply --check / list / remove leak
main d987721 (= v5.2.0) 10.9.9 (lockfileVersion 3) yes (plain and --json) no
main d987721 (= v5.2.0) 12.2.3 (--allow-git=all) yes no

I reproduced it 3 times: twice on the lock npm 10.9.9 wrote, and once on npm 12.2.3. This isn't a regression: before #2445 every one of these messages carried the token. It's the one sink that fix left uncovered. The code is platform-independent, so macOS and Windows should behave the same.

Suspect code

crates/socket-patch-cli/src/commands/vendor.rs:645: the copy unpatched: reason copies d.detail (the vex discovery Diag) as written. The vex path redacts the same diag when it records it through RunWarning::new (note_warning), but this vendor --check reason is built separately and never goes through utils::redact::redact_message. The wiring incomplete: reasons a few lines below (vendor.rs:656, :662) build their text from diag.detail the same way. I only proved the npm git-copy path, but the same fix probably covers those reasons too (for example, a pnpm lock that quotes a tarball URL).


Generated by Claude Code

Activity

  1. added
    bug
    bughunt
    on Dec 3, 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