Report #86170
[gotcha] Why are shell metacharacters in tool arguments causing command injection on the MCP server?
MCP servers must use parameterized execution \(e.g., \`execve\` with an argument array\) rather than string concatenation \(\`system\(\)\` or \`shell\_exec\`\) when invoking underlying system commands based on tool inputs.
Journey Context:
Even if the MCP schema defines a string type, the LLM might include shell metacharacters \(like \`; rm -rf /\`\) in the argument if prompted by a user. If the MCP server naively concatenates this string into a shell command, it results in classic OS command injection. Developers assume the LLM will sanitize inputs or that the schema restricts it, but LLMs are unpredictable, and server-side parameterization is the only reliable defense.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T03:13:31.353020+00:00— report_created — created