AAK-MCP-STDIO-CMD-INJ-001
MCP StdioServerParameters built from network-controlled input (Python)
| Field | Value |
|---|---|
| Severity | CRITICAL |
| Category | SUPPLY_CHAIN |
| Shipped | v0.3.6 (2026-04-26) |
| Scanner | agent_audit_kit/scanners/mcp_stdio_params.py |
| CWE | CWE-78 + CWE-77 |
| OWASP MCP | MCP05:2025 (Command Injection & Execution) |
| OWASP Agentic | ASI05 (Unexpected Code Execution (RCE)) |
| AICM | AIS-08, IAM-05 |
| CVEs | CVE-2026-30615, 30617, 30623, 22252, 22688, 33224, 40933, 6980 |
| Incident | OX-MCP-2026-04-25 |
What it catches
A Python function calls StdioServerParameters(command=..., args=...)
from mcp.client.stdio / modelcontextprotocol.client while also
reading from a network-controlled source (request.json(),
flask.request.*, fastapi.Request.*, os.environ[<var>],
json.loads(<network>), yaml.safe_load(<network>)). The OX MCP
April-2026 disclosure aggregated 8 CVEs to this exact shape: the SDK
executes whatever ends up in command/args verbatim.
This rule is the SDK-named-API config-side counterpart to
AAK-STDIO-001 (see the per-rule index), which detects the broader
subprocess(shell=True) sink shape. Both fire on overlapping inputs;
do not collapse them.
Detection
The Python pass walks the AST and orders calls by source line so
StdioServerParameters invoked after a tainted source is detected even
when the validator and call are nested at different AST depths. Per
function:
- Collect every
Callnode, sort by(lineno, col_offset). - For each call, check if
_attr_chain(call.func)ends inStdioServerParameters. - Scan the enclosing function source for any of:
request.(json|form|args|data|values|headers|files),flask.request.*,fastapi.Request.*,requests.<verb>(...).json(),httpx.<verb>(...).json(),urllib.request.urlopen(,os.environ,json.loads,yaml.safe_load,yaml.load. - If no marker fires, accept the cross-frame hint: function arg named
body/payload/req/request/event/data/config.
Remediation
Pin command to a constant binary path. Look up server choice in a
server-side allow-list keyed by tenant identity, never by a free-form
string in the request:
ALLOWED_BINARIES = {"server-a": "/usr/bin/server-a", "server-b": "/usr/bin/server-b"}
def spawn(name: str) -> StdioServerParameters:
if name not in ALLOWED_BINARIES:
raise ValueError("not allowed")
return StdioServerParameters(command=ALLOWED_BINARIES[name], args=[])
Sister rules
- AAK-MCP-STDIO-CMD-INJ-002 — TypeScript variant
- AAK-MCP-STDIO-CMD-INJ-003 — Java variant
- AAK-MCP-STDIO-CMD-INJ-004 — Rust variant (regex-only)
- AAK-MCP-MARKETPLACE-CONFIG-FETCH-001 — single-line marketplace-fetch shape
Registry reference
This section is generated from the rule registry (agent_audit_kit/rules/builtin.py) when the documentation is built, so it follows the scanner. The rest of the page is hand-written; where the two disagree, the registry is what runs.
- Severity
- CRITICAL
- Category
- Supply Chain (
supply-chain) - Scanner
agent_audit_kit/scanners/mcp_stdio_params.py- Auto-fixable
- No.
- SARIF name
McpStdioServerParamsTainted
What it detects
A Python function calls StdioServerParameters(command=..., args=...) from mcp.client.stdio / modelcontextprotocol.client while also reading from a network-controlled source (request body, fetched JSON, environment variable wired to a webhook, untrusted YAML). The OX MCP April-2026 architectural class makes this exploitable: the SDK executes whatever ends up in command/args verbatim. The same class without the SDK is a hand-rolled launcher: subprocess.Popen, subprocess.run or asyncio.create_subprocess_exec over shlex.split() of a stored server record's command field (server.endpoint_or_command, cfg["command"]), in a class or function that manages MCP STDIO servers, with no executable allowlist between the split and the spawn. A command users register over an application's API is as network-controlled as a request body (CVE-2026-93965, SxDevOps). Both arms are AST within one function, not data flow across functions. See AAK-STDIO-001 for the broader sink-pattern detector; this rule is the launcher-side counterpart.
How to fix
Never build StdioServerParameters.command / .args, or the argv a launcher splits, from a network-controlled value. Pin command to a constant binary path and validate args against an allow-list. If a tenant must pick the server, look the choice up in a server-side allow-list keyed by tenant identity, not by a free-form string in the request. An application that stores user-registered STDIO servers must check the executable, and for npx or uvx the package, against an allowlist before spawning, reject shell metacharacters, and drop PATH / LD_PRELOAD-style keys from the server's environment.
To confirm the finding is gone, report only this rule:
agent-audit-kit scan . --rules AAK-MCP-STDIO-CMD-INJ-001
Limitations
Reads one function at a time. A StdioServerParameters(command=, args=) call counts as tainted when its command or args come straight from a request, HTTP-client, os.environ, json.loads or yaml.load expression, from a parameter named body, payload, req, request, event, untrusted or user_input, or from a local assigned from such an expression. A value that arrives through any other parameter name (def build(spec) called with request.json()), through a helper's return value or through an attribute stored on self is not followed. A source file over 512 KB is not read.
References
- CVE: CVE-2026-30615, CVE-2026-30617, CVE-2026-30623, CVE-2026-22252, CVE-2026-22688, CVE-2026-33224, CVE-2026-40933, CVE-2026-6980, CVE-2026-93965
- OWASP MCP Top 10: MCP05:2025 (Command Injection & Execution)
- OWASP Agentic Top 10: ASI05 (Unexpected Code Execution (RCE))
- Adversa AI MCP Top 25 (AAK-defined ids): ADV-INJECT-04 (Tool Param Shell Injection)
- Incidents and advisories: OX-MCP-2026-04-25
- CSA AI Controls Matrix (AICM): AIS-08, IAM-05