AAK-MCP-002: MCP server command runs with shell expansion
- Severity
- CRITICAL
- Category
- MCP Configuration (
mcp-config) - Scanner
agent_audit_kit/scanners/mcp_config.py- Auto-fixable
- No.
- SARIF name
McpCommandShellInjection
What it detects
An MCP server command contains shell metacharacters or shell wrappers (sh -c, bash -c). This enables command injection via argument composition.
How to fix
Put only the program in command and every argument in args. This rule matches sh -c, bash -c, cmd /c and any of |, ;, &, $, (, ) or a backtick in command, so a path such as $HOME/bin/server, or one containing parentheses, fires it too. A VS Code variable such as ${workspaceFolder}, which VS Code substitutes itself, does not.
To confirm the finding is gone, report only this rule:
agent-audit-kit scan . --rules AAK-MCP-002
Limitations
Looks only at the command string of each server in mcpServers, or servers in VS Code's .vscode/mcp.json, for one of the characters | ; & $ ( ) or a leadingsh -c,bash -c,cmd /corcmd.exe /c, after removing any VS Code variable (${workspaceFolder},${userHome},${env:...}and the others VS Code documents), which VS Code substitutes itself. The same wrapper split intocommand: bashandargs: ["-c", ...]` is not read by this rule.
References
- 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-01 (Shell Injection via MCP)
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-MCP-002.md: the page then shows that text, with the registry reference appended under it.