Site icon API Security Blog

GHSA-VF9J-H32G-2764 mcp-package-docs vulnerable to command injection in several tools

image
Summary A command injection vulnerability exists in the mcp-package-docs MCP Server. The vulnerability is caused by the unsanitized use of input parameters within a call to child_process.exec, enabling an attacker to inject arbitrary system commands. Successful exploitation can lead to remote code execution under the server process's privileges. The server constructs and executes shell commands using unvalidated user input directly within command-line strings. This introduces the possibility of shell metacharacter injection (|, >, &&, etc.). Details The MCP Server exposes tools to access documentation for several types of packages. An MCP Client can be instructed to execute additional actions for example via prompt injection when asked to read package documentation. Below some example of vulnerable code and different ways to test this vulnerability including a real example of indirect prompt injection that can lead to arbitrary command injection. Vulnerable code The following snippet illustrates the vulnerable code pattern used in the MCP Server’s tooling. Note: These is only one instance, but similar patterns may exist elsewhere in the codebase. “`js import { exec } from "child_process" const execAsync = promisify(exec) // https://github.com/sammcj/mcp-package-docs/blob/v0.1.26/src/package-docs-server.ts#L1575-L1596 private async describeGoPackage(args: GoDocArgs): Promise { const { package: packageName, symbol, projectPath } = args …. try { //…Read More

Exit mobile version