AI agents can be forced to run arbitrary system commands via prompt injection
Argument injection can achieve remote code execution in AI agents that rely on pre-approved command allowlists.
AI/ML Trail of Bits 22 Oct 2025 Attack Real-world evidence
Published as “Prompt injection to RCE in AI agents”
Why it matters
Developers must move beyond simple command allowlists and adopt sandboxing or strict facade patterns to prevent RCE via prompt injection.
Summary
The authors examined three popular AI agent platforms that execute system commands based on a safe-command allowlist. By crafting a single malicious prompt they injected arguments into allowed utilities (e.g., go test, git show, ripgrep) to execute bash and curl, achieving remote code execution without human approval. The attacks work both directly and when the malicious payload is hidden in comments or repository files. They demonstrate that simple allowlist filtering is insufficient and recommend sandboxing or a facade pattern with argument separators as mitigations.
What they found 2
- Remote code execution can be achieved with a single malicious prompt in agents that allow pre-approved commands.
“In all cases, we required that RCE could be achieved with a single prompt (i.e., one-shot).”
- The attack uses allowed utilities’ flags to inject bash and curl commands.
“It executes bash andcurl with a pipe operator to achieve remote code execution.”
Caveats 2
- It should be said that cloud-based versions of these agents already implement sandboxing to protect against catastrophic breaches.
- we cannot name the products in this post due to ongoing coordinated disclosure
What’s new here 4
- Identifies argument injection as a distinct RCE vector in AI agents.
- Shows one-shot remote code execution on three different production agent platforms.
- Demonstrates that safe-command allowlists can be bypassed via flag manipulation.
- Provides concrete defensive guidance, emphasizing sandboxing and proper argument separation.