Repository navigation
fix(shadow): scan only the dlx package with IPC token - #1617
Merged
Merged
Conversation
The pnpm and yarn shadow bins ran their pre-launch package scan with the user's default API token and ignored the IPC overrides that internal callers pass. When the CLI launched Coana with pnpm dlx or yarn dlx, a repository-scoped token got a 403 from the purl endpoint on every reachability run. The npm path already used the public token. The dlx scan also treated every positional argument as a package, so the launched tool's own arguments were looked up as npm packages, and an alert on one of them could abort the run. Both bins now take the API token and accept-risks flag from IPC, and dlx scans only the --package values or the first positional.
pnpm options like --allow-build and --reporter take the next argument as their value. The dlx scan treated that value as the package and stopped, so the package pnpm actually launched went unchecked. Each shadow bin now passes the options that take a value, so the scan skips their values before choosing the package. In pnpm, -p means --parseable, so only yarn treats it as --package.
Martin Torp (mtorp)
marked this pull request as ready for review
October 13, 2026 11:00
Martin Torp (mtorp)
requested a review
from Benjamin Barslev Nielsen (barslev)
October 13, 2026 11:00
Benjamin Barslev Nielsen (barslev)
approved these changes
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The pnpm and yarn shadow bins now honor the IPC overrides that internal callers pass, and
dlxonly scans the package being launched.Why
When
socket scan create --reachruns in a pnpm or yarn project, the CLI launches Coana withpnpm dlxoryarn dlxthrough the shadow bin. Before running, the shadow bin checks the package withPOST /v0/purl. Two things went wrong there.spawnCoanaDlx(andrunCdxgen) passSOCKET_CLI_SHADOW_API_TOKEN: SOCKET_PUBLIC_API_TOKENandSOCKET_CLI_SHADOW_ACCEPT_RISKS: trueover IPC. The npm/npx path forwards these to the injected arborist. The pnpm and yarn bins ignored them and called the purl endpoint with the user's own token. The purl endpoint rejects repository-scoped tokens, so every reachability run with one printedReceived a 403 response from Socket API which we consider a permanent failure: ... This endpoint does not support repository-scoped tokens. The run kept going, but it reads as an auth failure in CI logs.run, the analysis timeout, the memory limit and the manifests tar hash were all looked up as npm packages, e.g.pkg:npm/run. Because accept-risks was also ignored, an alert on any of those names would have made the shadow bin exit 1 and kill the scan.How
scanPackagesAndLogAlertstakes an optionalapiTokenand passes it togetAlertsMapFromPurls. When it's unset, the token falls back to the default, same as before.shadowPnpmBinandshadowYarnBinread the API token and accept-risks fromipc, the same way the npm arborist does. Calls without IPC overrides, like a user runningsocket pnpm dlx foo, behave as before.dlxscans the package option values, or the first positional if there are none. Later positionals belong to the launched binary. Each shadow bin passes aDlxFlagslist naming its package options and the other options that take a value, so values like--allow-build esbuildare skipped before the package is chosen. pnpm uses--package(its-pis--parseable). yarn uses--packageand-p.Testing
src/shadow/pnpm/bin.test.mtsandsrc/shadow/yarn/bin.test.mtscover dlx with tool arguments, dlx with--package, option values before the package, repeated--packagesplit by another option, pnpm-pas a boolean, and IPC token plus accept-risks. They fail without the fix and pass with it.pnpm run check:tscandpnpm run lintpass.Workaround for affected users until this ships:
SOCKET_CLI_COANA_LAUNCHER=npm-installskips dlx and the shadow scan.Expected reviewer effort: Full code review
Note
Medium Risk
Changes API token selection and which packages block
dlxin the shadow security gate used before reachability runs; behavior for direct userdlxwithout IPC is intended to stay the same.Overview
Fixes pnpm and yarn shadow-bin preflight scans when internal callers launch tools via
dlx(e.g. Coana duringsocket scan create --reach).The shadow bins now read
SOCKET_CLI_SHADOW_API_TOKENandSOCKET_CLI_SHADOW_ACCEPT_RISKSfrom IPC (matching npm/npx) and pass the token intogetAlertsMapFromPurls, so the pre-download PURL check no longer hits the API with a repository-scoped user token and spurious 403 errors in CI.dlxparsing is split fromadd: only--package/-pvalues (yarn) or--packageplus pnpm value-taking flags are considered packages; otherwise the first positional is scanned and later args (e.g.run, timeouts) are ignored. Lockfile scans on pnpm also forward the IPC token.Unit tests cover Coana-style
dlxinvocations,--packagehandling, and IPC overrides.Reviewed by Cursor Bugbot for commit 77c1c66. Configure here.