AAK-MCP-STDIO-CMD-INJ-003
MCP StdioServerParameters.Builder() built from network-controlled input (Java)
| Field | Value |
|---|---|
| Severity | CRITICAL |
| Category | SUPPLY_CHAIN |
| Shipped | v0.3.6 |
| Scanner | agent_audit_kit/scanners/mcp_stdio_params.py (regex pass) |
| Same metadata as | AAK-MCP-STDIO-CMD-INJ-001 |
What it catches
StdioServerParameters.Builder().command(...).args(...).build() from
io.modelcontextprotocol.sdk.client.stdio after a network-controlled
source: request.getParameter(, HttpServletRequest,
RestTemplate.getForObject(, WebClient.<verb>(,
new ObjectMapper().readValue(, System.getenv(.
Detection
Match StdioServerParameters.Builder() opener; require .build()
within the next 4KB (chain confirmed); look back 2KB and scan the
forward chain for a taint marker. Nested-paren handling is bypassed by
splitting the regex into opener + terminator + window scan.
Remediation
private static final Map<String, String> ALLOWED =
Map.of("server-a", "/usr/bin/server-a");
public StdioServerParameters spawn(String name) {
String cmd = ALLOWED.get(name);
if (cmd == null) throw new IllegalArgumentException("not allowed");
return StdioServerParameters.Builder()
.command(cmd)
.args(new String[]{})
.build();
}
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
McpStdioServerParamsTaintedJava
What it detects
A Java file constructs StdioServerParameters.Builder().command(...).args(...).build() from io.modelcontextprotocol.sdk.client.stdio after a network-controlled source (HttpServletRequest, RestTemplate.getForObject, WebClient, ObjectMapper.readValue(...), System.getenv(...)). Same OX MCP April-2026 class as AAK-MCP-STDIO-CMD-INJ-001.
How to fix
Pin command() to a constant; validate args() against an allow-list. If using Spring, prefer @Value-injected configuration over per-request resolution.
To confirm the finding is gone, report only this rule:
agent-audit-kit scan . --rules AAK-MCP-STDIO-CMD-INJ-003
Limitations
Matches the spelling StdioServerParameters.Builder() followed by .build() in .java files, with a request parameter, HTTP client, ObjectMapper read or System.getenv call in the preceding 2 KB or in the chain. The MCP Java SDK's own ServerParameters.builder(command) is not matched, and neither is the same code in a Kotlin file. 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
- 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