Skip to content

AAK-STDIO-001: MCP STDIO command-injection (Ox architectural class)

Severity
CRITICAL
Category
MCP Configuration (mcp-config)
Scanner
agent_audit_kit/scanners/stdio_injection.py
Auto-fixable
No.
SARIF name
McpStdioCommandInjection

What it detects

User-controllable input flows into a STDIO command executor in an MCP server implementation — the architectural shape Ox Security traced through CVE-2026-30615 (Windsurf RCE) and nine other CVEs across ~200,000 exposed servers. Matches subprocess / os.system / os.popen / os.exec / eval / exec where an arg references a taint source (request params, stdin, @tool parameter, json.loads(stdin)). TS/JS variant: child_process.spawn / execa with {shell:true} or a request-derived command string.

How to fix

Never pass caller-controlled data into a shell. Use argv lists (subprocess.run([...]) without shell=True), allowlist the command set, and validate arguments against an explicit schema. For TS, pass argv as an array with shell:false and validate every element against a regex or allowlist.

To confirm the finding is gone, report only this rule:

agent-audit-kit scan . --rules AAK-STDIO-001

Limitations

A Python value counts as caller input when it is named stdin, request, req, event, params, tool_input, input_data, args or payload, or is a parameter of a function whose decorator name ends in tool (@mcp.tool, @mcp.tool(), @server.call_tool()). The sinks are the subprocess run, call, Popen, check_call and check_output calls, os.system, os.popen, os.execv, os.execvp, commands.getoutput, eval and exec, also under an imported name (import subprocess as sp, from subprocess import run), and a call whose last name is run, call, Popen, check_call, check_output, system, popen, exec or eval on a receiver whose name says executor (shell, process, sandbox, terminal, command, runner and similar). So asyncio.create_subprocess_shell is not one, and neither is an executor behind a short name, such as Fabric's c.run(cmd). In TS/JS it opens only .ts, .tsx, .js, .jsx and .mjs files (not .cjs, .mts or .cts) of 512,000 bytes or less that name StdioServerParameters, createServer, McpServer or mcp.server, in any case, or carry @tool. The stdio: key the same list names matches only when a letter, digit or underscore follows the colon directly (stdio:true), so a file whose only hint is stdio: true or { stdio: "pipe" } is not opened. In TypeScript a command counts as request-derived only when its text contains req, request, body, params, event, stdin or tool_input, so a destructured tool argument (exec(git log ${branch})) is not.

References


All rules. This page is generated from the rule registry when the documentation is built; to change it, change the rule in agent_audit_kit/rules/builtin.py. To give the rule a hand-written write-up, add docs/rules/AAK-STDIO-001.md: the page then shows that text, with the registry reference appended under it.