Skip to the content
AI and Cybersecurity Learning and Practice Center Test automation Open the Learning Center

IncidentCoding assistants

Gemini CLI: a README prompt injection runs hidden commands

HighGoogle

A booby-trapped README could make Google's Gemini CLI secretly run commands on a developer's computer and send their secrets out, combining prompt injection with a weak allowlist check and a misleading display.

Replay the attack step by step in the Learning Center

How it happened

  1. The attacker hides instructions in a README, buried in license text people skim.
  2. The developer asks Gemini CLI to explore the untrusted repository.
  3. The injection first gets a harmless grep approved and allowlisted.
  4. It then runs a command that starts with grep but chains a second command that sends environment variables out; whitespace padding hides it on screen.

Impact

Silent code execution on the developer's machine, including theft of credentials in environment variables.

The fix

Fixed in Gemini CLI 0.1.14 (July 25, 2025), which shows the full command and asks before running additional programs.

Lessons

  • Command allowlists must parse the whole shell command, including chained commands.
  • Run coding agents on untrusted repositories in a sandbox with no secrets.
  • Approval prompts must show exactly what will run.

Sources