Miggo Logo

CVE-2025-53372:
Node.js Sandbox MCP Server vulnerability can lead to Sandbox Escape via Command Injection

7.5

CVSS Score
3.1

Basic Information

EPSS Score
-
Published
7/8/2025
Updated
7/8/2025
KEV Status
No
Technology
TechnologyJavaScript

Technical Details

CVSS Vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H
Package NameEcosystemVulnerable VersionsFirst Patched Version
node-code-sandbox-mcpnpm<= 1.2.01.3.0

Vulnerability Intelligence
Miggo AIMiggo AI

Miggo AIRoot Cause Analysis

The vulnerability exists because the application uses child_process.execSync and child_process.exec to construct and execute shell commands using unsanitized user input. Specifically, the container_id parameter, and in some cases other parameters like image and command, are directly concatenated into a command string. This allows an attacker to inject shell metacharacters (e.g., $(...), |, &&) and execute arbitrary commands on the host machine where the MCP server is running, effectively escaping the Docker sandbox.

The patch addresses this by replacing all instances of execSync and exec with the safer execFileSync and execFile APIs. These APIs take command arguments as an array, which prevents shell interpretation of the input and mitigates the command injection vulnerability. Additionally, input sanitization functions like sanitizeContainerId and sanitizeShellCommand have been introduced as a defense-in-depth measure.

Vulnerable functions

stopSandbox
src/tools/stop.ts
The function `stopSandbox` is vulnerable to command injection because it uses `execSync` to build a shell command with the `container_id` parameter, which is not sanitized. An attacker can provide a malicious `container_id` with shell metacharacters to execute arbitrary commands on the host.
forceStopContainer
src/dockerUtils.ts
The function `forceStopContainer` is vulnerable to command injection because it uses `execPromise` (a promisified version of `exec`) to build shell commands with the `containerId` parameter, which is not sanitized. An attacker can provide a malicious `containerId` with shell metacharacters to execute arbitrary commands on the host.
safeExecNodeInContainer
src/dockerUtils.ts
The function `safeExecNodeInContainer` is vulnerable to command injection because it uses `execSync` to build a shell command with the `containerId` and `command` parameters. Although `command` is wrapped in `JSON.stringify`, `containerId` is not sanitized, allowing an attacker to inject shell metacharacters and execute arbitrary commands.
execInSandbox
src/tools/exec.ts
The function `execInSandbox` is vulnerable to command injection because it uses `execSync` to build a shell command with the `container_id` parameter, which is not sanitized. An attacker can provide a malicious `container_id` with shell metacharacters to execute arbitrary commands on the host.
initializeSandbox
src/tools/initialize.ts
The function `initializeSandbox` is vulnerable to command injection because it uses `execSync` to build a shell command with multiple parameters, including `containerId` and `image`, which are not sanitized. An attacker can provide malicious input to execute arbitrary commands on the host.
runJs
src/tools/runJs.ts
The function `runJs` is vulnerable to command injection because it uses `execSync` multiple times to build shell commands with the `container_id` parameter, which is not sanitized. An attacker can provide a malicious `container_id` with shell metacharacters to execute arbitrary commands on the host.
runJsEphemeral
src/tools/runJsEphemeral.ts
The function `runJsEphemeral` is vulnerable to command injection because it uses `execSync` multiple times to build shell commands with parameters like `containerId` and `image`, which are not sanitized. An attacker can provide malicious input to execute arbitrary commands on the host.

WAF Protection Rules

WAF Rule

### Summ*ry * *omm*n* inj**tion vuln*r**ility *xists in t** `no**-*o**-s*n**ox-m*p` M*P S*rv*r. T** vuln*r**ility is **us** *y t** uns*nitiz** us* o* input p*r*m*t*rs wit*in * **ll to `**il*_pro**ss.*x**Syn*`, *n**lin* *n *tt**k*r to inj**t *r*itr*r

Reasoning

T** vuln*r**ility *xists ****us* t** *ppli**tion us*s `**il*_pro**ss.*x**Syn*` *n* `**il*_pro**ss.*x**` to *onstru*t *n* *x**ut* s**ll *omm*n*s usin* uns*nitiz** us*r input. Sp**i*i**lly, t** `*ont*in*r_i*` p*r*m*t*r, *n* in som* **s*s ot**r p*r*m*t*