MCPHub Path Traversal Vulnerability via Malicious MCPB Manifest Name
MCPHub is vulnerable to path traversal, where a malicious MCPB file with a crafted manifest.name can cause files to be extracted to arbitrary locations due to missing sanitization in the upload handler.
MCPHub is vulnerable to a path traversal vulnerability affecting versions prior to 0.12.13. The vulnerability exists in the MCPB file upload handler, which extracts a ZIP file and reads the manifest.json file. The name field from the manifest is directly concatenated into the file path without any sanitization or path traversal character validation. This allows an attacker to craft a malicious MCPB file with a manifest.name containing directory traversal sequences (e.g., ../../../etc/malicious), leading to arbitrary file extraction and potential directory deletion via the cleanupOldMcpbServer function. This vulnerability poses a significant risk to systems running vulnerable versions of MCPHub, potentially allowing attackers to overwrite critical system files or execute arbitrary code.
Attack Chain
- An attacker crafts a malicious MCPB file.
- The malicious MCPB file contains a
manifest.jsonfile with anamefield set to a path traversal string (e.g.,../../../tmp/evil). - The attacker uploads the malicious MCPB file to the
/mcpb/uploadendpoint. - The
uploadMcpbFilefunction extracts the uploaded MCPB file to a temporary directory. - The function reads and parses the
manifest.jsonfile from the temporary directory. - The
manifest.namevalue (containing the path traversal string) is used to construct the final extraction directory path usingpath.join. - The server attempts to create the directory specified by the crafted path and moves the extracted files to this location. Due to the path traversal, the files are written outside the intended directory.
- The
cleanupOldMcpbServerfunction may be triggered, attempting to delete directories based on the unsanitized name, though constrained to the upload directory.
Impact
Successful exploitation of this path traversal vulnerability allows an attacker to write files to arbitrary locations on the server’s file system. This could lead to overwriting critical system files, injecting malicious code into existing applications, or gaining unauthorized access to sensitive data. The exact impact depends on the permissions of the user running the MCPHub application and the contents of the files being written. If the attacker can overwrite executable files or configuration files, they could achieve arbitrary code execution and full system compromise.
Recommendation
- Apply the remediation recommendations from the original advisory: Use
path.basename()to strip directory components frommanifest.name, and enforce a strict character whitelist before use. - Deploy the Sigma rule “Detect MCPHub Path Traversal Attempt via Manifest Name” to identify attempts to exploit this vulnerability by monitoring for specific path traversal sequences in the manifest name (see Sigma rule).
- Upgrade MCPHub to version 0.12.13 or later to patch this vulnerability.
Detection coverage 2
Detect MCPHub Path Traversal Attempt via Manifest Name
highDetects path traversal attempts in MCPHub by monitoring for specific sequences in the manifest name during file uploads.
Detect MCPHub Manifest Name with Suspicious Characters
mediumDetects MCPHub manifest uploads with potentially malicious characters in the manifest name, indicating a possible path traversal attempt.
Detection queries are kept inside the platform. Get full rules →