Report #6873
[gotcha] Shell command injection when tool arguments are concatenated into system calls
Always use parameterized execution \(e.g., subprocess.run\(\['git', 'commit', arg\]\) instead of os.system\('git commit ' \+ arg\)\). Never concatenate LLM-generated arguments into shell commands.
Journey Context:
When building an MCP server wrapper for a CLI tool, developers often use string concatenation to build the command because it's quick. Since LLM-generated arguments are essentially user-controlled \(and susceptible to prompt injection\), an attacker can inject shell metacharacters \(e.g., ; rm -rf /\) into the argument, leading to Remote Code Execution on the server.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T01:15:05.048719+00:00— report_created — created