CVE-2025-64340: Fastmcp FastMCP Has A Command Injection Vulnerability
MODERATECVE-2025-64340 is a MODERATE (CVSS 6.7) fastmcp has a command injection vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting Fastmcp libraries in the PyPI ecosystem. The issue involves fastmcp has a command injection vulnerability - gemini cli. Remediation is available by upgrading affected packages to version 3.2.0.
CVE-2025-64340 at a Glance
Security Impact
CVSS: 6.7
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H).
How to Fix CVE-2025-64340
To remediate this vulnerability, upgrade all affected Fastmcp dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install fastmcp>=3.2.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show fastmcp
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2025-64340, inspect your installed packages using pip:
pip show fastmcp
Analyze the terminal output to locate any version of Fastmcp in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.2.0), your application is affected.
Note: The pip show fastmcp command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where the product constructs all or part of an os command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended os command when it is sent to a downstream component. In Fastmcp, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-64340 Affected Fastmcp Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
fastmcp
|
PyPI |
< 3.2.0
|
3.2.0
|
References
Frequently Asked Questions
What is CVE-2025-64340?
Which Fastmcp versions are affected?
What version fixes CVE-2025-64340?
Is fastmcp affected?
What is the CVSS score of CVE-2025-64340?
What CWE is associated with CVE-2025-64340?
How can I check PyPI dependencies for CVE-2025-64340?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-m8x7-r2rg-vh5g",
"modified" : "2026-04-06T17:37:31Z",
"published" : "2026-03-31T22:24:15Z",
"aliases" : [ "CVE-2025-64340" ],
"summary" : "FastMCP has a Command Injection vulnerability - Gemini CLI",
"details" : "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.\n\nPoC:\n```python\nfrom fastmcp import FastMCP\n\nmcp = FastMCP(name=\"test&calc\")\n\n@mcp.tool\ndef roll_dice(n_dice: int) -> list[int]:\n \"\"\"Roll `n_dice` 6-sided dice and return the results.\"\"\"\n return [random.randint(1, 6) for _ in range(n_dice)]\n```\n\n```\nfastmcp install claude-code server.py # or: fastmcp install gemini-cli server.py\n```\n\nOn Windows, this opens Calculator via the `&calc` in the server name.\n\nImpact:\nArbitrary 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).\n\nPatched in #3522 by validating server names to reject shell metacharacters.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "fastmcp"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.2.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/PrefectHQ/fastmcp/security/advisories/GHSA-m8x7-r2rg-vh5g"
}, {
"type" : "WEB",
"url" : "https://github.com/jlowin/fastmcp/security/advisories/GHSA-m8x7-r2rg-vh5g"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-64340"
}, {
"type" : "WEB",
"url" : "https://github.com/PrefectHQ/fastmcp/pull/3522"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/PrefectHQ/fastmcp"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-78" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-03-31T22:24:15Z",
"nvd_published_at" : "2026-04-03T16:16:23Z"
}
}