OS Command Injection in token-optimizer-mcp via smart_user
The token-optimizer-mcp package is vulnerable to OS command injection via the smart_user tool due to insecure interpolation of user-supplied input into shell commands, allowing arbitrary command execution with application privileges.
The @ooples/token-optimizer-mcp package (versions prior to 5.1.0) contains an OS command injection vulnerability within the smart_user tool's get-user-info operation. The application insecurely interpolates the user-provided username argument directly into a shell command string that is subsequently executed using execAsync().
The implementation uses the pattern getent passwd "${username}" || grep "^${username}:" /etc/passwd. Because POSIX shells evaluate command substitution syntax such as $(...) and backticks even when enclosed in double quotes, the application fails to sanitize malicious inputs. An attacker capable of invoking the smart_user tool through an MCP client can inject shell metacharacters to execute arbitrary commands with the identity and permissions of the process running the MCP server. This vulnerability, identified as CVE-2026-55157, poses a significant risk to the integrity and confidentiality of the host environment.
Attack Chain
- An attacker gains access to an MCP client that can interact with the token-optimizer-mcp server.
- The attacker identifies the
smart_usertool as a potential vector for interaction with the operating system. - The attacker crafts a malicious JSON-RPC request for the
tools/callmethod targeting thesmart_usertool. - The
usernameargument is populated with an injection payload, such as$(id > /tmp/pwned). - The MCP server receives the request and passes the malicious string into the
get-user-infotool implementation. - The
execAsync()function executes the shell command containing the attacker-controlled payload. - The POSIX shell parses the command substitution inside the double quotes, triggering the execution of the injected command.
- The injected command runs with the privileges of the MCP server, potentially leading to system compromise or data exfiltration.
Impact
Successful exploitation allows for arbitrary code execution with the privileges of the user running the MCP server process. This can lead to unauthorized access to system resources, potential lateral movement, and the execution of malicious tasks such as file creation or data exfiltration. The vulnerability impacts all environments where @ooples/token-optimizer-mcp version 5.0.1 or earlier is deployed.
Recommendation
- Upgrade
@ooples/token-optimizer-mcpto version 5.1.0 or later immediately to patch CVE-2026-55157. - Implement input validation and sanitization for all user-supplied arguments passed to shell execution functions.
- Replace calls to shell-interpreting functions like
execAsync()with safer alternatives that do not invoke a shell (e.g., usingexecFile()with distinct argument arrays). - Deploy the suggested Sigma rule to monitor for child processes spawned by the MCP server process.
Immediate actions
Patch token-optimizer-mcp to version 5.1.0
Deploy Sigma detection rule to identify potential shell injection attempts
Detection coverage 1
Detects CVE-2026-55157 Exploitation - Suspicious Shell Spawning from Nodejs
highDetects the MCP server process spawning shell commands, which may indicate command injection exploitation of the smart_user tool.
Detection queries are available on the platform. Get full rules →