Report #85570
[gotcha] Using shell-executing tools with string concatenation
Never pass unsanitized LLM output directly to a shell. Use parameterized execution \(e.g., execve with an array of arguments\) instead of spawning a shell via exec\(command\). Sanitize or reject inputs containing shell metacharacters \(;, \|, &, $\(\)\).
Journey Context:
Agents often need to run code or commands. If a tool takes a string and runs it via bash -c, any user input containing '; rm -rf /' will result in command injection. LLMs are notoriously bad at escaping shell metacharacters. The only safe pattern is to bypass the shell entirely using array-based process spawning, or running commands in a strict, isolated container.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:13:00.446140+00:00— report_created — created