feat: OSV malware check for MCP extension packages (#5305)
Before launching an MCP server via npx/uvx, queries the OSV (Open Source Vulnerabilities) API to check if the package has known malware advisories (MAL-* IDs). Regular CVEs are ignored — only confirmed malware is blocked. - Free, public API (Google-maintained), ~300ms per query - Runs once per MCP server launch, inside _run_stdio() before subprocess spawn - Parallel with other MCP servers (asyncio.gather already in place) - Fail-open: network errors, timeouts, unrecognized commands → allow - Parses npm (scoped @scope/pkg@version) and PyPI (name[extras]==version) Inspired by Block/goose extension malware check.
This commit is contained in:
@@ -833,6 +833,15 @@ class MCPServerTask:
|
||||
|
||||
safe_env = _build_safe_env(user_env)
|
||||
command, safe_env = _resolve_stdio_command(command, safe_env)
|
||||
|
||||
# Check package against OSV malware database before spawning
|
||||
from tools.osv_check import check_package_for_malware
|
||||
malware_error = check_package_for_malware(command, args)
|
||||
if malware_error:
|
||||
raise ValueError(
|
||||
f"MCP server '{self.name}': {malware_error}"
|
||||
)
|
||||
|
||||
server_params = StdioServerParameters(
|
||||
command=command,
|
||||
args=args,
|
||||
|
||||
Reference in New Issue
Block a user