MCP exec() to execFile() Migration: Eliminating the #1 Attack Vector (43% of All MCP CVEs)
Snyk·high signal
Shell injection via child_process.exec() string interpolation accounts for 43% of all MCP-related CVEs filed in early 2026 because exec spawns a shell interpreter that evaluates metacharacters like ;, |, and $(). The fix is a one-line change: replace exec('cmd ' + userInput) with execFile('cmd', [userInput]) — execFile passes arguments as an array directly to the binary, bypassing shell interpretation entirely. Pair with allowlist validation (not blocklist) on input values before they reach any command boundary.