CVE-2025-64340: Fastmcp FastMCP Has A Command Injection Vulnerability

MODERATE
Advisory Identifier: GHSA-m8x7-r2rg-vh5g
CVSS 6.7
CWE-78
Published
Advisory Summary

CVE-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

CVE Identifier CVE-2025-64340
GHSA Identifier GHSA-m8x7-r2rg-vh5g
Severity MODERATE
CVSS v3.1 Base Score 6.7
CWE Classification CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Affected Product Fastmcp
Package Ecosystem PyPI
Published Date
Last Updated

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).

Attack Vector Local (AV:L)
Attack Complexity High (AC:H)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (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.

fastmcp fixed: 3.2.0
pip install fastmcp>=3.2.0
Verify Direct and Transitive Dependencies

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

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: ```python 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.

CVE-2025-64340 Affected Fastmcp Versions

1 component(s)
Fixed Versions:
3.2.0
Product / Package Ecosystem Affected Versions Fixed Version
fastmcp
PyPI
< 3.2.0
3.2.0

References

Frequently Asked Questions

What is CVE-2025-64340?
CVE-2025-64340 is a security vulnerability in Fastmcp involving FastMCP has a Command Injection vulnerability - Gemini CLI under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Which Fastmcp versions are affected?
Affected versions include releases prior to 3.2.0 across affected packages: fastmcp.
What version fixes CVE-2025-64340?
Upgrading to 3.2.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is fastmcp affected?
Yes, fastmcp is affected in releases prior to 3.2.0. Upgrade your dependency to 3.2.0 or later.
What is the CVSS score of CVE-2025-64340?
CVE-2025-64340 has a CVSS v3.1 base score of 6.7 (MODERATE) with vector string CVSS:3.1/AV:L/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2025-64340?
CVE-2025-64340 is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') (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.).
How can I check PyPI dependencies for CVE-2025-64340?
Run the dependency tree command: 'pip show fastmcp'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}