GHSA-3ch2-jxxc-v4xf

Suggest an improvement
Source
https://github.com/advisories/GHSA-3ch2-jxxc-v4xf
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/09/GHSA-3ch2-jxxc-v4xf/GHSA-3ch2-jxxc-v4xf.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-3ch2-jxxc-v4xf
Aliases
Published
2025-09-08T19:42:34Z
Modified
2025-09-10T21:03:16Z
Severity
  • 9.3 (Critical) CVSS_V4 - 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 CVSS Calculator
Summary
@akoskm/create-mcp-server-stdio is vulnerable to MCP Server Command Injection through `exec` API
Details

Command 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:

Cursor defined MCP Server vulnerable to command injection

Impact

User initiated and remote command injection on a running MCP Server.

Recommendation

  • Don't use exec. Use execFile instead, 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

  1. Exploiting MCP Servers Vulnerable to Command Injection
  2. Liran's Node.js Secure Coding: Defending Against Command Injection Vulnerabilities

#

Disclosed by Liran Tal

Database specific
{
    "github_reviewed": true,
    "severity": "CRITICAL",
    "github_reviewed_at": "2025-09-08T19:42:34Z",
    "nvd_published_at": "2025-09-08T20:15:35Z",
    "cwe_ids": [
        "CWE-77",
        "CWE-78"
    ]
}
References

Affected packages

npm / @akoskm/create-mcp-server-stdio

Package

Name
@akoskm/create-mcp-server-stdio
View open source insights on deps.dev
Purl
pkg:npm/%40akoskm/create-mcp-server-stdio

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
0.0.13

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/09/GHSA-3ch2-jxxc-v4xf/GHSA-3ch2-jxxc-v4xf.json"