Report #68560
[gotcha] MCP tool executing arbitrary shell commands from LLM arguments
Use parameterized commands or strict allowlists instead of string interpolation for tool execution; never pass raw LLM-generated arguments directly to a shell \(e.g., bash, sh\).
Journey Context:
It's tempting to build flexible tools using string interpolation like \`os.system\(f"git commit -m \{message\}"\)\`. However, LLMs can be tricked via prompt injection into generating arguments containing shell metacharacters \(e.g., \`; rm -rf /\`\). Parameterized execution or strict input validation prevents the shell from interpreting malicious payloads.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T21:33:44.229424+00:00— report_created — created