Commands that look read-only, such as find, grep, rg, git and go test, accept flags that run arbitrary programs. Research in 2025 showed one-prompt remote code execution through these flags in production agents, plus prefix-matching bypasses in Gemini CLI. Prefer narrow, exact allow rules and count on the sandbox to contain what slips through.
Read in this order
- ArticlePrompt injection to RCE in AI agents (Trail of Bits)Start here: the flag tricks that turn safe-looking commands into code execution.
- ArticleCode execution through deception: Gemini AI CLI hijack (Tracebit)A real prefix-matching bypass in Gemini CLI, step by step.
- Open sourcetrailofbits/claude-code-configA working hardened config you can copy and compare to yours.