/

CVE-2026-32871

Severity:

CRITICAL RISK

(10.0)

SSRF in FastMCP OpenAPIProvider URL Construction

CVE-2026-32871

Modified

Vulnerability type

Category:

Server-Side Request Forgery (SSRF)

CWE:

CWE-918

Impact:

Authenticated Server-Side Request Forgery to Internal Backend Endpoints

Severity:

CRITICAL RISK

(10.0)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

FastMCP's OpenAPIProvider incorrectly substitutes unencoded path parameters into backend URLs, allowing attackers to manipulate request paths via directory traversal sequences.

When an attacker controls a path parameter in an OpenAPI-described endpoint, they can escape the intended API prefix and trigger authenticated SSRF requests to arbitrary internal backend endpoints.

Affected context

This vulnerability appears in FastMCP deployments that:

  • Use the OpenAPIProvider to expose backend HTTP APIs to MCP clients
  • Rely on OpenAPI specifications with templated path parameters (e.g., /api/v1/users/{user_id})
  • Have backend services reachable from the MCP server that are not directly accessible to the client
  • Attach authentication or authorization headers to outbound requests from the MCP provider

The risk materializes when MCP clients can influence path parameter values that are used to construct backend URLs without additional validation or encoding.

Exploit preconditions

  • Attack surface: MCP API endpoints defined via OpenAPI that include path parameters.
  • Required access: Ability for an attacker-controlled MCP client (or a compromised client) to invoke operations with attacker-chosen path parameter values.
  • Trigger point: Invocation of an OpenAPI operation where the RequestDirector's _build_url() method substitutes user-controlled values into a URL template and then passes it through urllib.parse.urljoin().
  • Why exploitation is possible: Path parameter values are inserted into the URL without URL-encoding or path normalization checks. urljoin() treats ../ sequences as directory traversal, allowing the constructed URL to escape the intended base path and target arbitrary internal endpoints while still carrying configured authorization headers.

Why this happens

The core issue lies in how the RequestDirector's _build_url() method constructs backend URLs from OpenAPI templates. Instead of treating path parameters as data that must be encoded, the implementation directly interpolates raw parameter values into the URL path prior to calling urllib.parse.urljoin().

Because urljoin() implements URL resolution semantics, it processes ../ segments as directory traversal operations on the path. An attacker who controls a path parameter can therefore introduce ../ sequences or other path-manipulating constructs to override or escape the intended API base path chosen by the MCP provider.

This behavior maps to CWE-918: Server-Side Request Forgery (SSRF), where a server-side component builds and issues HTTP requests based on attacker-controlled input. The lack of URL-encoding and path validation allows the attacker to pivot the server into contacting internal resources on their behalf, using the server's network position and authorization context.

Potential impact

  • MCP server may send authenticated requests to unintended internal backend endpoints.
  • Attackers could access or enumerate internal APIs that are not exposed to external clients.
  • Sensitive data from internal services may be returned to the attacker-controlled client.
  • Internal state of backend services could be modified via forged requests.
  • Potential pivot to further vulnerabilities in internal services (e.g., injection, misconfiguration, debug endpoints).
  • Abuse of privileged authorization headers configured for the MCP provider to bypass normal access controls.

General mitigation guidance

Effective mitigations focus on treating URL components as data, constraining backend reachability, and validating derived request targets:

  • Strictly encode path parameters: Always URL-encode path parameter values before interpolating them into URL paths so that special characters like /, ?, #, and .. are treated as data rather than path control.
  • Normalize and validate final URLs: After constructing a URL, normalize the path and validate that it still resides under the intended API prefix or allowed path set before sending the request.
  • Constrain allowed destinations: Enforce a strict allowlist of backend hosts and base paths that the provider is permitted to contact, rejecting any request that resolves outside those boundaries.
  • Separate authorization scopes: Avoid reusing powerful authorization headers for generic routing logic; scope credentials to the minimal set of endpoints needed and avoid "catch-all" tokens with broad access.
  • Reduce trust in client-provided parameters: Treat all client-influenced path parameters as untrusted input and apply length, character, and pattern constraints before using them in request construction.
  • Defense-in-depth at backend: Configure backend services to enforce their own authorization and path restrictions, assuming that upstream routing layers can be bypassed or misconfigured.

How teams detect issues like this

Detection should target both insecure URL construction patterns in code and anomalous backend traffic:

  • Static analysis and code scanning:
  • Flag code that directly interpolates user-controlled variables into URL strings without encoding.
  • Detect uses of urllib.parse.urljoin() or similar resolvers where either argument contains untrusted input, especially when used with a base path prefix.
  • Identify functions responsible for HTTP routing that lack explicit allowlists, normalization, or validation of outbound URLs.
  • Targeted code review:
  • Review the RequestDirector and similar request-building abstractions for correct use of URL-encoding routines.
  • Check that all OpenAPI-derived path parameters are treated as untrusted and are validated or constrained.
  • Inspect how authorization headers are attached to outbound requests and ensure they are not universally applied to all internal destinations.
  • Runtime monitoring and logging:
  • Log final resolved URLs for MCP-to-backend requests and alert on suspicious patterns, such as repeated ../ sequences or unexpected service paths.
  • Monitor for unusual access from the MCP server to internal endpoints that are not part of the documented API surface.
  • Policy enforcement:
  • Use HTTP proxies, service meshes, or network policies to restrict which internal endpoints the MCP server can reach, logging and blocking attempts to contact out-of-scope paths or hosts.
  • Integrate automated review tools in CI/CD pipelines to enforce URL-construction best practices and prevent reintroduction of similar patterns.

Sources

SourceLink
github.comgithub.com/PrefectHQ/fastmcp/commit/40bdfb6b1de0ce30609ee9ba5bb95ecd04a9fb71
github.comgithub.com/PrefectHQ/fastmcp/pull/3507
github.comgithub.com/PrefectHQ/fastmcp/releases/tag/v3.2.0
github.comgithub.com/PrefectHQ/fastmcp/security/advisories/GHSA-vv7q-7jx5-f767
access.redhat.comaccess.redhat.com/errata/RHSA-2026:36350
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-32871
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2454434
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-32871.json

Frequently asked

questions

Exploitability depends on how the OpenAPIProvider is exposed and which operations are available to MCP clients. If a client can invoke operations with attacker-controlled path parameters, they may be able to influence backend request paths and perform SSRF against internal services accessible to the MCP server.

Yes, some level of access is required. The attacker must be able to act as an MCP client that can call affected operations and supply crafted path parameter values. The resulting SSRF is "authenticated" in the sense that the MCP server includes its configured authorization headers when contacting backend services.

The safest pattern is to treat path parameters as untrusted data, always URL-encode them before interpolation, and validate the final resolved URL against a strict allowlist of hosts and path prefixes. This should be implemented in a central request-building component so that all OpenAPI operations benefit from the same protections.

Future designs should avoid constructing URLs via string concatenation with untrusted input. Instead, use high-level URL-building utilities that encode components by default, enforce normalizing and validating of the final URL, and restrict outbound requests to explicitly allowed destinations. Regular security reviews of request-routing code and automated checks for unsafe URL handling patterns further reduce the likelihood of similar SSRF issues.

Find out what's already
exploitable in your codebase.