Skip to content

mcp-server-fetch follows redirects with no private-IP / metadata SSRF guard | #4838

Description

@tiagovilasboas

Static review of public source at commit f46d9578190b. No traffic was sent to any MCP environment.

The Fetch MCP server retrieves arbitrary URLs with redirects enabled and no private/link-local/metadata IP checks:

src/fetch/src/mcp_server_fetch/server.py:

async with AsyncClient(proxy=proxy_url) as client:
    response = await client.get(
        url,
        follow_redirects=True,
        headers={"User-Agent": user_agent},
        timeout=30,
    )

The README already documents the risk (This server can access local/internal IP addresses…). Robots.txt handling is present; SSRF egress control is not. A model-controlled url (or a redirect hop) can therefore reach loopback, RFC1918, link-local, or cloud metadata endpoints from the host that runs the server.

Suggested change (defense-in-depth, opt-out for demos):

  • Resolve hostname → IP(s) before connect; block private/special-purpose ranges and known metadata addresses by default (revalidate on each redirect hop).
  • Add --allow-private-ips / env escape hatch and document it next to the existing CAUTION.
  • Prefer the same posture pydantic-ai’s safe_download / similar libraries use (block-by-default, explicit allow_local).

Severity: medium as insecure default for an agent-facing fetch tool; README already discloses the class of risk. Not filed as a novel CVE claim. No proof-of-concept.

Happy to send a focused PR if useful.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions