GHSA-3CH2-JXXC-V4XF
Vulnerability from github – Published: 2025-09-08 19:42 – Updated: 2025-09-10 21:03Command Injection in MCP Server
The MCP Server at https://github.com/akoskm/create-mcp-server-stdio is written in a way that is vulnerable to command injection vulnerability attacks as part of some of its MCP Server tool definition and implementation.
Vulnerable tool
The MCP Server exposes the tool which-app-on-port which relies on Node.js child process API exec which is an unsafe and vulnerable API if concatenated with untrusted user input.
Vulnerable line of code: https://github.com/akoskm/create-mcp-server-stdio/blob/main/src/index.ts#L24-L40
server.tool("which-app-on-port", { port: z.number() }, async ({ port }) => {
const result = await new Promise<ProcessInfo>((resolve, reject) => {
exec(`lsof -t -i tcp:${port}`, (error, pidStdout) => {
if (error) {
reject(error);
return;
}
const pid = pidStdout.trim();
exec(`ps -p ${pid} -o comm=`, (error, stdout) => {
if (error) {
reject(error);
return;
}
resolve({ command: stdout.trim(), pid });
});
});
});
Exploitation
When LLMs are tricked through prompt injection (and other techniques and attack vectors) to call the tool with input that uses special shell characters such as ; rm -rf /tmp;# (be careful actually executing this payload) and other payload variations, the full command-line text will be interepted by the shell and result in other commands except of ps executing on the host running the MCP Server.
Reference example from prior security research on this topic:

Impact
User initiated and remote command injection on a running MCP Server.
Recommendation
- Don't use
exec. UseexecFileinstead, which pins the command and provides the arguments as array elements. - If the user input is not a command-line flag, use the
--notation to terminate command and command-line flag, and indicate that the text after the--double dash notation is benign value.
References and Prior work
- Exploiting MCP Servers Vulnerable to Command Injection
- Liran's Node.js Secure Coding: Defending Against Command Injection Vulnerabilities
Disclosed by Liran Tal
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "@akoskm/create-mcp-server-stdio"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.0.13"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2025-54994"
],
"database_specific": {
"cwe_ids": [
"CWE-77",
"CWE-78"
],
"github_reviewed": true,
"github_reviewed_at": "2025-09-08T19:42:34Z",
"nvd_published_at": "2025-09-08T20:15:35Z",
"severity": "CRITICAL"
},
"details": "# Command Injection in MCP Server\n\nThe MCP Server at https://github.com/akoskm/create-mcp-server-stdio is written in a way that is vulnerable to command injection vulnerability attacks as part of some of its MCP Server tool definition and implementation.\n\n## Vulnerable tool\n\nThe MCP Server exposes the tool `which-app-on-port` which relies on Node.js child process API `exec` which is an unsafe and vulnerable API if concatenated with untrusted user input.\n\nVulnerable line of code: https://github.com/akoskm/create-mcp-server-stdio/blob/main/src/index.ts#L24-L40\n\n```js\nserver.tool(\"which-app-on-port\", { port: z.number() }, async ({ port }) =\u003e {\n const result = await new Promise\u003cProcessInfo\u003e((resolve, reject) =\u003e {\n exec(`lsof -t -i tcp:${port}`, (error, pidStdout) =\u003e {\n if (error) {\n reject(error);\n return;\n }\n const pid = pidStdout.trim();\n exec(`ps -p ${pid} -o comm=`, (error, stdout) =\u003e {\n if (error) {\n reject(error);\n return;\n }\n resolve({ command: stdout.trim(), pid });\n });\n });\n });\n```\n\n## Exploitation\n\nWhen LLMs are tricked through prompt injection (and other techniques and attack vectors) to call the tool with input that uses special shell characters such as `; rm -rf /tmp;#` (be careful actually executing this payload) and other payload variations, the full command-line text will be interepted by the shell and result in other commands except of `ps` executing on the host running the MCP Server.\n\nReference example from prior security research on this topic:\n\n\n\n## Impact\n\nUser initiated and remote command injection on a running MCP Server.\n\n## Recommendation\n\n- Don\u0027t use `exec`. Use `execFile` instead, which pins the command and provides the arguments as array elements.\n- If the user input is not a command-line flag, use the `--` notation to terminate command and command-line flag, and indicate that the text after the `--` double dash notation is benign value.\n\n## References and Prior work\n\n1. [Exploiting MCP Servers Vulnerable to Command Injection](https://snyk.io/articles/exploiting-mcp-servers-vulnerable-to-command-injection/)\n2. Liran\u0027s [Node.js Secure Coding: Defending Against Command Injection Vulnerabilities](https://www.nodejs-security.com/book/command-injection)\n\n##\n\nDisclosed by [Liran Tal](https://lirantal.com)",
"id": "GHSA-3ch2-jxxc-v4xf",
"modified": "2025-09-10T21:03:16Z",
"published": "2025-09-08T19:42:34Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/akoskm/create-mcp-server-stdio/security/advisories/GHSA-3ch2-jxxc-v4xf"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-54994"
},
{
"type": "WEB",
"url": "https://github.com/akoskm/create-mcp-server-stdio/pull/1"
},
{
"type": "WEB",
"url": "https://github.com/akoskm/create-mcp-server-stdio/commit/48c26bbe1f8c62764e4592f33c8300d1cadd2eac"
},
{
"type": "PACKAGE",
"url": "https://github.com/akoskm/create-mcp-server-stdio"
},
{
"type": "WEB",
"url": "https://github.com/akoskm/create-mcp-server-stdio/blob/main/src/index.ts#L24-L40"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N",
"type": "CVSS_V4"
}
],
"summary": "@akoskm/create-mcp-server-stdio is vulnerable to MCP Server Command Injection through `exec` API"
}
Sightings
| Author | Source | Type | Date |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.