Report #79860
[gotcha] Agent interpolates MCP tool names or arguments directly into shell commands without sanitization
Never use string concatenation or f-strings to build shell commands from LLM-generated tool arguments. Use parameterized execution \(e.g., \`subprocess.run\(\["git", "commit", arg\], ...\)\`\) and strictly validate tool names against an allowlist before mapping them to functions.
Journey Context:
Some agent frameworks dynamically route tool calls by mapping the tool name string directly to a function or shell command \(e.g., \`os.system\(f"run\_\{tool\_name\} \{args\}"\)\`\). If the LLM is manipulated into calling a tool with a name like \`rm -rf / ;\` or arguments containing shell metacharacters \(\`; & \|\`\), it results in direct command injection on the host machine.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:38:41.879962+00:00— report_created — created