You can safeguard against this by having a whitelist of commands that can be run, basically cd, ls, find, grep, the build tool, linter, etc that are only informational and local. Mine is set up like that and it works very well.
cmd.split(" ") in ["cd", "ls", ...]
is easy target for command injections. just to think of a few: ls . && evil.sh
ls $(evil.sh)Amazon Q Developer: Remote Code Execution with Prompt Injection
https://embracethered.com/blog/posts/2025/amazon-q-developer...
Previously you might've been able to say "okay, but that requires the attacker to guess the specifics of my environment" - which is no longer true. An attacker can now simply instruct the LLM to exploit your environment and hope the LLM figures out how to do it on its own.
Doesn't this give the LLM the ability to execute arbitrary scripts?