Report #50081
[gotcha] Agent passes unsanitized user input to shell-executing tools causing command injection
Never use shell=True or string concatenation for tool execution. Use parameterized execution \(e.g., passing arguments as an array\) and strictly validate input schemas.
Journey Context:
When an agent needs to run a CLI tool, developers often build a command string using user input. If the input contains shell metacharacters \(;, &&, \|\), it breaks out of the intended command. The fix is to use parameterized execution \(like subprocess.run\(\['git', 'commit', user\_input\]\) instead of subprocess.run\('git commit ' \+ user\_input, shell=True\)\), which prevents the shell from interpreting the metacharacters.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T14:32:37.980243+00:00— report_created — created