NewApp Monitoring is liveSign up free
AgentbeamBeta
AI agent vulnerability · FastMCP

CVE-2025-64340: FastMCP has a Command Injection vulnerability - Gemini CLI

mediumCVSS 3.1 6.7GHSA-m8x7-r2rg-vh5g

FastMCP before 3.2.0 has a command injection on Windows in fastmcp install claude-code and fastmcp install gemini-cli. A server name with shell metacharacters such as & runs extra commands as the user. macOS and Linux are not affected. Upgrade fastmcp to 3.2.0.

Published Mar 31, 2026 · Updated Apr 6, 2026 · Analysis Oct 31, 2026

What an attacker can do

The two install commands call subprocess.run() with a list of arguments, which is normally safe. On Windows, the claude and gemini CLIs are often installed as .cmd wrappers. Those run through cmd.exe, which flattens the arguments into one string and interprets characters like & as command separators. A server name such as test&calc therefore runs calc after the install call. The advisory's proof of concept opens Calculator this way.

The attacker must get a user to run fastmcp install against a server whose name they control, for example a downloaded server.py from an untrusted repository. User interaction and local access are required, and complexity is rated high. Success gives arbitrary command execution with the rights of the user running the install. Config-file install targets (cursor, goose, mcp-json) are not affected.

Who is affected

pip package fastmcp, versions before 3.2.0, on Windows hosts where the claude or gemini CLI is installed as a .cmd wrapper and you use the install claude-code or install gemini-cli commands. Check the version:

pip show fastmcp

Before installing a server, read the name set in its FastMCP(name=...) call.

fastmcp

Ecosystem
PyPI
Affected
< 3.2.0
Fixed in
3.2.0
Check
pip show fastmcp

How to fix it

Upgrade to fastmcp 3.2.0:

pip install --upgrade fastmcp==3.2.0

Pull request 3522 validates server names and rejects shell metacharacters. The advisory lists no workaround. Until you upgrade, do not run these install commands on servers from sources you do not trust, and check the server name for characters like & first.

How to tell if you were hit

Look for server names with &, |, ^ or similar characters in the FastMCP(name=...) call of any server you installed. On Windows, check process creation logs for cmd.exe spawning unexpected programs right after a fastmcp install run. The advisory gives no other indicators. Beam records agent shell commands, which helps when an agent ran the install on your behalf.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Server names containing shell metacharacters (e.g., &) can cause command injection on Windows when passed to fastmcp install claude-code or fastmcp install gemini-cli. These install paths use subprocess.run() with a list argument, but on Windows the target CLIs often resolve to .cmd wrappers that are executed through cmd.exe, which interprets metacharacters in the flattened command string.

PoC:

from fastmcp import FastMCP

mcp = FastMCP(name="test&calc")

@mcp.tool
def roll_dice(n_dice: int) -> list[int]:
    """Roll `n_dice` 6-sided dice and return the results."""
    return [random.randint(1, 6) for _ in range(n_dice)]
fastmcp install claude-code server.py   # or: fastmcp install gemini-cli server.py

On Windows, this opens Calculator via the &calc in the server name.

Impact: Arbitrary command execution with the privileges of the user running fastmcp install. Affects Windows hosts where the target CLI (one of claude, gemini) is installed as a .cmd wrapper. Does not affect macOS/Linux, and does not affect config-file-based install targets (cursor, goose, mcp-json).

Patched in #3522 by validating server names to reject shell metacharacters.

Credited to nil340.

Questions

Is Linux or macOS affected by this FastMCP flaw?

No. The problem comes from Windows .cmd wrappers being run through cmd.exe. The advisory says macOS and Linux are not affected.

Which install targets are vulnerable?

fastmcp install claude-code and fastmcp install gemini-cli. The config-file targets cursor, goose and mcp-json are not affected.

Which version fixes CVE-2025-64340?

fastmcp 3.2.0, which validates server names and rejects shell metacharacters.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More FastMCP vulnerabilities

All FastMCP entries