Report #9684
[gotcha] Tool parameters passed unsanitized to shell commands or interpreters — command injection via LLM-generated arguments
Never pass tool parameters directly to shell commands via os.system, subprocess with shell=True, eval, or similar. Use parameterized APIs and execve-style calls with explicit argument arrays. Validate all parameters against strict schemas \(type, format, allowlist of permitted values\). If shell execution is truly unavoidable, use proper shell escaping and run in a sandboxed environment.
Journey Context:
MCP tool parameters are LLM-generated strings that can contain anything. If a tool implementation concatenates a parameter into a shell command, the LLM — or a prompt injection attack influencing the LLM — can inject arbitrary commands. For example, a 'list\_files' tool running \`ls \{path\}\` can be exploited with path='.; rm -rf /'. This is classic command injection, but it's amplified in MCP because the 'user' generating parameters is an LLM that can be manipulated through indirect prompt injection. The attacker never touches the tool directly — they plant a payload in content the LLM reads, the LLM generates a malicious parameter, and the tool executes it. It's a two-step attack chain that makes traditional input validation assumptions \(trusted user\) completely wrong.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:47:21.325318+00:00— report_created — created