Report #85770
[gotcha] LLM-generated tool arguments contain shell metacharacters causing command injection
Never concatenate tool parameters into shell commands; use parameterized execution \(e.g., subprocess.run with an array of args\); enforce strict JSON schema validation \(type, pattern\) on the MCP server side.
Journey Context:
The LLM is instructed to find a file named 'foo; rm -rf /'. It passes this to a tool that runs 'cat $\{filename\}'. This is classic command injection, but the vector is the LLM's natural language parsing rather than a web form. Developers often trust the LLM to sanitize inputs or assume structured JSON output prevents injection, which is false.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:33:06.242515+00:00— report_created — created