Report #42187
[gotcha] Unsanitized MCP tool parameters concatenated into shell commands cause Remote Code Execution
Use structured parameters \(objects/arrays\) and strict input validation; avoid string concatenation for shell commands entirely by using safe APIs like subprocess.run with argument lists.
Journey Context:
An MCP tool exposes a run\_git function. The agent passes user input directly as an argument. If the server naively concatenates it into os.system\(f'git \{args\}'\), a malicious input like 'status; rm -rf /' leads to RCE on the server host. Developers often forget that LLM-generated arguments are essentially user input.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T01:16:58.577944+00:00— report_created — created