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:
Teknium 2026-04-05 12:46:07 -07:00 committed by GitHub
parent b63fb03f3f
commit 4494fba140
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 334 additions and 0 deletions

View file

@ -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,