GHSA-45qj-4xq3-3c45: mcp-markdownify-server vulnerable to command injection in pptx-to-markdown tool
SummaryA command injection vulnerability exists in the `mcp-markdownify-server` 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.).DetailsThe MCP Server exposes tools to perform several file operations.  An MCP Client can be instructed to execute additional actions for example via indirect prompt injection when asked to read an `md` file. 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 codeThe following snippet illustrates the vulnerable code pattern used in the MCP Server’s tooling.`pptx-to-markdown`PoCsetupIndirect prompt injection via md file contentAn MCP Client can be instructed to execute additional actions for example via indirect prompt injection in md files. The following PoC shows how reading an md file can lead to execution of additional tools vulnerable to command injection.When the client reads an md file as part of its contextual input, it may inadvertently interpret injected instructions embedded in the file as legitimate commands or follow-up instructions.This behavior can be exploited to cause the model to execute unintended actions, leading to an arbitrary command execution on the host where the MCP server is running.create a file `file.md` with the following content:Verify the file `/tmp/TEST`1 does **not** exist:setup your client IDEopen the chat and enter the following prompt (it's an example) - replace `/path/to/` with the absolute path to `file.md`run the `get-markdown-file` toolObserve that the response will contain the the file content but will also trigger the `pptx-to-markdown` tool execution with a malicious payload that can lead to command injectionrun the `pptx-to-markdown` toolConfirm that the injected command executed:Using MCP InspectorOpen the MCP Inspector:In MCP Inspector:set transport type: `STDIO`set the `command` to nodeset the arguments to `{ABSOLUTE PATH TO FILE HERE}/dist/index.js`click Connectgo to the **Tools** tab and click **List Tools**select the `pptx-to-markdown` toolVerify the file `/tmp/TEST` does **not** exist:In the **filepath** field, input:Click **Run Tool**Observe the request being sent:Confirm that the injected command executed:ImpactCommand Injection / Remote Code Execution (RCE)RemediationTo mitigate this vulnerability, I suggest to avoid using `child_process.exec` with untrusted input. Instead, use a safer API such as [`child_process.execFile`](https://nodejs.org/api/child_process.html#child_processexecfilefile-args-options-callback), which allows you to pass arguments as a separate array - avoiding shell interpretation entirely.
Note: given that the `uvPath` can be relative (i.e. `"~/.local/bin/uv"`), I suggest to consider `untildify` (https://www.npmjs.com/package/untildify) package to convert a tilde path to an absolute path before passing to `child_process.execFile`. Something like the following (not tested):Referenceshttps://security.snyk.io/vuln/SNYK-JS-MCPMARKDOWNIFYSERVER-10249193 (very similar to this issue but exploits a different vulnerability)https://security.snyk.io/vuln/SNYK-JS-MCPMARKDOWNIFYSERVER-10249387 (very similar to this issue but exploits a different vulnerability)https://equixly.com/blog/2025/03/29/mcp-server-new-security-nightmare/https://invariantlabs.ai/blog/mcp-github-vulnerability
CVSS v3.1: 7.5