gemini-mcp-tool
- Type
- MCP server
- Scanned
- Nov 12, 2026
- Version
- 588e73dfff07
- Files read
- 96
This MCP server connects AI coding assistants to Google's Gemini CLI and Antigravity CLI so they can ask questions, brainstorm, and analyze project files. Its biggest risk is that prompt injection in text the AI reads can trick it into passing crafted tool arguments that run arbitrary commands or leak environment secrets—either by injecting CLI flags like --yolo through the unvalidated model parameter or by abusing cmd.exe variable expansion on Windows.
What it can reach
- Shell commands
- Spawns external gemini, agy (Antigravity CLI), echo, and optional script/sh subprocesses; when using the agy backend (which becomes the automatic default on 2026-06-18), the spawned CLI runs agent tools with the user's privileges.
- Files
- Reads project files referenced with @path inside the current working directory, reads Antigravity CLI transcripts and SQLite databases under ~/.gemini/antigravity-cli, and writes cached edit chunks under the system temporary folder.
- Network
- Sends prompts and inlined project files to Google's Gemini or Antigravity cloud services through the underlying CLI, which can also run web searches.
- Secrets
- Forwards the full parent process environment (process.env, including any API keys or tokens) to spawned child processes and uses the user's saved Gemini or Antigravity CLI login.
Findings
-
HighCLI flag injection through unvalidated model parameter can enable YOLO shell execution
src/utils/geminiExecutor.ts:226
The ask-gemini and brainstorm tools accept any text in their optional model parameter and pass it right after -m to the gemini CLI. Because the gemini CLI uses yargs to parse arguments, a model value starting with a dash—such as --yolo or -y—is treated as a separate CLI flag instead of a model name while gemini falls back to its default model. If prompt injection in a webpage, issue, or file tricks the host AI agent into calling ask-gemini or brainstorm with model set to --yolo, Gemini CLI unlocks auto-approved shell command execution and file writes on macOS, Linux, and Windows.
Fix: Validate the model parameter against a strict allowlist pattern such as /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/ and reject any value starting with a dash before building CLI arguments.
-
HighWindows cmd.exe variable expansion allows secret leakage and command injection
src/utils/commandExecutor.ts:107
On Windows, executeCommand runs commands with shell: true (cmd.exe) and wraps arguments in double quotes via quoteForCmd. However, cmd.exe still expands %VAR% environment variables inside double quotes before it finishes parsing quotes and command separators like &. If an agent is tricked into passing %VAR% in ping (or in ask-gemini or brainstorm prompts that do not contain @), cmd.exe expands secret environment variables such as API keys and returns or sends them out; worse, referencing %CMDCMDLINE:~-1%&command expands to a raw double quote that breaks out of quoteForCmd's quoting and runs arbitrary OS commands on Windows.
Fix: Return ping responses directly in JavaScript instead of spawning echo, pass all prompts over stdin rather than command-line flags, strictly validate non-prompt arguments, and avoid shell: true where possible (such as spawning .exe binaries or node directly).
-
LowSandbox mode fails open when using the Antigravity (agy) backend
The ask-gemini tool's schema tells the AI agent to set sandbox: true to safely run potentially risky code in an isolated environment, without mentioning any backend limitation in the tool description. When running on the agy backend—either via GEMINI_MCP_BACKEND=agy or automatically for all default installs starting 2026-06-18—print mode does not isolate tool execution and runs operations with the user's full privileges. Instead of refusing to run when sandbox: true cannot be honored, runWithBackend proceeds to execute the request and only attaches a warning notice to the reply after the unsandboxed run has already finished.
Fix: Fail closed by throwing an error before calling backend.run() whenever sandbox: true is requested on a backend where sandboxIsolatesToolExecution is false, and note this limitation in the ask-gemini tool schema description.
-
LowCached changeMode code chunks are stored in a shared world-accessible temp folder
Multi-chunk changeMode responses are written as JSON files inside a fixed gemini-mcp-chunks folder under os.tmpdir() (such as /tmp/gemini-mcp-chunks on Linux) using default permissions and without checking directory ownership or symlinks. On a shared computer, another local user can read cached snippets of the user's source code or pre-create the folder and tamper with cached edit chunks before fetch-chunk returns them to the AI agent.
Fix: Store cached chunks in a per-user directory created with mode 0o700, verify ownership with lstatSync so symlinks are rejected, and write cache files with mode 0o600.
-
LowchangeMode instructs the host agent to apply edits without reading files and skips path checks
src/utils/changeModeTranslator.ts:20
Unlike @file reads—which assertSafeFileReferences restricts to the project root—validateChangeModeEdits accepts any non-empty filename returned by Gemini, including ../ traversals or absolute paths. formatChangeModeResponse then wraps those edits in an instruction telling the host coding agent to apply them directly without reading the target files first, which lowers the host agent's guardrails if Gemini's output was steered by prompt injection in analyzed text or web search results.
Fix: Validate every edit.filename in validateChangeModeEdits to ensure it resolves inside the current project root (matching assertSafeFileReferences), and remove the instruction telling the calling agent not to read files before editing.
