`socket pnpm install` fabricates alerts for packages not in the tree: pnpm v9 lockfile keys are truncated at the first underscore
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 66/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- typescript
Direzione di ricerca
Riproduci il problema con il lockfile pnpm v9 mostrato, quindi esamina stripPnpmPeerSuffix in dist/utils.js e il suo utilizzo tramite extractPurlsFromPnpmLockfile e getAlertsMapFromPnpmLockfile in dist/shadow-pnpm-bin2.js. Il lavoro è completato quando i pacchetti con nomi contenenti underscore mantengono i nomi e le versioni completi nei purls inviati, i suffissi dei peer continuano a essere gestiti per il formato di lockfile pertinente e la riproduzione non segnala più l’alert di stringa non correlato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
The pnpm shadow wrapper's lockfile scan mangles the name of any package whose name contains an underscore, submitting a purl for a different, unrelated package. In any pnpm-v9 project that depends on string_decoder (i.e. effectively every project, via readable-stream), socket pnpm install reports a High CVE for string@3.3.3 — a package that is not in the dependency tree at all — and exits 1.
Mechanism
stripPnpmPeerSuffix truncates a lockfile package key at the first ( or _:
function stripPnpmPeerSuffix(depPath) {
const parenIndex = depPath.indexOf('(');
const index = parenIndex === -1 ? depPath.indexOf('_') : parenIndex;
return index === -1 ? depPath : depPath.slice(0, index);
}
The _ case is the pnpm lockfile v5 peer-suffix convention (/foo/1.0.0_bar@2.0.0). In lockfile v9, package keys are plain name@version, where _ is an ordinary legal character in npm package names. So extractPurlsFromPnpmLockfile maps:
| Lockfile key (v9) | Submitted purl |
|---|---|
string_decoder@1.3.0 |
pkg:npm/string (versionless, wrong package) |
evp_bytestokey@1.0.3 |
pkg:npm/evp |
@types/babel__core@7.20.5 |
pkg:npm/@types/babel |
The batch purl endpoint resolves the versionless pkg:npm/string to the real (unrelated) string package, whose latest version 3.3.3 carries a High CVE — which the wrapper's default filter treats as fatal, regardless of org policy. The other two mangled names happen not to resolve to alerting packages, which is why only string@3.3.3 surfaces.
Reproduction
mkdir repro && cd repro
npm init -y > /dev/null
printf 'lockfileVersion: "9.0"\npackages:\n string_decoder@1.3.0:\n resolution: {integrity: sha512-zOgAKMkjXbleOl9U5k7DBVdNwCRJW8ANhbJpEbriDmqu3nrOJPVHHqAmU7hBVBkoGuZbSpUnGdgOSg74RSPikw==}\nsnapshots:\n string_decoder@1.3.0:\n dependencies:\n safe-buffer: 5.2.1\n' > pnpm-lock.yaml
SOCKET_CLI_DEBUG=1 DEBUG='*' socket pnpm install 2>&1 | grep -A5 purls
# → purls include 'pkg:npm/string' (no version), and the run fails on string@3.3.3's High CVE
(Alternatively: any real pnpm-v9 project with string_decoder in its lockfile reproduces it — we hit it in a 1,500-package workspace.)
Versions
Observed identical in @socketsecurity/cli@1.1.85, socket@1.1.143, and socket@1.1.155 (latest as of 2026-08-08): dist/utils.js stripPnpmPeerSuffix, reached via extractPurlsFromPnpmLockfile → getAlertsMapFromPnpmLockfile in dist/shadow-pnpm-bin2.js's install path.
Suggested fix
Only apply the _ truncation to v5-style dep paths (those beginning with / and using /name/version shape), or key the suffix-stripping on the lockfile's lockfileVersion. For v9 name@version keys, peer suffixes only ever appear in parentheses.
Impact
socket pnpm installfails spuriously (exit 1) for effectively any pnpm-v9 tree containing an underscore-named package that maps onto an alerting package name.- The submitted purl set silently omits the real packages (
string_decoder,evp_bytestokey,@types/babel__*are never actually checked).
- Lingua principale
- TypeScript
- Stelle
- 317
- Fork
- 65
- Merge medio
- 1h 26m
- PR unite (30g)
- 30
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di SocketDev/socket-cli
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
SocketDev/socket-cli#1160 · 1 commento ·
-
[fuzz] fuzz-js job failed Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
SocketDev/socket-cli#1547 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
SocketDev/socket-cli#1525 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
SocketDev/socket-cli#1517 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
SocketDev/socket-cli#1498 ·
Tutte le issue di SocketDev/socket-cli
Issue simili
-
Type/Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
OpenNSW/nsw-srilanka#497 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
0xMiden/bridge-portal#132 ·
-
react-doctor severity:warning tech-debt
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
digidem/comapeo-cloud-app#403 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100