Skip to content

fix(scanner): classify Windows npx.cmd/uvx.exe as package runners - #1779

Merged
Dumbris merged 1 commit into
smart-mcp-proxy:mainfrom
rudycelekli:fix/scanner-runner-windows-ext-20261024-01
Oct 26, 2026
Merged

Dumbris merged 1 commit into
smart-mcp-proxy:mainfrom
rudycelekli:fix/scanner-runner-windows-ext-20261024-01

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

Problem

The security scanner's source resolver gets the runner name from filepath.Base(info.Command) and compares it exactly against npx, uvx, pnpm and so on. On Windows the command is commonly npx.cmd, uvx.exe or pnpm.cmd, so:

  • isPackageRunnerCommand returns false and the package-cache-first lookup is skipped. Arg scanning can then pick a data-dir argument (for example the filesystem server's allowed root) as the server source, which is the case that ordering exists to prevent.
  • The published-package fetch (resolveFromPackageFetch) is gated on the same check, so a quarantined server falls back to a tool-definitions-only scan.
  • npxTargetPackage and uvxTargetPackage return "".

Fix

Add runnerBase(command), which returns the lowercased base name with a .exe, .cmd or .bat suffix removed. Use it everywhere the runner name is derived: isPackageRunnerCommand, npxTargetPackage, uvxTargetPackage, resolveFromPackageCache, the two runnerPackageSpec calls, and the package-fetch dispatch. Unsuffixed names are unchanged.

Test

TestPackageRunner_WindowsExecutableSuffix covers npx.cmd, NPX.CMD, uvx.exe and pnpm.cmd dlx, a non-runner node.exe, and the npx/uvx target-package helpers. On main the four runner checks and both target lookups fail; with this change they pass. go test -count=1 ./internal/security/scanner/ passes.

Made with Cursor

The source resolver matched runner commands by exact base name, so a
Windows server launched with npx.cmd, uvx.exe or pnpm.cmd was not a
package runner. The package-cache-first lookup was skipped, letting arg
scanning pick a data-dir argument as server source, and the published
package fetch never ran. Strip a .exe, .cmd or .bat suffix (and
lowercase) wherever the runner name is derived.
@rudycelekli
rudycelekli force-pushed the fix/scanner-runner-windows-ext-20261024-01 branch from eaad1cd to 6b702d6 Compare October 24, 2026 22:18
@codecov-commenter

codecov-commenter commented Oct 25, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/security/scanner/source_resolver.go 91.66% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@Dumbris Dumbris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified: the PR test fails on main for the reason described and passes on this branch merged with main; race tests for the touched packages and CI lint (bare and server tags) are clean. Also built and tested together with the rest of this batch, independently reviewed, and cross-reviewed with a second model.

@Dumbris
Dumbris merged commit c087de7 into smart-mcp-proxy:main Oct 26, 2026
49 checks passed
@Dumbris

Dumbris commented Oct 26, 2026

Copy link
Copy Markdown
Member

Merged. Thank you, @rudycelekli! The scanner recognises npx.cmd/uvx.exe as package runners on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants