T07 · Tool Hijacking and Spoofing
- Location
minimax_mcp.py:12- Finding
Relative MCP Path Enables Credential-Bearing Tool Hijacking
- Content
View full analysis
Vulnerability Details
File Location:
minimax_mcp.py, lines 12-58
Vulnerability Type: Local dependency path hijacking
Risk Level: HighVulnerable Code
python MCP_PATH = "node_modules/@ameno/pi-minimax-mcp/bin/pi-minimax-mcp.js" def run_mcp_command(command, args): """Run MiniMax MCP command""" api_key = get_api_key() if not api_key: return "Error: No API key found. Set MINIMAX_API_KEY or create ~/.openclaw/credentials/minimax.json" # Build command cmd = ['node', MCP_PATH, command] + args # Set environment env = os.environ.copy() env['MINIMAX_API_KEY'] = api_key env['MINIMAX_API_HOST'] = DEFAULT_API_HOST # Run try: result = subprocess.run( cmd, capture_output=True, text=True, env=env, timeout=120 )Technical Analysis
MCP_PATHis a relative path resolved from the process's current working directory. The documentation instructs users to install the MCP package globally, but the implementation does not resolve or invoke a trusted global installation. Instead, it executes any JavaScript file present at the expected relativenode_modulespath.Before execution, the wrapper reads the MiniMax API key and places it in the child process environment. Consequently, a spoofed JavaScript file receives both arbitrary code execution in the user's security context and direct access to
MINIMAX_API_KEY.Passing
cmdas an argument list withoutshell=Trueprevents conventional shell metacharacter injection throughcommandorargs, but it does not mitigate executable path substitution.Attack Path
- An attacker gains the ability to create files in a directory from which the user may invoke the wrapper, such as an untrusted downloaded project.
- The attacker creates:
node_modules/@ameno/pi-minimax-mcp/bin/pi-minimax-mcp.js. ...[truncated 1009 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not resolve security-sensitive executables relative to the current working directory.
- Install the dependency in a controlled, project-local environment and resolve it from the wrapper's own directory using an absolute canonical path.
- Pin the exact reviewed package version and verify its integrity before execution.
- Confirm that the resolved script is a regular file inside the expected installation directory and reject symlinks or paths under untrusted writable projects.
- Consider invoking a verified package entry point rather than constructing a path into
node_modules. - Minimize the child environment instead of copying all of
os.environ; provide only variables required by the MCP process. - Where supported, use a narrowly scoped token and rotate the existing key if the wrapper has been run from untrusted directories.
