The vulnerability is a classic command injection issue within the @aiondadotcom/mcp-ssh package, specifically in the server-simple.mjs file. The root cause is the use of child_process.exec (via a promisified execAsync) with untrusted input concatenated directly into the command string. This method of execution involves a shell, which interprets special characters in the input as commands.
The patch, found in commit 5b9b9c5b28d3f2672f356a790154ed68e17ef453, correctly remediates this by replacing all instances of execAsync with execFileAsync. The execFile function is inherently safer for this use case because it treats the command and its arguments as separate entities, passing them directly to the system's executable without invoking a shell. This prevents any shell metacharacters within the arguments from being executed.
The three identified vulnerable functions, SSHClient.runRemoteCommand, SSHClient.uploadFile, and SSHClient.downloadFile, all followed this unsafe pattern of building command strings for ssh and scp operations. An attacker who could control the arguments passed to these functions (such as command, localPath, or remotePath) could execute arbitrary commands on the machine running the mcp-ssh agent, leading to a remote code execution (RCE) vulnerability.